I am writing a node js function which contains a cypher query to form a relation between two person node if they met each other. When they met decide by the exchange of Bluetooth packet.
Problem is when many Bluetooth packets received by server simultaneously, there are many MET relationship formed between two-person node.
My query look like this in psudo form
Match Person A with id X
Match Person B with id y
Optinal Match A and B has any MET relation in A-> B or B<-A
Then if no relation create A -[r:Met]-> B
if relation exist increse the count of met ( r.count++)
In any given case, there should be only one MET relationship in either A->B or B<-A.
I don't believe the problem is the parallel access because afaik all nodes relevant to a transaction are locked until it finishes. Can you post your actual Cypher Query? For example this one works for me
MATCH (a:Person {id:x})
MATCH (b:Person {id:y})
MERGE (a)-[r:MET]->(b)
ON MATCH
SET r.count = r.count+1
ON CREATE
SET r.count = 0