You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/database-internals/index.adoc
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,24 @@
1
-
= Database internals
1
+
= Database internals and transactional behavior
2
2
:description: Database internals and transactional behavior
3
3
4
+
To maintain data integrity and ensure reliable transactional behavior, Neo4j DBMS supports transactions with full ACID properties, and it uses a write-ahead transaction log to ensure durability.
4
5
5
-
To fully maintain data integrity and ensure good transactional behavior, Neo4j DBMS supports the **ACID** properties:
6
+
* **Atomicity**-- If a part of a transaction fails, the database state is left unchanged.
7
+
* **Consistency**-- Every transaction leaves the database in a consistent state.
8
+
* **Isolation**-- During a transaction, modified data cannot be accessed by other operations.
9
+
* **Durability**-- The DBMS can always recover the results of a committed transaction.
6
10
7
-
* **A**tomicity -- If a part of a transaction fails, the database state is left unchanged.
8
-
* **C**onsistency -- Every transaction leaves the database in a consistent state.
9
-
* **I**solation -- During a transaction, modified data cannot be accessed by other operations.
10
-
* **D**urability -- The DBMS can always recover the results of a committed transaction.
11
-
12
-
Specifically for Neo4j, the following transactional behavior is important to understand:
11
+
Neo4j DBMS supports the following transactional behavior:
13
12
14
13
* All database operations that access the graph, indexes, or schema must be performed in a transaction.
15
-
* The default isolation level is _read-committed isolation level_.
14
+
* The default isolation level is _read-committed_ isolation level.
15
+
* Write locks are acquired automatically at the node and relationship levels.
16
+
However, you can also manually acquire write locks if you want to achieve a higher level of isolation --_serialization_ isolation level.
16
17
* Data retrieved by traversals is not protected from modification by other transactions.
17
18
* Non-repeatable reads may occur (i.e., only write locks are acquired and held until the end of the transaction).
18
-
* One can manually acquire write locks on nodes and relationships to achieve a higher level of isolation --_serialization isolation level_.
19
-
* Locks are acquired at the Node and Relationship levels.
20
19
* Deadlock detection is built into the core transaction management.
21
20
22
-
The following sections describe the transactional behavior and how to control it.
21
+
The following sections describe the transactional behavior in detail and how to control it:
Copy file name to clipboardExpand all lines: modules/ROOT/pages/database-internals/transaction-logs.adoc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,14 +65,14 @@ Other possible ways to configure the log retention policy are:
65
65
====
66
66
This option is not recommended due to the effectively unbounded storage usage.
67
67
Old transaction logs cannot be safely archived or removed by external jobs since safe log pruning requires knowledge about the most recent successful checkpoint.
68
-
For more information, see <<checkpointing>>.
68
+
For more information, see xref:database-internals/checkpointing.adoc[Checkpointing and log pruning].
69
69
====
70
70
71
71
* `db.tx_log.rotation.retention_policy=false|keep_none` -- keep only the most recent non-empty log.
72
72
+
73
73
Log pruning is called only after checkpoint completion to ensure at least one checkpoint and points to a valid place in the transaction log data.
74
74
In reality, this means that all transaction logs created between checkpoints are kept for some time, and only after a checkpoint, the pruning strategy removes them.
75
-
For more details on how to speed up checkpointing, see <<transaction-logging-log-pruning>>.
75
+
For more details on how to speed up checkpointing, see xref:database-internals/checkpointing.adoc#transaction-logging-log-pruning[Configure log pruning].
76
76
To force a checkpoint, run the procedure xref:reference/procedures.adoc#procedure_db_checkpoint[`CALL db.checkpoint()`].
There are database operations that must be performed in a transaction to ensure the ACID properties.
8
-
Specifically, operations that access the graph, indexes, or schema are such operations.
6
+
Database operations that access the graph, indexes, or schema are performed in a transaction to ensure the ACID properties.
9
7
Transactions are single-threaded, confined, and independent.
10
8
Multiple transactions can be started in a single thread and they are independent of each other.
11
9
@@ -15,17 +13,8 @@ The interaction cycle of working with transactions follows the steps:
15
13
. Perform database operations.
16
14
. Commit or roll back the transaction.
17
15
18
-
[NOTE]
19
-
====
20
-
It is crucial to finish each transaction.
21
-
The locks or memory acquired by a transaction are only released upon completion.
22
-
====
23
-
24
-
The idiomatic use of transactions in Neo4j is to use a `try-with-resources` statement and declare `transaction` as one of the resources.
25
-
Then start the transaction and try to perform graph operations.
26
-
The last operation in the `try` block should commit or roll back the transaction, depending on the business logic.
27
-
In this scenario, `try-with-resources` is used as a guard against unexpected exceptions and as an additional safety mechanism to ensure that the transaction gets closed no matter what happens inside the statement block.
28
-
All non-committed transactions will be rolled back as part of resource cleanup at the end of the statement.
16
+
It is crucial to finish each transaction because the xref:/database-internals/locks-deadlocks.adoc#_locks[locks] or memory acquired by a transaction are only released upon completion.
17
+
All non-committed transactions are rolled back as part of resource cleanup at the end of the statement.
29
18
No resource cleanup is required for a transaction that is explicitly committed or rolled back, and the transaction closure is an empty operation.
30
19
31
20
[NOTE]
@@ -34,13 +23,90 @@ All modifications performed in a transaction are kept in memory.
34
23
This means that very large updates must be split into several transactions to avoid running out of memory.
35
24
====
36
25
26
+
== Configure transactional behavior
27
+
28
+
The transaction settings help you manage the transactions in your database, for example, the transaction timeout, the maximum number of concurrently running transactions, how much time to allow Neo4j to wait for running transactions to complete before allowing initiated database shutdown to continue, and so on.
29
+
For all available settings, see xref:/configuration/configuration-settings.adoc#_transaction_settings[Transaction settings].
30
+
31
+
=== Configure the maximum number of concurrently running transactions
32
+
33
+
By default, Neo4j can run a maximum of 1000 concurrent transactions.
34
+
To change this value, use the xref:configuration/configuration-settings.adoc#config_db.transaction.concurrent.maximum[`db.transaction.concurrent.maximum`] setting.
35
+
If set to `0`, the limit is disabled.
36
+
37
+
[[transaction-management-transaction-timeout]]
38
+
=== Configure transaction timeout
39
+
40
+
It is recommended to configure Neo4j to terminate transactions whose execution time has exceeded the configured timeout.
41
+
42
+
* Set `xref:configuration/configuration-settings.adoc#config_db.transaction.timeout[db.transaction.timeout]` to some positive time interval value (e.g.,`10s`) denoting the default transaction timeout.
43
+
Setting `db.transaction.timeout` to `0` -- which is the default value -- disables the feature.
44
+
45
+
* You can also set this dynamically on each primary server using the procedure `dbms.setConfigValue('db.transaction.timeout','10s')`.
46
+
47
+
.Configure transaction timeout
48
+
====
49
+
Set the timeout to ten seconds.
50
+
[source, parameters]
51
+
----
52
+
db.transaction.timeout=10s
53
+
----
54
+
====
55
+
56
+
Configuring transaction timeout does not affect transactions executed with custom timeouts (e.g., via the Java API or Neo4j Drivers), as the custom timeout overrides the value set for `db.transaction.timeout`.
57
+
Note that the timeout value can only be overridden to a value that is smaller than that configured by `db.transaction.timeout`.
58
+
The _transaction timeout_ feature is also known as the _transaction guard_.
59
+
60
+
61
+
== Manage transactions
62
+
63
+
Transactions can be managed using the Cypher commands `SHOW TRANSACTIONS` and `TERMINATE TRANSACTIONS`.
64
+
The `TERMINATE TRANSACTIONS` command can be combined with multiple `SHOW TRANSACTIONS` and `TERMINATE TRANSACTIONS` commands in the same query.
65
+
66
+
For more information, see link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/transaction-clauses/[Cypher manual -> Transaction commands].
67
+
68
+
// [[transaction-management-list-transactions]]
69
+
// === List all running transactions
70
+
71
+
// To list all running transactions on the current server, use the `SHOW TRANSACTIONS` command.
72
+
73
+
// [NOTE]
74
+
// ====
75
+
// The command `SHOW TRANSACTIONS` returns only the default output.
76
+
// For a full output use `SHOW TRANSACTIONS YIELD *`.
77
+
78
+
// For more information on this command, such as syntax, output fields, filtering, and examples, see the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/transaction-clauses#query-listing-transactions[Cypher manual -> `SHOW TRANSACTIONS` command].
79
+
// ====
80
+
81
+
// A user with the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/administration/access-control/database-administration#access-control-database-administration-transaction[`SHOW TRANSACTION` privilege] can view the currently executing transactions per the privilege grants.
82
+
83
+
// All users may view all of their own currently executing transactions.
84
+
85
+
// === Terminata a transaction
86
+
87
+
// To terminate a transaction, use the `TERMINATE TRANSACTIONS` command.
88
+
89
+
// [[query-management-terminate-queries]]
90
+
// == Terminate queries
91
+
92
+
// Queries are terminated by terminating the transaction on which they are running. This is done using the `TERMINATE TRANSACTIONS transactionIds` command.
93
+
// The `transactionIds` can be found using the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/transaction-clauses#query-listing-transactions[`SHOW TRANSACTIONS` command].
94
+
95
+
// The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/administration/access-control/database-administration#access-control-database-administration-transaction[`TERMINATE TRANSACTION` privilege] determines what transactions can be terminated.
96
+
// However, the xref:authentication-authorization/terminology.adoc#term-current-user[current user] can always terminate all of their own transactions.
97
+
98
+
// *Syntax:*
99
+
100
+
// `TERMINATE TRANSACTIONS transactionIds`
37
101
38
-
[[transactions-isolation]]
39
-
== Isolation levels
102
+
// *Argument:*
40
103
41
-
Transactions in Neo4j use a _read-committed isolation level_, which means they see data as soon as it has been committed but cannot see data in other transactions that have not yet been committed.
42
-
This type of isolation is weaker than serialization but offers significant performance advantages while being sufficient for the overwhelming majority of cases.
104
+
// [options="header"]
105
+
// |===
106
+
// | Name | Type | Description
107
+
// | `transactionIds` | Comma-separated strings | The IDs of all the transactions to be terminated.
108
+
// | `transactionIds` | Single string parameter | The ID of the transaction to be terminated.
109
+
// | `transactionIds` | List parameter | The IDs of all the transactions to be terminated.
110
+
// |===
43
111
44
-
In addition, the Neo4j Java API enables explicit locking of nodes and relationships.
45
-
Using locks allows simulating the effects of higher levels of isolation by obtaining and releasing locks explicitly.
46
-
For example, if a write lock is taken on a common node or relationship, then all transactions are serialized on that lock -- giving the effect of a _serialization isolation level_.
112
+
// For more information on the command, see the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/transaction-clauses#query-terminate-transactions[Cypher manual -> `TERMINATE TRANSACTIONS` command].
Copy file name to clipboardExpand all lines: modules/ROOT/pages/monitoring/index.adoc
+1-9Lines changed: 1 addition & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
[[monitoring]]
2
2
= Monitoring
3
-
:description: This chapter describes the tools that are available for monitoring Neo4j.
3
+
:description: This chapter describes the tools that are available for monitoring Neo4j.
4
4
5
5
Neo4j provides mechanisms for continuous analysis through the output of metrics as well as the inspection and management of currently-executing queries.
6
6
@@ -18,14 +18,6 @@ This chapter describes the following:
0 commit comments