Neo4j 2.2 Cypher Locking Regression?

I have some code that needs to get a write lock on a node. For various reasons, it is inconvenient to use the Java API to obtain a lock, so I acquired it in Cypher 2.1 by setting a dummy value on node. Then I use node in another request. In 2.1, calling SET n._lock = 1 was enough to acquire the write lock on the node for the rest of the transaction. However, when I upgrade to 2.2, I have a test that fails because the write lock seems to be lost between requests within the same transaction. (I'm using the community version of Neo4j in inline mode.)

So, I have two requests like this (in the same TX):

    MATCH (a:A)
    WHERE ID(a) = {aId}
    SET a._lock = 1

    MATCH (a:A)
    WHERE ID(a) = {aId}
    WITH a
    MATCH (b:B)-[:IS_AT]->(a:A)
    ...  // then more application code in the same TX

      

I have a unit test that calls this code multiple times in parallel and checks the mutex property of the later code, i.e. later code did not run in parallel due to write blocking in the first request (there is only one "A" node in the test). This test passes in 2.1 but fails in 2.2. If I change the second query as

    MATCH (a:A)
    WHERE ID(a) = {aId}
    SET a._lock = 1
    WITH a
    MATCH (b:B)-[:IS_AT]->(a:A)
    ...

      

The test passes. This seems to indicate that TX is "losing" the write lock between the first and second requests, which is a concern. Can anyone explain this behavior?

+1


source to share





All Articles