2
votes

When fetching or when I try to delete a specifc node like

MATCH (p) 
where ID(p)=79259223
OPTIONAL MATCH (p)-[r]-() 
//drops p's relations
DELETE r,p

I get the following error

While loading relationships for Node[79259223] a Relationship[87331456] was encountered that had startNode: 80312215 and endNode: 83719851, i.e. which had neither start nor end node as the node we're loading relationships for

I also run the ConsistencyChecker what resulted in a big list of inconsistencys. However how can you fix these inconsistencys? I can not delete the nodes for instance

1

1 Answers

0
votes

Here is a possible way to "fix" an occurrence of this error. Unfortunately, it is a fairly manual approach that has to be used for every node that encounters the same problem.

Before you delete the node, you can try to delete the inconsistent relationship by its native neo4j ID. For example:

MATCH ()-[r]->()
WHERE ID(r) = 87331456
DELETE r;

NOTE: Before deleting that relationship, you should first try to take a look at it (e.g., replace DELETE WITH RETURN) to understand what you are planning to delete. You may want to do something else first or instead.

If that deletion works, then try to delete the node again, as follows:

MATCH (p) 
WHERE ID(p) = 79259223
DETACH DELETE p;

Notice that I use the DETACH DELETE syntax, which will attempt to delete all the relationships for the specified node.