apoc.lock.read.rels

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.

Details

Syntax

apoc.lock.read.rels(rels)

Description

Acquires a read lock on the given RELATIONSHIP values.

Input arguments

Name

Type

Description

rels

LIST<RELATIONSHIP>

The list of relationships to acquire a read lock on.

Example

Given this dataset:

CREATE (:Person {name: 'Alice'})-[:KNOWS {since: 2019}]->(:Person {name: 'Bob'})

The following query acquires a read lock on the relationship before reading its property, preventing other transactions from acquiring write locks on it for the duration of this transaction:

MATCH ()-[r:KNOWS]->()
CALL apoc.lock.read.rels([r])
RETURN r.since AS since
Results
since

2019

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.