Manage transactions

Configure transaction timeout

It is recommended to configure Neo4j to terminate transactions whose execution time has exceeded the configured timeout.

  • Set dbms.transaction.timeout to some positive time interval value (e.g.,10s) denoting the default transaction timeout. Setting dbms.transaction.timeout to 0 — which is the default value — disables the feature.

  • You can also set this dynamically on each instance (Read Replicas only if required) using the procedure dbms.setConfigValue('dbms.transaction.timeout','10s').

Example 1. Configure transaction timeout

Set the timeout to ten seconds.

dbms.transaction.timeout=10s

Configuring transaction timeout has no effect on transactions executed with custom timeouts (e.g., via the Java API or Neo4j Drivers), as the custom timeout overrides the value set for dbms.transaction.timeout. Note that the timeout value can only be overridden to a value that is smaller than that configured by dbms.transaction.timeout.

The transaction timeout feature is also known as the transaction guard.

Configure lock acquisition timeout

An executing transaction may get stuck while waiting for some lock to be released by another transaction. To kill that transaction and remove the lock, set set dbms.lock.acquisition.timeout to some positive time interval value (e.g., 10s) denoting the maximum time interval within which any particular lock should be acquired, before failing the transaction. Setting dbms.lock.acquisition.timeout to 0 — which is the default value — disables the lock acquisition timeout.

This feature cannot be set dynamically.

Example 2. Configure lock acquisition timeout

Set the timeout to ten seconds.

dbms.lock.acquisition.timeout=10s

List all running transactions

The procedure for viewing transactions, dbms.listTransactions(), is replaced by the command for showing transactions, SHOW TRANSACTIONS. Both the command and procedure returns the transactions that are currently executing within the instance.

The SHOW TRANSACTION privilege determines what transactions are returned by the command. However, the current user can always view all of their own currently executing transactions.

Syntax:

SHOW TRANSACTIONS

For more information on this command, see the Cypher manual → SHOW TRANSACTIONS command.