I am using CYPHER like below (with Neo4j 2.2.3, over the transactional cypher REST endpoint) to atomically read and increment a counter property on a node:
MATCH node WHERE id(node)={nodeId}
SET node.counter=COALESCE(node.counter,0) + 1
RETURN node.counter
I have multiple threads making REST posts like this, and I have now seen a case where two threads got the same counter value returned.
This behavior looks similar to what is described as a possible regression from 2.1 to 2.2 here: Neo4j 2.2 Cypher locking regression?
However, earlier it was suggested that this isn't possible in CYPHER (see comments here: https://stackoverflow.com/a/18486645) ... even earlier it seems to have been possible (see: https://stackoverflow.com/a/18450171)
Is there a CYPHER query, similar to above, that will reliably produce unique (monotonically increasing) counter values when there are multiple concurrent REST POSTs of the query?