-
Notifications
You must be signed in to change notification settings - Fork 65
Closed
Labels
kind/bugSomething is broken.Something is broken.status/acceptedWe were able to reproduce the issue and accept to work on itWe were able to reproduce the issue and accept to work on it
Description
Dgraph4j version: v2.1.0
Dgraph version: v1.2.0
I got following error when running multiple upserts within single transaction:
java.lang.RuntimeException: java.util.concurrent.CompletionException: java.lang.RuntimeException: The doRequest encountered an execution exception:
....
Caused by: java.util.concurrent.ExecutionException: io.dgraph.DgraphException: startTs mismatch
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
at io.dgraph.DgraphAsyncClient.lambda$runWithRetries$2(DgraphAsyncClient.java:180)
... 6 more
Caused by: io.dgraph.DgraphException: startTs mismatch
at io.dgraph.AsyncTransaction.mergeContext(AsyncTransaction.java:252)
at io.dgraph.AsyncTransaction.lambda$null$0(AsyncTransaction.java:165)
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
...
Sample code:
DgraphProto.Operation op =
DgraphProto.Operation.newBuilder()
.setSchema("email: string @index(exact) @upsert .")
.build();
dgraphClient.alter(op);
JsonArray jsonData = new JsonArray();
JsonObject person = new JsonObject();
person.addProperty("uid", "uid(v)");
person.addProperty("name", "wrong");
jsonData.add(person);
JsonObject person2 = new JsonObject();
person2.addProperty("email", "[email protected]");
person2.addProperty("uid", "uid(v)");
jsonData.add(person2);
String query =
"{\n"
+ " me(func: eq(email, \"[email protected]\")) {\n"
+ " v as uid\n"
+ " }\n"
+ "}\n";
Mutation mu =
Mutation.newBuilder().setSetJson(ByteString.copyFromUtf8(jsonData.toString())).build();
Request request = Request.newBuilder().addMutations(mu).setQuery(query).build();
Transaction transaction = dgraphClient.newTransaction();
// This upsert works
transaction.doRequest(request);
try {
transaction.doRequest(request);
} catch (RuntimeException e) {
transaction.discard();
fail(e.getMessage());
}
Problem does not occur for multiple Queries
and Mutations
. When running queryWithVars
or mutate
, new Request object is build and property startTs
is inherited from context. When raw Request is passed into doRequest
it does not happen, so this may cause the problem?
Metadata
Metadata
Assignees
Labels
kind/bugSomething is broken.Something is broken.status/acceptedWe were able to reproduce the issue and accept to work on itWe were able to reproduce the issue and accept to work on it