Skip to content

feat: v25 upgrade#284

Merged
mlwelles merged 19 commits intomainfrom
feat/v25-upgrade
Mar 20, 2026
Merged

feat: v25 upgrade#284
mlwelles merged 19 commits intomainfrom
feat/v25-upgrade

Conversation

@mlwelles
Copy link
Copy Markdown
Contributor

@mlwelles mlwelles commented Feb 27, 2026

Summary

Upgrades dgraph4j from v24.2.0 to v25.0.0, bringing full parity with the Dgraph v25 API.

New APIs

  • RunDQL — run DQL queries and mutations directly without managing transactions
  • ID AllocationallocateUIDs(), allocateTimestamps(), allocateNamespaces()
  • Namespace ManagementcreateNamespace(), dropNamespace(), listNamespaces()
  • Convenience MethodsdropAll(), dropData(), dropPredicate(), dropType(), setSchema()

All methods available on both DgraphAsyncClient (returning CompletableFuture<T>) and DgraphClient (sync wrapper).

Typed Exception Hierarchy

All exceptions now extend DgraphException (which extends StatusRuntimeException), with isRetryable() on every subclass. Existing catch (StatusRuntimeException e) blocks continue to work.

DgraphException (extends StatusRuntimeException)
├── AlphaException [retryable] — server reachable but temporarily unable to serve
│   ├── AlphaNotReadyException — startup, indexing, Raft init
│   ├── AlphaShutdownException — draining mode, try a different node
│   └── AlphaOverloadedException — too many pending requests
├── ConnectionException [retryable] — network-level, server unreachable
├── DeadlineExceededException [retryable] — operation timed out
├── TxnException
│   ├── TxnConflictException [retryable] — transaction conflict
│   ├── TxnFinishedException — transaction already committed/discarded
│   └── TxnReadOnlyException — mutation on read-only transaction
├── ResourceExhaustedException — e.g., gRPC message size limit
├── QueryException — invalid query/mutation syntax
├── DisallowedOperationException — server config blocks the operation
└── AuthException — authentication or authorization failure

Exceptions utility class centralizes translation from gRPC status codes to typed exceptions. ExceptionUtil retained as deprecated alias for backward compatibility.

Automatic Retry

withRetry() on both DgraphClient and DgraphAsyncClient provides managed transaction retry with exponential backoff:

Response resp = client.withRetry(txn -> {
    txn.mutate(mutation);
    txn.commit();
    return txn.query(query);
});

Configurable via RetryPolicy with support for read-only and best-effort transactions:

client.withRetry(RetryPolicy.bestEffort(), txn -> txn.query(query));

client.withRetry(RetryPolicy.builder()
    .maxRetries(10)
    .baseDelay(Duration.ofMillis(200))
    .build(), txn -> { ... });

Async variant uses non-blocking backoff via CompletableFuture.delayedExecutor.

Internal Refactoring

  • CompletableFutures utility class — extracted runWithRetries (JWT-refresh retry) and attemptAsync (managed transaction retry with backoff) from DgraphAsyncClient into a stateless static utility class, keeping the async client focused on the Dgraph API surface
  • Updated CODEOWNERS from @rarvikar to @mlwelles

Other Changes

  • Updated proto definitions to Dgraph v25 (8 new RPCs)
  • Updated copyright from Hypermode Inc. to Istari Digital, Inc.
  • Updated GitHub org references from hypermodeinc to dgraph-io
  • Deprecated clientStubFromSlashEndpoint / clientStubFromCloudEndpoint (now throw UnsupportedOperationException with migration guidance)
  • Fixed isJwtExpired() to handle UNKNOWN status code
  • Fixed 5 broken docs.dgraph.io links to match new site structure
  • Updated README with new API documentation sections
  • Updated CHANGELOG, samples, and CI workflows

Deprecated

  • clientStubFromSlashEndpoint() — throws UnsupportedOperationException, use clientStub() instead
  • clientStubFromCloudEndpoint() — throws UnsupportedOperationException, use clientStub() instead
  • ExceptionUtil — use Exceptions instead

Removed

  • Cloud-related documentation section from README

Test plan

  • Integration tests pass against a 3-alpha + 1-zero Dgraph cluster with ACL enabled
  • 3 new unit test classes: ExceptionHierarchyTest, ExceptionMappingTest, RetryPolicyTest
  • All pre-existing tests continue to pass
  • ./gradlew clean generateProto compileJava succeeds
  • Trunk linter passes
  • testDropType fixed — added dropAll() for clean schema state before type creation

Closes #283

- Update proto definitions to Dgraph v25 (8 new RPCs)
- Add RunDQL API for running DQL queries/mutations directly
- Add allocateUIDs, allocateTimestamps, allocateNamespaces methods
- Add namespace management (createNamespace, dropNamespace, listNamespaces)
- Add convenience methods (dropAll, dropData, dropPredicate, dropType, setSchema)
- Remove defunct Dgraph Cloud code (clientStubFromSlash/CloudEndpoint)
- Update copyright from Hypermode Inc. to Istari Digital, Inc.
- Update GitHub org references from hypermodeinc to dgraph-io
- Fix ExceptionUtil.isJwtExpired() to handle UNKNOWN status code
- Add 24 new integration tests across 4 test classes
- Update documentation, CHANGELOG, samples, and CI workflows
- Bump version to 25.0.0
…links

