I was wondering if I explicitly acquire a read lock then use the node, will the transaction drop the lock?
I tried running a test for this but for some reason when I tried to run more than 2 cypher queries in a transaction using neo4j sandbox, the transaction stalled on the third and didn't give me a reason.
Is the read lock on node (a: A) ever dropped during the transaction, after it is acquired in the explicit apoc.lock.read call?
tx.run("MATCH (a: A) call apoc.lock.read.nodes([a]) RETURN NULL").consume()
# POINT 1
tx.run("MATCH (a: A) RETURN a.prop").consume()
# POINT 3
tx.run("call apoc.util.sleep(10000) RETURN NULL").consume()
# POINT 4
with driver.session() as session:
Thank you! I have already read through that page. That's actually what helped me come up with the test case.
I was unable to run the test case on the sandbox and I do not have access to enterprise edition of neo4j.
Specifically, I run the following code on my computer:
from neo4j import GraphDatabase, basic_auth
tx.run("MATCH (m: E) call apoc.lock.read.nodes([a]) RETURN NULL").consume()
tx.run("MATCH (m: E) RETURN m.prop").consume()
tx.run("call apoc.util.sleep(30000) RETURN NULL").consume()
neo4j = GraphDatabase.driver(
with neo4j.session() as session:
And then I try to use the techniques on that page to find the locks held by the process. However, it seems like the process just never runs the third part of the transaction and just gets stuck after point 2 with no active query.
hence, I was unable to answer my question.
ok, but now is it working?
I just gave it another try and it worked this time! There must have been something wrong with the sandbox I had.
The answer, for all those curious, is that the lock is held throughout the whole transaction. It is only released when the transaction is over.
no problem, if there is anything that I could help you let me know