Getting Inconsistent Relations when using Neo4j Version 5

Hi there,

our use case might be unusual. We have a quite huge database with some billions of nodes and relations. There are some categorical relations types in which single nodes may be target of hundreds of millions of relations. Once created, the database is read-only. Whenever we want to update the data, a new database is created from scratch using "neo4j-admin" to import the CSV data.
This worked well for quite some time with neo4j version 4.4.3. Now we want to build the same thing with version 5. The last attempt was version 5.21.0 Community Edition. The import process seems to be successful, but when we run the consistency check "neo4j-admin database check" we get lots of errors regarding inconsistent relations. E.g.:

2024-07-03 11:40:04.475+0000 ERROR [o.n.c.ConsistencyCheckService] The target node does not have a relationship chain.
        Relationship[3619136827,used=true,source=571112742,target=1005006858,type=20,sPrev=5411327501,sNext=3616139165,tPrev=3619136828,tNext=3619136826,prop=10678626935,!sFirst,!tFirst]
        Inconsistent with: Node[1005006858,used=true,created=false,rel=-1,prop=1573944898,labels=Inline(0x1000000042:[66]),light,fixedRefs=false]

When checking this message it is true that the relation exists, both nodes exist, but the target node does not show any relations. The inconsistent relations are not constant over different attempts to build the database. Which relations are broken is at least a bit random.
Any help or ideas, how to get that fixed?

Kind regards

@eckhard.lindenblatt So the graph builds? Are you using ${NEO4J_DIR}/bin/neo4j-admin import to build the graph?

Yes, the resulting graph db looks and behaves okay on the first glance. It took some time and effort to find out that it has broken relations. And, yes, we are using ${NEO4J_DIR}/bin/neo4j-admin import to build it.

Is this correct?

Amongst the billions of nodes and relations, you have some instances where:

  • Node1 exists
  • Node2 exists
  • There should be a relation between Node1 and Node2

The error message stays that "The target node does not have a relationship chain." - does anyone know what that message means? There doesn't seem to be anything online about this error.

That is not exactly what happens.

  • Node1 exists
  • Node2 exists
  • the Relation exists
    but: Node2 does not know about that relation.

Does that mean you can traverse from Node1 across the Relation to Node2 but that you cannot traverse from Node2 across the Relation to Node1?

As in:

MATCH (n1:Node1) -[r:Relation]- (n2:Node2)
WHERE n1.id = <some-id>
RETURN n1, r, n2

works but that

MATCH (n1:Node1) -[r:Relation]- (n2:Node2)
WHERE n2.id = <some-other-id>
RETURN n1, r, n2

does /not/ work?

ps: and just checking that it isn't as simle as getting the relation arrows the wrong way round in cypher?

Yes, that example describes the situation well. And yes, we have payed attention to the direction of the arrows.

In before a real solution is found, you may want to try different ways of checking consistency. You can check

  • offline database directly
  • dump of an offline database
  • backup of online database

and possibly find more hints on what is going on along the way. "Four ways to check the consistency of a Neo4j graph" has an overview for neo4j. It is meant for versions 3.5-4.4 but mostly works and similarly for 5.*. Only the first way no longer works as backup no longer comes with the immediate option to check consistency, i.e. --check-consistency is gone.

Compare syntax:

  • backup (of online db) 4.4 vs. 5
  • dump (of offline db) 4.4 vs. 5
  • consistency checker of backup, dump or stopped/offline database 4.4 vs. 5

Hi grapholog12514,

I ran the consistency-check against the offline database. What additional insight could I expect from running the same tool e.g. against a dump of the very same database? Would you expect the results to be different?

We retried building the database last week using neo4j community version 5.22.0 and it worked. The consistency check passed without any errors! A second trial also passed. Cannot tell why, but possibly the problem might be solved.

1 Like