- Restore clientStubFromSlashEndpoint and clientStubFromCloudEndpoint as
  @deprecated stubs that throw UnsupportedOperationException
- Update 5 broken docs.dgraph.io links to match new site structure:
  - /deploy/#tls-configuration → /admin/security/tls-configuration
  - /master/query-language/#indexes-in-background → /dql/dql-schema/#predicate-indexing
  - /mutations/#upsert-block → /dql/dql-mutation#upsert-block
  - /mutations/#conditional-upsert → /dql/dql-mutation#conditional-upsert
  - /clients/overview/#transactions → /clients/#transactions
@mlwelles mlwelles marked this pull request as draft February 27, 2026 04:17
@mlwelles mlwelles marked this pull request as ready for review February 27, 2026 21:57
…RuntimeException

- DgraphException now extends StatusRuntimeException for backward compatibility
- TxnException reparented under DgraphException for unified hierarchy
- 7 new typed exception classes for specific error conditions
- isRetryable() on all exceptions, serialVersionUID on all classes
- DgraphInterruptedException uses Status.CANCELLED and preserves interrupt flag
- 21 tests covering hierarchy, status codes, retryability, and message format
Comment thread samples/DgraphJavaSampleDeadlineInterceptors/README.md Outdated
Comment thread samples/DgraphJavaSampleWithDeadlineAfter/README.md Outdated
mlwelles added 5 commits March 2, 2026 13:39
…ExceptionUtil

translate() now unwraps CompletionException before type-checking,
preventing typed exceptions from being re-translated into generic ones.
findStatusRuntimeException() guards against circular cause chains and
limits traversal depth to 20.
…ionUtil to Exceptions

- Rename all DgraphException subclasses: DgraphAlphaException -> AlphaException,
  DgraphConnectionException -> ConnectionException, DgraphAuthException -> AuthException, etc.
- Rename DgraphInterruptedException to CancelledException, then remove it entirely
  (InterruptedException wraps to generic DgraphException, preserving interrupt flag)
- Rename ExceptionUtil -> Exceptions; retain ExceptionUtil as deprecated delegate
- Rename DgraphOperationNotAllowedException -> DisallowedOperationException
- Simplify Exceptions.translate(): no cause-chain walking, direct instanceof checks only
- Remove findStatusRuntimeException() (over-engineered for our code paths)
- Rewrite README exception section: hierarchy diagram + progressive catch examples
  instead of kitchen-sink catch block
- Add TxnException.getMessage() override for backward-compatible plain descriptions
- DgraphException keeps its prefix as the hierarchy root
Add RetryPolicy, TransactionOp, AsyncTransactionOp, and withRetry() on
both DgraphClient (blocking) and DgraphAsyncClient (non-blocking via
delayedExecutor). Supports read-only and best-effort transactions via
RetryPolicy.readOnly() and RetryPolicy.bestEffort().
…n AlterConvenienceTest

AclTest.verifyOperation now handles typed DgraphException subclasses
(e.g. AuthException) thrown directly rather than wrapped in a cause
chain, since Exceptions.translate() produces typed exceptions that ARE
StatusRuntimeExceptions.

AlterConvenienceTest.testDropType uses 'schema { types }' instead of
'schema(type: Person) {}' which returned empty on the CI cluster.
@mlwelles mlwelles mentioned this pull request Mar 3, 2026
mlwelles added 3 commits March 3, 2026 01:49
…pdate CODEOWNERS

testDropType was failing because prior tests left the `name` predicate
in the schema, causing Dgraph v25 to skip the alter operation (and its
type definition) when no predicate changes were detected.

Also updates CODEOWNERS from @rarvikar to @mlwelles.
…tility class

Moves runWithRetries (JWT-refresh retry) and attemptAsync (managed
transaction retry with backoff) out of DgraphAsyncClient into a
stateless utility class. DgraphAsyncClient delegates to the static
methods, passing its own retryLogin callback, executor, and transaction
factory as parameters.
@mlwelles mlwelles requested a review from matthewmcneely March 3, 2026 20:42
Copy link
Copy Markdown
Contributor

@matthewmcneely matthewmcneely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, and this is a big one, Istari legal want the copyright header to read

/*
 * SPDX-FileCopyrightText: © 2017-2026 Istari Digital, Inc.
 * SPDX-License-Identifier: Apache-2.0
 */

Comment thread .github/CODEOWNERS Outdated
Comment thread .github/PULL_REQUEST_TEMPLATE.md Outdated
- Update CODEOWNERS to use @dgraph-io/maintainers team
- Fix docs repo link to dgraph-io/dgraph-docs in PR template
- Update SPDX copyright headers to include year range (2017-2026)
- Add SPDX headers to sample source files missing them
@mlwelles mlwelles changed the title feat: upgrade dgraph4j to v25 feat: v25 upgrade Mar 10, 2026
@mlwelles mlwelles requested a review from matthewmcneely March 13, 2026 14:31
@mlwelles mlwelles merged commit b538569 into main Mar 20, 2026
6 checks passed
@mlwelles mlwelles deleted the feat/v25-upgrade branch March 20, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Exception Handling

3 participants