apoc.lock.relsProcedure
|
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 write lock on the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The list of relationships to acquire a write lock on. |
|
Example
Given this dataset:
CREATE (:Person {name: 'Alice'})-[:KNOWS {since: 2019}]->(:Person {name: 'Bob'})
The following query acquires a write lock on a relationship before updating its property, preventing other transactions from reading or writing it until this transaction completes:
MATCH ()-[r:KNOWS]->()
CALL apoc.lock.rels([r])
SET r.since = 2020
RETURN r.since AS since
| since |
|---|
2020 |
Unlike a write lock, a read lock allows other concurrent transactions to also acquire read locks on the same relationship.
Only write locks - such as those required for SET or DELETE - are blocked.