neo4j - Neo4jClient Transaction Error -
when try update existing node in neo4jclient without using transaction, has unique constraint on id , name property, receive exception:
cypherexecutionexception: node 6 exists label user , property "name"=[mike]
but when try update node in transaction, receive exception:
received unexpected http status when executing request.
the response status was: 404 not found
the response neo4j (which might include useful detail!) was: {"results":[],"errors":[{"code":"neo.clienterror.transaction.unknownid","message":"unrecognized transaction id. transaction may have timed out , been rolled back."}]}
my code this:
using (var transaction = client.begintransaction()) { client.cypher .merge("(user:user { id: {id}})") .oncreate().set("user = {user}") .onmatch().set("user = {user}") .withparams(new { id = user.id, user = user }) .executewithoutresults(); transaction.commit(); }
my question is: there way actual error when using transaction, 1 when don't use transaction?
thanks
edit 1:
it looks null id in not being handled correctly. after drilling down, managed pull actual error. first exception in is:
errors = {[ { "code": "neo.clienterror.statement.invalidsemantics", "message": "cannot merge node using null property value id" } ]}
the stack trace exception is:
at neo4jclient.serialization.cypherjsondeserializer
1.getrootresultintransaction(jobject root) in [path_hiiden]\neo4jclient\serialization\cypherjsondeserializer.cs:line 316 @ neo4jclient.serialization.cypherjsondeserializer
1.checkforerrorsintransactionresponse(string content) in [path_hiiden]\neo4jclient\serialization\cypherjsondeserializer.cs:line 291 @ neo4jclient.graphclient.<>c__displayclass84_01.<preparecypherrequest>b__0(task
1 responsetask) in [path_hiiden]\neo4jclient\graphclient.cs:line 933 @ system.threading.tasks.continuationresulttaskfromresulttask`2.innerinvoke() @ system.threading.tasks.task.execute()
and after there exception 404 not found error. stack trace is:
at neo4jclient.execution.httpresponsemessageextensions.ensureexpectedstatuscode(httpresponsemessage response, string commanddescription, httpstatuscode[] expectedstatuscodes) in [path_hiiden]\neo4jclient\execution\httpresponsemessageextensions.cs:line 41 @ neo4jclient.execution.httpresponsemessageextensions.ensureexpectedstatuscode(httpresponsemessage response, httpstatuscode[] expectedstatuscodes) in [path_hiiden]\neo4jclient\execution\httpresponsemessageextensions.cs:line 14 @ neo4jclient.execution.responsebuilder.<>c__displayclass21_0.b__0(task
1 requesttask) in [path_hiiden]\neo4jclient\execution\responsebuilder.cs:line 127 @ system.threading.tasks.continuationresulttaskfromresulttask
2.innerinvoke() @ system.threading.tasks.task.execute()
can error fixed in next release please?
edit 2
using (var transaction = client.begintransaction()) { manifest.users = client.cypher .merge("(n:user { id: '8be0b8fd-c433-44d3-a7e2-3f0d1a03fefa'}) " + "on create " + "set n = { " + "id: '8be0b8fd-c433-44d3-a7e2-3f0d1a03fefa', " + "username: 'test.user', " + "name: 'test user', " + "active: true " + "} " + "on match " + "set n = { " + "id: '8be0b8fd-c433-44d3-a7e2-3f0d1a03fefa', " + "username: 'test.user', " + "name: 'test user', " + "active: true " + "}") .return(n => n.as<user>()) .results .tolist(); transaction.commit(); }
meaning fluent api causing error.
so problem in neo4j
2.2.6 change introduced whereby clienterror
(constraint violation etc) resulted in automatic rollback of transaction on server.
neo4jclient
did auto-rollback on error, , continued so. 2.2.6 resulted in 404 error transaction no longer there (previous versions fine).
so, i've made fix , published updated nuget package, version 1.1.0.12
of neo4jclient
give correct response.
Comments
Post a Comment