Acquisition of shared read locks

Neo4j allows acquisition of shared read locks on nodes and edges by using org.neo4j.graphdb.Transaction::acquireReadLock. Since this functionality is not available via Cypher, according to Transaction management - Java Reference, a workaround is for readers to perform an otherwise useless write in order to implicitly acquire a write lock, preventing any concurrent writers from modifying the node. However, this also locks out all other concurrent writers.
Is there any other way, besides, org.neo4j.graphdb.Transaction::acquireReadLock, for acquiring a shared read lock on a node?

APOC to the resuce!
You could use CALL apoc.lock.read.nodes(<list of nodes>) or CALL apoc.lock.read.rels(<list of rels>). Standard cypher does not provide any way to acquire read locks.

1 Like