Skip to content

Commit 54b674d

Browse files
authored
Update dense node lock description (neo4j#2675) (neo4j#2678)
Cherry-picked from neo4j#2675
1 parent 2124d5f commit 54b674d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

modules/ROOT/pages/configuration/configuration-settings.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ m|+++block+++
22052205
[frame="topbot", stripes=odd, grid="cols", cols="<1s,<4"]
22062206
|===
22072207
|Description
2208-
a|Relationship count threshold for considering a node to be dense.
2208+
a|Relationship count threshold for considering a node to be dense. This setting applies only to `standard`, `aligned`, and `high_limit` formats.
22092209
|Valid values
22102210
a|An integer that is minimum `1`.
22112211
|Default value

modules/ROOT/pages/database-internals/concurrent-data-access.adoc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,22 +257,25 @@ For these additional locks, no assumptions or guarantees can be made concerning
257257

258258
=== Locks for dense nodes
259259

260-
[NOTE]
261-
====
262-
This _Locks for dense nodes_ section describes the behavior of the `standard`, `aligned`, and `high_limit` store formats.
263-
The `block` format has a similar but not identical feature.
264-
====
260+
When creating or deleting relationships, Neo4j does not exclusively lock dense nodes during a transaction.
261+
Rather, internally shared locks prevent the deletion of nodes and shared degree locks are acquired for synchronizing with concurrent label changes for those nodes to ensure correct count updates.
265262

266-
A node is considered dense if it at any point has had 50 or more relationships (i.e. it will still be considered dense even if it comes to have less than 50 relationships at any point in the future).
267-
A node is considered sparse if it has never had more than 50 relationships.
263+
`standard`, `aligned`, and `high_limit` store formats::
264+
A node is considered dense if it, at any point, has had 50 or more relationships.
265+
Even if it later has fewer than 50 relationships, it is still considered dense. +
266+
A node is considered sparse if it has never had more than 50 relationships. +
268267
You can configure the relationship count threshold for when a node is considered dense by setting xref:configuration/configuration-settings.adoc#config_db.relationship_grouping_threshold[`db.relationship_grouping_threshold`] configuration parameter.
269268

270-
When creating or deleting relationships in Neo4j, dense nodes are not exclusively locked during a transaction.
271-
Rather, internally shared locks prevent the deletion of nodes, and shared degree locks are acquired for synchronizing with concurrent label changes for those nodes to ensure correct count updates.
269+
`block` format::
270+
A node is considered dense for *a particular relationship type* when it surpasses a certain internal size threshold, which typically happens at approximately 50 relationships of that type.
271+
However, it also depends on the number and size of properties connected to these relationships.
272+
Therefore, a node may be dense for one relationship type (e.g., A) and sparse for another (e.g., relationship type B).
272273

273-
At commit time, relationships are inserted into their relationship chains at places that are currently uncontested (i.e. not currently modified by another transaction), and the surrounding relationships are exclusively locked.
274+
At commit time, relationships are inserted into the backing data structures in a manner that allows concurrent modification.
275+
For example, multiple transactions can create, update, or delete relationships connected to the same dense nodes concurrently.
276+
This process may in rare cases acquire additional exclusive locks in a sorted manner if necessary, to ensure data consistency.
274277

275-
In other words, relationship modifications acquire coarse-grained shared node locks when doing the operation in the transaction, and then acquire precise exclusive relationship locks during commit.
278+
In other words, relationship modifications acquire coarse-grained shared node locks when doing the operation in the transaction, and then acquire precise exclusive locks during the commit.
276279

277280
The locking is very similar for sparse and dense nodes.
278281
The biggest contention for sparse nodes is the update of the degree (i.e. number of relationships) for the node.

0 commit comments

Comments
 (0)