Estimated change in cypher behavior in Neo4j 1.9.M02-M05?

Is this a known issue and / or alleged behavior in Neo4j 1.9.M02-M05 that you can no longer remove nodes and relationships from cypher requests outside of a transaction?

The following code example works in 1.8.2, but not 1.9.M02-M05:

ExecutionEngine engine = new ExecutionEngine(graphDb); ExecutionResult result = engine.execute("start n = node(*) match (n)<-[r:SOME_TYPE]-() return r"); final Iterator<Relationship> rels = result.columnAs("r"); assertTrue(rels.hasNext()); Transaction tx = graphDb.beginTx(); try { rels.next().delete(); tx.success(); } finally { tx.finish(); } 

Stack trace:

 org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only. at org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:94) at org.neo4j.kernel.PlaceboTransaction.finish(PlaceboTransaction.java:48) Caused by: java.lang.NullPointerException at org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:90) 

If you move the cypher request into a transaction, it still works and, as expected:

 Transaction tx = graphDb.beginTx(); try { ExecutionResult result = engine.execute("start n = node(*) match (n)<-[r:ONE_TO_ONE]-() return r"); final Iterator<Relationship> rels = result.columnAs("r"); assertTrue(rels.hasNext()); rels.next().delete(); tx.success(); } finally { tx.finish(); } 

Same thing with btw nodes.

If you are not using cypher to get the relationships, for example fe use node.getRelationship () or do an index search outside of tx, you can remove rel.

I wrote several tests [1] for structr that all pass with Neo4j 1.8.2, but two of them commented on the error with 1.9.M02-1.9.M05 (M01 could not be verified due to dependency problems).

Greetings Axel

[1] https://github.com/structr/structr/blob/develop/structr-core/src/test/java/org/structr/common/CypherNotInTransactionTest.java

Update: This seems to be due to lazy pricing. The following code does not throw an exception:

 Relationship r = rels.next(); Transaction tx = graphDb.beginTx(); try { r.delete(); tx.success(); [...] 
+4
source share

All Articles