Hello all,
I'm experiencing random missing or double reads with my queries and would be glad to get a definite answer on whether or not this is expected. I have already read the dedicated section on the doc.
My data model looks like so:
I created it with the following query:
MERGE(c:Container{})
WITH c
UNWIND [1,2,3] as id
MERGE(c)-[r1:Owns]->(e1:ConstituentA{id: id})
MERGE(c)-[r2:Owns]->(e2:ConstituentB{id: id})
RETURN c, e1, e2, r1,r2
But that's only demonstration data. The real, problematic business logic involves two distinct steps:
ConstituentAnodes are created first, in one transaction each, using a query that is very similar to the one above- Once they are all created (all transactions are complete and committed), I run dozens of concurrent requests that fall into two categories:
- some create
ConstituentBnodes, in the same wayConstituentAwere created - others look up
ConstituentAnodes using a query that resembles the one below:
- some create
OPTIONAL MATCH(c:Container)
UNWIND [{
label: "ConstituentA", id: 1
}, {
label: "ConstituentA", id: 10
}] AS constituentDef
OPTIONAL MATCH(c)-[:Owns]->(constituent{id:constituentDef.id})
WHERE
(constituentDef.label = 'ConstituentA' AND constituent:ConstituentA)
WITH c, constituent IS NOT NULL as constituentExists
RETURN c IS NOT NULL AS containerExists, collect(constituentExists) as constituentsExist
In other words, there are dozens of transactions creating ConstituentB nodes linked to the common Container node with Owns relationships while multiple other transactions try to find ConstituentA nodes by traversing Owns relationships starting on the same Container node.
A typical correct result based on my demo data above would be:
╒═══════════════╤═════════════════╕
│containerExists│constituentsExist│
╞═══════════════╪═════════════════╡
│true │[true, false] │
└───────────────┴─────────────────┘
But on some occasions (maybe 1 out of 20), a ConstituentA with the expected id cannot be found, or I get two occurrences of it, leading to the constituentsExist to contain one too many item.
To give a rough sense of the numbers involved: the typical use case involves the creation of 50 ConstituentB nodes while looking up 50 ConstituentA nodes in 50 distinct transactions.
My question is: is this a case where the concurrent matching and creation of Owns relationships on the same node (Container, here) can lead to missing or double reads? The doc is not very clear on that point and since the nodes being created do not hold the same label as the ones being looked up, I was not expecting the issue to occur.
Any help very much appreciated! Thanks for reading thus far ![]()


