This page explains the SHOW TRANSACTIONS and TERMINATE TRANSACTIONS commands.
The SHOW TRANSACTIONS command is used to display running transactions within the instance.
This also includes fabric transactions.
For remote database aliases, transactions can be tracked by running SHOW TRANSACTIONS when connected to the remote database alias.
|
Note
|
The command |
This command returns the following outputs:
| Column | Description | Type |
|---|---|---|
|
The name of the database the transaction is executing against. label:default-output[] |
|
|
The transaction ID. label:default-output[] |
|
|
The ID of the query currently executing in this transaction, or |
|
|
The ID of the database connection attached to the transaction or an empty |
|
|
The client address of the connection issuing the transaction or |
|
|
The username of the user executing the transaction. label:default-output[] |
|
|
The query text of the query currently executing in this transaction, or |
|
|
The time at which the transaction was started. label:default-output[] |
|
|
The current status of the transaction ( |
|
|
The time that has elapsed since the transaction was started. label:default-output[] |
|
|
The ID of this transaction’s outer transaction, if such exists, otherwise |
|
|
Any metadata associated with the transaction, or an empty map if there is none. |
|
|
A map containing all the parameters used by the query currently executing in this transaction, or |
|
|
The name of the Cypher planner used to plan the query currently executing in this transaction, or |
|
|
The name of the Cypher runtime used by the query currently executing in this transaction, or |
|
|
The indexes utilized by the query currently executing in this transaction, or |
|
|
The time at which the query currently executing in this transaction was started, or |
|
|
The protocol used by the connection issuing the transaction. This is not necessarily an internet protocol, such as http, etc., although it could be. It might also be "embedded", for example, if this connection represents an embedded session. |
|
|
The request URI used by the client connection issuing the transaction, or |
|
|
The current status of the query currently executing in this transaction ( |
|
|
Provide additional status details from the underlying transaction or an empty |
|
|
Information about any blocked transactions, or an empty map if there is none. |
|
|
Count of active locks held by the transaction. |
|
|
Count of active locks held by the query currently executing in this transaction. |
|
|
CPU time that has been actively spent executing the transaction or |
|
|
Wait time that has been spent waiting to acquire locks. |
|
|
Idle time for this transaction, or |
|
|
The time that has elapsed since the query currently executing in this transaction was started, or |
|
|
CPU time that has been actively spent executing the query currently executing in this transaction, or |
|
|
Wait time that has been spent waiting to acquire locks for the query currently executing in this transaction, or |
|
|
Idle time for the query currently executing in this transaction, or |
|
|
The number of bytes allocated on the heap so far by the query currently executing in this transaction, or |
|
|
Amount of off-heap (native) memory allocated by the transaction in bytes or |
|
|
The estimated amount of used heap memory allocated by the transaction in bytes or |
|
|
The total number of page cache hits that the transaction performed. |
|
|
The total number of page cache faults that the transaction performed. |
|
|
The total number of page cache hits that the query currently executing in this transaction performed. |
|
|
The total number of page cache faults that the query currently executing in this transaction performed. |
|
|
The initialization stacktrace for this transaction, or an empty |
|
The SHOW TRANSACTIONS command can be combined with multiple SHOW TRANSACTIONS and TERMINATE TRANSACTIONS, see transaction commands combination.
|
Note
|
More details about the syntax descriptions can be found here. |
- List transactions on the current server
SHOW TRANSACTION[S] [transaction-id[,...]]
[YIELD { * | field[, ...] } [ORDER BY field[, ...]] [SKIP n] [LIMIT n]]
[WHERE expression]
[RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]]The format of transaction-id is <databaseName>-transaction-<id>.
Transaction IDs must be supplied as one or more comma-separated quoted STRING values, or as an expression resolving to a STRING or a LIST<STRING>.
|
Note
|
When using the |
A user with the SHOW TRANSACTION privilege can view the currently executing transactions in accordance with the privilege grants.
All users may view all of their own currently executing transactions.
To list all available transactions with the default outputs, use the SHOW TRANSACTIONS command.
If all outputs are required, use SHOW TRANSACTIONS YIELD *.
SHOW TRANSACTIONS| database | transactionId | currentQueryId | connectionId | clientAddress | username | currentQuery | startTime | status | elapsedTime |
|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rows: 2 |
|||||||||
The listed transactions can be filtered by using the WHERE clause.
For example, getting the databases for all transactions where the currently executing query contains 'Mark':
SHOW TRANSACTIONS YIELD database, currentQuery WHERE currentQuery contains 'Mark'| database | currentQuery |
|---|---|
|
|
|
|
Rows: 2 |
|
Several of the outputs have the duration type, which can be hard to read.
They can instead be returned in a more readable format:
SHOW TRANSACTIONS
YIELD transactionId, elapsedTime, cpuTime, waitTime, idleTime,
currentQueryElapsedTime, currentQueryCpuTime, currentQueryWaitTime, currentQueryIdleTime
RETURN
transactionId AS txId,
elapsedTime.milliseconds AS elapsedTimeMillis,
cpuTime.milliseconds AS cpuTimeMillis,
waitTime.milliseconds AS waitTimeMillis,
idleTime.seconds AS idleTimeSeconds,
currentQueryElapsedTime.milliseconds AS currentQueryElapsedTimeMillis,
currentQueryCpuTime.milliseconds AS currentQueryCpuTimeMillis,
currentQueryWaitTime.microseconds AS currentQueryWaitTimeMicros,
currentQueryIdleTime.seconds AS currentQueryIdleTimeSeconds| txId | elapsedTimeMillis | cpuTimeMillis | waitTimeMillis | idleTimeSeconds | currentQueryElapsedTimeMillis | currentQueryCpuTimeMillis | currentQueryWaitTimeMicros | currentQueryIdleTimeSeconds |
|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rows: 3 |
||||||||
It is possible to specify which transactions to return in the list by transaction ID.
SHOW TRANSACTIONS "neo4j-transaction-3"| database | transactionId | currentQueryId | connectionId | clientAddress | username | currentQuery | startTime | status | elapsedTime |
|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
Rows: 1 |
|||||||||
The TERMINATE TRANSACTIONS command is used to terminate running transactions by their IDs.
|
Note
|
The outputs for the |
This command returns the following outputs:
| Column | Description | Type |
|---|---|---|
|
The transaction ID. |
|
|
The username of the user executing the transaction. |
|
|
The result of the |
|
The TERMINATE TRANSACTIONS command can be combined with multiple SHOW TRANSACTIONS and TERMINATE TRANSACTIONS, see transaction commands combination.
|
Note
|
More details about the syntax descriptions can be found here. |
- Terminate transactions by ID on the current server
TERMINATE TRANSACTION[S] transaction_id[, ...]
[YIELD { * \| field[, ...] }
[ORDER BY field[, ...]]
[SKIP n]
[LIMIT n]
[WHERE expression]
[RETURN field[, ...] [ORDER BY field[, ...]] [SKIP n] [LIMIT n]]
]The format of transaction-id is <databaseName>-transaction-<id>.
Transaction IDs must be supplied as one or more comma-separated quoted STRING values, or as an expression resolving to a STRING or a LIST<STRING>.
|
Note
|
When using the |
A user with the TERMINATE TRANSACTION privilege can terminate transactions in accordance with the privilege grants.
All users may terminate their own currently executing transactions.
To end running transactions without waiting for them to complete on their own, use the TERMINATE TRANSACTIONS command.
TERMINATE TRANSACTIONS "neo4j-transaction-1","neo4j-transaction-2"| transactionId | username | message |
|---|---|---|
|
|
|
|
|
|
Rows: 2 |
||
The output from the TERMINATE TRANSACTIONS command can be filtered using the YIELD and WHERE clauses.
For example, returning the transaction IDs and message for the transactions that did not terminate.
TERMINATE TRANSACTIONS "neo4j-transaction-1","neo4j-transaction-2"
YIELD transactionId, message
WHERE message <> "Transaction terminated."| transactionId | message |
|---|---|
|
|
Rows: 1 |
|
In difference to SHOW TRANSACTIONS; the TERMINATE TRANSACTIONS does not allow WHERE without YIELD.
TERMINATE TRANSACTIONS "neo4j-transaction-1","neo4j-transaction-2"
WHERE message <> "Transaction terminated."42N84: error: syntax error or access rule violation - TERMINATE TRANSACTION misses YIELD clause. WHERE clause without YIELD clause. Use 'TERMINATE TRANSACTION … YIELD … WHERE …'. |
In difference to other show commands, the SHOW and TERMINATE TRANSACTIONS commands can be combined in the same query.
|
Note
|
When combining multiple commands the |
|
Note
|
At this point in time, no other cypher clauses are allowed to be combined with the transaction commands. |
To terminate all transactions by a user, first find the transactions using SHOW TRANSACTIONS, then pass them onto TERMINATE TRANSACTIONS.
SHOW TRANSACTIONS
YIELD transactionId AS txId, username AS user
WHERE user = "Alice"
TERMINATE TRANSACTIONS txId
YIELD message
RETURN txId, message| txId | message |
|---|---|
|
|
|
|
Rows: 2 |
|
To terminate transactions that have been waiting for more than 30 minutes, first find the transactions using SHOW TRANSACTIONS, then pass them onto TERMINATE TRANSACTIONS.
The following example shows a transaction that has been waiting for 40 minutes.
SHOW TRANSACTIONS
YIELD transactionId, waitTime
WHERE waitTime > duration({minutes: 30})
TERMINATE TRANSACTIONS transactionId
YIELD username, message
RETURN *| transactionId | waitTime | username | message |
|---|---|---|---|
|
|
|
|
Rows: 1 |
|||
To list remaining transactions by users whose transactions were terminated, first terminate the transactions using TERMINATE TRANSACTIONS, then filter users through SHOW TRANSACTIONS.
TERMINATE TRANSACTION 'neo4j-transaction-1', 'neo4j-transaction-2'
YIELD username AS terminatedUser
SHOW TRANSACTIONS
YIELD username AS showUser, transactionId AS txId, database, currentQuery, status
WHERE showUser = terminatedUser AND NOT status STARTS WITH 'Terminated'
RETURN txId, showUser AS user, database, currentQuery| txId | user | database | currentQuery |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Rows: 2 |
|||
To list other transactions by the same user as a given transaction, first find the transactions using SHOW TRANSACTIONS, then filter users through a second SHOW TRANSACTIONS.
SHOW TRANSACTION 'neo4j-transaction-1'
YIELD username AS originalUser, transactionId AS originalTxId
SHOW TRANSACTIONS
YIELD username AS newUser, transactionId AS txId, database, currentQuery, status
WHERE newUser = originalUser AND NOT txId = originalTxId
RETURN txId, newUser AS user, database, currentQuery, status| txId | user | database | currentQuery | status |
|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
Rows: 2 |
||||