apoc.lock.read.nodesProcedure
|
This procedure is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime. For more information, see the Cypher Manual → Parallel runtime. |
Syntax |
|
||
Description |
Acquires a read lock on the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The list of nodes to acquire a read lock on. |
|
Example
Given this dataset:
CREATE (:Person {name: 'Alice', age: 30})-[:KNOWS {since: 2019}]->(:Person {name: 'Bob', age: 25})
The following query acquires read locks on all Person nodes before reading their properties, preventing other transactions from acquiring write locks on them for the duration of this transaction:
MATCH (n:Person)
WITH collect(n) AS people
CALL apoc.lock.read.nodes(people)
UNWIND people AS n
RETURN n.name AS name, n.age AS age ORDER BY n.age
| name | age |
|---|---|
"Bob" |
25 |
"Alice" |
30 |
Unlike a write lock, a read lock allows other concurrent transactions to also acquire read locks on the same nodes.
Only write locks - such as those required for SET, DELETE, or MERGE - are blocked.