Bill Michaelson
Bill Michaelson

Reputation: 376

neo4y Cypher delete won't commit

I have been experimenting with the REST API recently. My work cycle involves running my test program which add nodes a relationships to my graphDB, then deleting them by using neo4j-shell with a Cypher command as preparation for the next test run. All was well until the deletions started failing. At first I thought this was because my deletions encompassed too many nodes for a single transaction, so I tried to restrict the scope. It doesn't help. I'm seeing this...

neo4j-sh (?)$ match (s:Tweeter)-[m:Tweet]->(r:Tweeter) where s.handle =~ '@C.*' delete s,m,r;
+-------------------+
| No data returned. |
+-------------------+
Nodes deleted: 12
Relationships deleted: 21
80 ms
TransactionFailureException: Transaction was marked as successful, but unable to commit transaction so rolled back.

I don't know what to try next. I see no clues in the server log.

Upvotes: 2

Views: 947

Answers (2)

Bill Michaelson
Bill Michaelson

Reputation: 376

I think the problem began when I added a second type of target node to the mix with a different label. I have since change the cleanup to delete all relationships first, then each of the node types. It's working reliably so far.

Upvotes: 1

Brian Underwood
Brian Underwood

Reputation: 10856

Maybe you need to delete the relationships for the nodes?

MATCH
  (s:Tweeter)-[m:Tweet]->(r:Tweeter)
  WHERE s.handle =~ '@C.*'
OPTIONAL MATCH
  s-[orel1]-(),
  r-[orel2]-()
DELETE s,m,r,orel1,orel2;

Upvotes: 2

Related Questions