Posted by lxwithgod:
when i insert into data in loop,i meet
Caused by: com.dataPlatform.protobuf.InvalidProtocolBufferException: Protocol message had invalid UTF-8.
after,i can’t insert into any new data unitil i restart server.
Posted by lxwithgod:
when i insert into data in loop,i meet
Caused by: com.dataPlatform.protobuf.InvalidProtocolBufferException: Protocol message had invalid UTF-8.
after,i can’t insert into any new data unitil i restart server.
deepakjois commented :
Could you post a minmal example here, which reproduces the problem.
lxwithgod commented :
this is v0.9.1
JsonObject json = new JsonObject();
json.addProperty(“name”, “Alice”);
// System.out.println(json.toString());
for(int i=0;i<10000;i++) {
System.out.println(json.toString());
Mutation mu =
Mutation.newBuilder()
.setSetJson(ByteString.copyFromUtf8(json.toString()))
.build();
dgraphClient.newTransaction().mutate(mu);
}
deepakjois commented :
This is a duplicate of #29. This is a bug that will need to be fixed in the server. I will update that issue with more details. Please follow there.
I had some comments about your client code, however. You do not seem to be committing the transaction. You have two options:
Either set the CommitNow
field in the mutation.
Mutation mu =
Mutation.newBuilder()
.setSetJson(ByteString.copyFromUtf8(json.toString()))
.setCommitNow(true)
.build();
or, a better solution is to call Transaction#Commit()
sometime. You can call it immediately after the mutation, or at the end of your loop after all the mutations have been done.
Transaction txn = dgraphClient.newTransaction()
for(int i=0;i<10000;i++) {
System.out.println(json.toString());
Mutation mu =
Mutation.newBuilder()
.setSetJson(ByteString.copyFromUtf8(json.toString()))
.build();
txn.mutate(mu);
}
txn.commit()
Hope that helps.
deepakjois commented :
Closed in favor of #29