From 76b196f575974c4a02a61c288f92e965ea158a99 Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Wed, 7 Oct 2026 09:23:02 +0200 Subject: [PATCH 1/5] docs: SHOW SESSIONS and TERMINATE SESSIONS Documents the session management queries from memgraph/memgraph#4577: listing open Bolt sessions and terminating them from another connection, who can see and terminate which sessions, the result columns, and the SESSIONS reserved keyword. Adds both queries to the query privileges table. Co-Authored-By: Claude Opus 5.5 --- .../query-privileges.mdx | 2 + pages/fundamentals/transactions.mdx | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/pages/database-management/authentication-and-authorization/query-privileges.mdx b/pages/database-management/authentication-and-authorization/query-privileges.mdx index 053000261..d4c6ad40b 100644 --- a/pages/database-management/authentication-and-authorization/query-privileges.mdx +++ b/pages/database-management/authentication-and-authorization/query-privileges.mdx @@ -147,6 +147,8 @@ Memgraph's privilege system controls access to various database operations throu | `SHOW TRANSACTIONS` | `TRANSACTION_MANAGEMENT` | `SHOW TRANSACTIONS` | | `TERMINATE TRANSACTIONS` | `TRANSACTION_MANAGEMENT` | `TERMINATE TRANSACTIONS 'transaction_id'` | | `TERMINATE TRANSACTIONS "*"` | `TRANSACTION_MANAGEMENT` | `TERMINATE TRANSACTIONS "*"` terminates every transaction the user may terminate. Without the privilege, only the user's own transactions are terminated. | +| `SHOW SESSIONS` | `TRANSACTION_MANAGEMENT` | `SHOW SESSIONS` lists sessions on the databases where the user has the privilege. Without it, only the user's own sessions are listed. | +| `TERMINATE SESSIONS` | `TRANSACTION_MANAGEMENT` | `TERMINATE SESSIONS 'session_id'` terminates another user's session. Without the privilege, a user can terminate only their own other sessions. | | `RELOAD BOLT_SERVER TLS` | `RELOAD_TLS` | `RELOAD BOLT_SERVER TLS` | | `RELOAD INTRA_CLUSTER TLS` | `RELOAD_TLS` | `RELOAD INTRA_CLUSTER TLS` | diff --git a/pages/fundamentals/transactions.mdx b/pages/fundamentals/transactions.mdx index 98c93a0dd..dd4396e1f 100644 --- a/pages/fundamentals/transactions.mdx +++ b/pages/fundamentals/transactions.mdx @@ -439,6 +439,69 @@ Client received exception: Transactions was asked to abort either because it was specified or another user asked to abort it. ``` +## Manage sessions + +A session is one client connection to Memgraph over Bolt. You can list the +open sessions and close any of them from another connection, for example an +idle connection that keeps a database in use and stops a [forced `DROP +DATABASE`](/database-management/multi-tenancy#drop-database-with-force) from +finishing. Available since Memgraph 3.14. + +Session queries run as implicit transactions only; running them inside an +explicit transaction raises an error. `SESSIONS` is a reserved keyword, so if +you use it as a name (a label, property or variable), write it in backticks: +`` `sessions` ``. + +### Show sessions + +To list the open sessions, run: + +```cypher +SHOW SESSIONS; +``` + +Each row is one session that has finished logging in: + +| Column | Type | Description | +|---|---|---| +| `session_id` | `String` | Unique id of the session. Use this value with `TERMINATE SESSIONS`. | +| `username` | `String` | The user the session is logged in as. | +| `database` | `String` | The database the session is using, or `""` if it isn't using one. | +| `login_timestamp` | `String` | When the session logged in. | + +You see your own sessions, and the sessions on every database where you have +the `TRANSACTION_MANAGEMENT` privilege. A session that isn't using a +database counts as using the default database, `memgraph`. + +### Terminate sessions + +To close one or more sessions, run the following query from another +connection: + +```plaintext +TERMINATE SESSIONS 'SESSION_ID' [, 'SESSION_ID' ...]; +``` + +`SESSION_ID` is a `session_id` from `SHOW SESSIONS`. It must be a string; +any other value raises the error `Session id must be a string.` + +Memgraph closes each session's connection, whether it is idle or running a +query. A running query is aborted. A transaction that is already committing +isn't interrupted; it completes. + +You can terminate your own other sessions without any privilege. To terminate +another user's session, you need the `TRANSACTION_MANAGEMENT` privilege on +the database that session is using (the default database, `memgraph`, if it +isn't using one). The session that runs `TERMINATE SESSIONS` can't terminate +itself. + +The result has two columns, `session_id` and `killed`, with one row per id in +the query, in the same order. A row reports `killed: true` only if the +session was found and you were allowed to close it. An id that matches no +session, an id you're not allowed to terminate, the id of the session running +the query, and every repeat of an id already in the list all report +`killed: false`. + ## Isolation levels In database systems, isolation determines how transaction integrity is visible From 54ce8128d41a6f879eb4105650bd7f1b55e9990c Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Wed, 7 Oct 2026 13:48:38 +0200 Subject: [PATCH 2/5] docs: apply review on SHOW/TERMINATE SESSIONS Also fix the TERMINATE TRANSACTIONS parameter claim and add the database column of SHOW TRANSACTIONS. --- .../query-privileges.mdx | 4 +- pages/fundamentals/transactions.mdx | 116 ++++++++++++++---- 2 files changed, 93 insertions(+), 27 deletions(-) diff --git a/pages/database-management/authentication-and-authorization/query-privileges.mdx b/pages/database-management/authentication-and-authorization/query-privileges.mdx index d4c6ad40b..ba4e5a48a 100644 --- a/pages/database-management/authentication-and-authorization/query-privileges.mdx +++ b/pages/database-management/authentication-and-authorization/query-privileges.mdx @@ -147,8 +147,8 @@ Memgraph's privilege system controls access to various database operations throu | `SHOW TRANSACTIONS` | `TRANSACTION_MANAGEMENT` | `SHOW TRANSACTIONS` | | `TERMINATE TRANSACTIONS` | `TRANSACTION_MANAGEMENT` | `TERMINATE TRANSACTIONS 'transaction_id'` | | `TERMINATE TRANSACTIONS "*"` | `TRANSACTION_MANAGEMENT` | `TERMINATE TRANSACTIONS "*"` terminates every transaction the user may terminate. Without the privilege, only the user's own transactions are terminated. | -| `SHOW SESSIONS` | `TRANSACTION_MANAGEMENT` | `SHOW SESSIONS` lists sessions on the databases where the user has the privilege. Without it, only the user's own sessions are listed. | -| `TERMINATE SESSIONS` | `TRANSACTION_MANAGEMENT` | `TERMINATE SESSIONS 'session_id'` terminates another user's session. Without the privilege, a user can terminate only their own other sessions. | +| `SHOW SESSIONS` | **None** | `SHOW SESSIONS` lists the user's own sessions. With `TRANSACTION_MANAGEMENT`, it also lists other users' sessions on the databases where the user has the privilege. | +| `TERMINATE SESSIONS` | **None** | `TERMINATE SESSIONS 'session_id'` terminates the user's own other sessions. Terminating another user's session needs `TRANSACTION_MANAGEMENT` on the database that session is using. | | `RELOAD BOLT_SERVER TLS` | `RELOAD_TLS` | `RELOAD BOLT_SERVER TLS` | | `RELOAD INTRA_CLUSTER TLS` | `RELOAD_TLS` | `RELOAD INTRA_CLUSTER TLS` | diff --git a/pages/fundamentals/transactions.mdx b/pages/fundamentals/transactions.mdx index dd4396e1f..2df862ab6 100644 --- a/pages/fundamentals/transactions.mdx +++ b/pages/fundamentals/transactions.mdx @@ -92,7 +92,7 @@ SHOW TRANSACTIONS; ``` Each row in the result represents one transaction (or an in-progress snapshot -creation or garbage collection) and contains seven columns: +creation or garbage collection) and contains eight columns: | Column | Type | Description | |---|---|---| @@ -103,6 +103,7 @@ creation or garbage collection) and contains seven columns: | `metadata` | `Map` | Metadata supplied by the client when the transaction was opened. For in-progress snapshots and garbage collection it contains progress details (see below). | | `start_time` | `ZonedDateTime` | UTC time at which the transaction started. | | `elapsed_ms` | `Integer` | How long the transaction has been running, in milliseconds. | +| `database` | `String` | The database the transaction is running on. | ```copy=false memgraph> SHOW TRANSACTIONS; @@ -337,8 +338,8 @@ following the same rules as the id list form: The wildcard must be the only argument. Mixing it with ids, such as `TERMINATE TRANSACTIONS "*", "9223372036854794885"`, raises an error. -A parameterized id is treated exactly like a literal one, so running -`TERMINATE TRANSACTIONS $id` with `$id = "*"` also terminates everything. +Transaction ids, including `"*"`, must be string literals. Query parameters +such as `$id` aren't supported and cause a syntax error. System transactions (for example an in-flight `CREATE DATABASE` or `GRANT`) are @@ -443,14 +444,16 @@ specified or another user asked to abort it. A session is one client connection to Memgraph over Bolt. You can list the open sessions and close any of them from another connection, for example an -idle connection that keeps a database in use and stops a [forced `DROP -DATABASE`](/database-management/multi-tenancy#drop-database-with-force) from -finishing. Available since Memgraph 3.14. +idle (often pooled) connection that still has a database selected and makes +[`DROP DATABASE`](/database-management/multi-tenancy#drop-database-with-force) +fail with `Cannot delete , it is currently being used.` Available since +Memgraph 3.14. -Session queries run as implicit transactions only; running them inside an -explicit transaction raises an error. `SESSIONS` is a reserved keyword, so if -you use it as a name (a label, property or variable), write it in backticks: -`` `sessions` ``. +Session queries run on data instances (MAIN and REPLICA), and each instance +lists and closes only the sessions connected to it. On a high availability +coordinator they fail with `Coordinator can run only coordinator queries!`. +They run as implicit transactions only; running them inside an explicit +transaction raises an error. ### Show sessions @@ -460,18 +463,41 @@ To list the open sessions, run: SHOW SESSIONS; ``` -Each row is one session that has finished logging in: +Each row is one session that is currently logged in. A connection that hasn't +logged in yet, or that has logged off, isn't listed. After it logs on again it +reappears with the same `session_id`: | Column | Type | Description | |---|---|---| | `session_id` | `String` | Unique id of the session. Use this value with `TERMINATE SESSIONS`. | -| `username` | `String` | The user the session is logged in as. | +| `username` | `String` | The user the session logged in as, or `""` if authentication is disabled. With impersonation, this is still the login user. | | `database` | `String` | The database the session is using, or `""` if it isn't using one. | -| `login_timestamp` | `String` | When the session logged in. | +| `login_timestamp` | `String` | UTC time of the session's most recent login, formatted as `YYYY-MM-DD HH:MM:SS.ffffff` (no time zone suffix). | You see your own sessions, and the sessions on every database where you have the `TRANSACTION_MANAGEMENT` privilege. A session that isn't using a -database counts as using the default database, `memgraph`. +database counts as using the default database, `memgraph`. When +authentication is disabled, every connection counts as the same user, so you +see all sessions. With [user +impersonation](/database-management/authentication-and-authorization/impersonate-user), +a connection counts as the impersonated user, and its queries are checked +against that user's privileges. + +In the following example, `admin` has `TRANSACTION_MANAGEMENT` on every +database, and `alice` has two idle connections open, one on `analytics` and +one on `memgraph`. The session running the query is listed too: + +```copy=false +memgraph> SHOW SESSIONS; ++----------------------------------------+----------+-------------+------------------------------+ +| session_id | username | database | login_timestamp | ++----------------------------------------+----------+-------------+------------------------------+ +| "eba078f8-2c56-4e22-bf47-4545ac9d4b1a" | "admin" | "memgraph" | "2026-10-07 10:30:33.022574" | +| "e9e40294-db31-4122-9875-75affefc1130" | "alice" | "memgraph" | "2026-10-07 10:30:32.391885" | +| "f9892d9b-ca91-4e16-b3df-1ead198cc846" | "alice" | "analytics" | "2026-10-07 10:30:32.228485" | ++----------------------------------------+----------+-------------+------------------------------+ +3 rows in set (round trip in 0.001 sec) +``` ### Terminate sessions @@ -482,12 +508,27 @@ connection: TERMINATE SESSIONS 'SESSION_ID' [, 'SESSION_ID' ...]; ``` -`SESSION_ID` is a `session_id` from `SHOW SESSIONS`. It must be a string; -any other value raises the error `Session id must be a string.` - -Memgraph closes each session's connection, whether it is idle or running a -query. A running query is aborted. A transaction that is already committing -isn't interrupted; it completes. +`SESSION_ID` is a `session_id` from `SHOW SESSIONS`, written as a string +literal. Query parameters such as `$id` aren't supported and cause a syntax +error. Any other literal value raises the error `Session id must be a string.` + +An idle session is closed immediately. For a session that is running a query, +Memgraph aborts its transaction and closes the connection as soon as that +query returns. Most queries stop right away, but one that doesn't check for +termination (for example, a long-running function call) runs until it +finishes, and its transaction is then not committed. If the session has an +open explicit transaction (it ran `BEGIN` but hasn't committed), that +transaction is rolled back: its uncommitted changes are discarded and any +writes it holds are released, so conflicting transactions can proceed. A +transaction that is already committing isn't interrupted; it completes. + +The client of a terminated session loses its connection. A query it is +running fails with the transient error `Transaction was asked to abort by +another user.` An idle client gets a connection error on its next request. +Because the error is transient, driver retry helpers (for example, the Python +driver's `execute_write`) retry the transaction on a new connection, and the +retry can commit, so terminating a session doesn't stop an application that +uses them from running the same work again. You can terminate your own other sessions without any privilege. To terminate another user's session, you need the `TRANSACTION_MANAGEMENT` privilege on @@ -495,12 +536,37 @@ the database that session is using (the default database, `memgraph`, if it isn't using one). The session that runs `TERMINATE SESSIONS` can't terminate itself. + +These privilege checks apply only in Memgraph Enterprise. In Memgraph +Community, every user has all privileges, so any user can see and terminate +any other user's session. + + The result has two columns, `session_id` and `killed`, with one row per id in -the query, in the same order. A row reports `killed: true` only if the -session was found and you were allowed to close it. An id that matches no -session, an id you're not allowed to terminate, the id of the session running -the query, and every repeat of an id already in the list all report -`killed: false`. +the query, in the same order. A row reports `killed: true` if the session was +found and you were allowed to close it. This means the close was requested: a +session that is busy with a query can still appear in `SHOW SESSIONS` until +that query returns. An id that matches no session, an id you're not allowed to +terminate, the id of the session running the query, and every repeat of an id +already in the list all report `killed: false`. + +For example, to close alice's `analytics` session (the second id doesn't +match any session): + +```cypher +TERMINATE SESSIONS 'f9892d9b-ca91-4e16-b3df-1ead198cc846', '00000000-0000-0000-0000-000000000000'; +``` + +```copy=false +memgraph> TERMINATE SESSIONS 'f9892d9b-ca91-4e16-b3df-1ead198cc846', '00000000-0000-0000-0000-000000000000'; ++----------------------------------------+--------+ +| session_id | killed | ++----------------------------------------+--------+ +| "f9892d9b-ca91-4e16-b3df-1ead198cc846" | true | +| "00000000-0000-0000-0000-000000000000" | false | ++----------------------------------------+--------+ +2 rows in set (round trip in 0.001 sec) +``` ## Isolation levels From 48479da128f606c2334e2c659244c4d1034ee475 Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Mon, 12 Oct 2026 13:48:54 +0200 Subject: [PATCH 3/5] docs: apply review on session wording and termination behavior --- .../query-privileges.mdx | 4 +- pages/fundamentals/transactions.mdx | 77 +++++++++++-------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/pages/database-management/authentication-and-authorization/query-privileges.mdx b/pages/database-management/authentication-and-authorization/query-privileges.mdx index ba4e5a48a..6331efc61 100644 --- a/pages/database-management/authentication-and-authorization/query-privileges.mdx +++ b/pages/database-management/authentication-and-authorization/query-privileges.mdx @@ -147,8 +147,8 @@ Memgraph's privilege system controls access to various database operations throu | `SHOW TRANSACTIONS` | `TRANSACTION_MANAGEMENT` | `SHOW TRANSACTIONS` | | `TERMINATE TRANSACTIONS` | `TRANSACTION_MANAGEMENT` | `TERMINATE TRANSACTIONS 'transaction_id'` | | `TERMINATE TRANSACTIONS "*"` | `TRANSACTION_MANAGEMENT` | `TERMINATE TRANSACTIONS "*"` terminates every transaction the user may terminate. Without the privilege, only the user's own transactions are terminated. | -| `SHOW SESSIONS` | **None** | `SHOW SESSIONS` lists the user's own sessions. With `TRANSACTION_MANAGEMENT`, it also lists other users' sessions on the databases where the user has the privilege. | -| `TERMINATE SESSIONS` | **None** | `TERMINATE SESSIONS 'session_id'` terminates the user's own other sessions. Terminating another user's session needs `TRANSACTION_MANAGEMENT` on the database that session is using. | +| `SHOW SESSIONS` | **None** | `SHOW SESSIONS` lists the user's own sessions. With the `TRANSACTION_MANAGEMENT` privilege, it also lists other users' sessions on the databases where the user has the privilege. | +| `TERMINATE SESSIONS` | **None** | `TERMINATE SESSIONS 'session_id'` terminates the user's own other sessions. Terminating another user's session needs the `TRANSACTION_MANAGEMENT` privilege on the database that session is using. | | `RELOAD BOLT_SERVER TLS` | `RELOAD_TLS` | `RELOAD BOLT_SERVER TLS` | | `RELOAD INTRA_CLUSTER TLS` | `RELOAD_TLS` | `RELOAD INTRA_CLUSTER TLS` | diff --git a/pages/fundamentals/transactions.mdx b/pages/fundamentals/transactions.mdx index 2df862ab6..551fe8742 100644 --- a/pages/fundamentals/transactions.mdx +++ b/pages/fundamentals/transactions.mdx @@ -446,14 +446,15 @@ A session is one client connection to Memgraph over Bolt. You can list the open sessions and close any of them from another connection, for example an idle (often pooled) connection that still has a database selected and makes [`DROP DATABASE`](/database-management/multi-tenancy#drop-database-with-force) -fail with `Cannot delete , it is currently being used.` Available since -Memgraph 3.14. +query fail with the `Cannot delete , it is currently being used.` error. +Available since Memgraph 3.14. Session queries run on data instances (MAIN and REPLICA), and each instance lists and closes only the sessions connected to it. On a high availability -coordinator they fail with `Coordinator can run only coordinator queries!`. -They run as implicit transactions only; running them inside an explicit -transaction raises an error. +coordinator they fail with the `Coordinator can run only coordinator queries!` +error. Run them on their own, not inside an [explicit +transaction](#explicit-transactions) (one you start with `BEGIN`), where they +raise an error. ### Show sessions @@ -469,13 +470,13 @@ reappears with the same `session_id`: | Column | Type | Description | |---|---|---| -| `session_id` | `String` | Unique id of the session. Use this value with `TERMINATE SESSIONS`. | +| `session_id` | `String` | Unique id of the session. Use this value with the `TERMINATE SESSIONS` query to close the session. | | `username` | `String` | The user the session logged in as, or `""` if authentication is disabled. With impersonation, this is still the login user. | | `database` | `String` | The database the session is using, or `""` if it isn't using one. | | `login_timestamp` | `String` | UTC time of the session's most recent login, formatted as `YYYY-MM-DD HH:MM:SS.ffffff` (no time zone suffix). | -You see your own sessions, and the sessions on every database where you have -the `TRANSACTION_MANAGEMENT` privilege. A session that isn't using a +The `SHOW SESSIONS` query shows your own sessions, and the sessions on every +database where you have the `TRANSACTION_MANAGEMENT` privilege. A session that isn't using a database counts as using the default database, `memgraph`. When authentication is disabled, every connection counts as the same user, so you see all sessions. With [user @@ -483,9 +484,10 @@ impersonation](/database-management/authentication-and-authorization/impersonate a connection counts as the impersonated user, and its queries are checked against that user's privileges. -In the following example, `admin` has `TRANSACTION_MANAGEMENT` on every -database, and `alice` has two idle connections open, one on `analytics` and -one on `memgraph`. The session running the query is listed too: +In the following example, `admin` has the `TRANSACTION_MANAGEMENT` privilege +on every database, and `alice` has two idle connections open, one on the +`analytics` database and one on the `memgraph` database. The session running +the query is listed too: ```copy=false memgraph> SHOW SESSIONS; @@ -508,33 +510,16 @@ connection: TERMINATE SESSIONS 'SESSION_ID' [, 'SESSION_ID' ...]; ``` -`SESSION_ID` is a `session_id` from `SHOW SESSIONS`, written as a string -literal. Query parameters such as `$id` aren't supported and cause a syntax -error. Any other literal value raises the error `Session id must be a string.` - -An idle session is closed immediately. For a session that is running a query, -Memgraph aborts its transaction and closes the connection as soon as that -query returns. Most queries stop right away, but one that doesn't check for -termination (for example, a long-running function call) runs until it -finishes, and its transaction is then not committed. If the session has an -open explicit transaction (it ran `BEGIN` but hasn't committed), that -transaction is rolled back: its uncommitted changes are discarded and any -writes it holds are released, so conflicting transactions can proceed. A -transaction that is already committing isn't interrupted; it completes. - -The client of a terminated session loses its connection. A query it is -running fails with the transient error `Transaction was asked to abort by -another user.` An idle client gets a connection error on its next request. -Because the error is transient, driver retry helpers (for example, the Python -driver's `execute_write`) retry the transaction on a new connection, and the -retry can commit, so terminating a session doesn't stop an application that -uses them from running the same work again. +`SESSION_ID` is a `session_id` from the `SHOW SESSIONS` output, written as a +string literal. Query parameters such as `$id` aren't supported and cause a +syntax error. Any other literal value raises the `Session id must be a +string.` error. You can terminate your own other sessions without any privilege. To terminate another user's session, you need the `TRANSACTION_MANAGEMENT` privilege on the database that session is using (the default database, `memgraph`, if it -isn't using one). The session that runs `TERMINATE SESSIONS` can't terminate -itself. +isn't using one). The session that runs the `TERMINATE SESSIONS` query can't +terminate itself. These privilege checks apply only in Memgraph Enterprise. In Memgraph @@ -568,6 +553,30 @@ memgraph> TERMINATE SESSIONS 'f9892d9b-ca91-4e16-b3df-1ead198cc846', '00000000-0 2 rows in set (round trip in 0.001 sec) ``` +What happens to a terminated session depends on what it's doing: + +- **Idle:** Memgraph closes the session immediately. +- **Running a query:** Memgraph aborts the query's transaction and closes the + session as soon as the query returns. Most queries stop right away. A query + that doesn't check for termination, such as a long-running function call, + runs until it finishes, and its transaction isn't committed. +- **In an open explicit transaction** (it ran `BEGIN` and hasn't committed): + Memgraph rolls the transaction back. Its uncommitted changes are discarded + and the writes it holds are released, so conflicting transactions can + continue. +- **Committing:** the commit isn't interrupted; it completes. + +The client of a terminated session loses its connection: + +- **A query it's running** fails with the transient `Transaction was asked to + abort by another user.` error. +- **An idle client** gets a connection error on its next request. + +Because the error is transient, driver retry helpers (for example, the Python +driver's `execute_write`) retry the transaction on a new connection, and the +retry can commit. Terminating a session doesn't stop an application that +uses retry helpers from running the same work again. + ## Isolation levels In database systems, isolation determines how transaction integrity is visible From 3e1c75095ed01d0cf7d6fe819021cba5c9e704bd Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Mon, 12 Oct 2026 14:14:24 +0200 Subject: [PATCH 4/5] docs: real SHOW TRANSACTIONS output, FORCE note, pooled clients --- pages/fundamentals/transactions.mdx | 47 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/pages/fundamentals/transactions.mdx b/pages/fundamentals/transactions.mdx index 551fe8742..a20f1d7f2 100644 --- a/pages/fundamentals/transactions.mdx +++ b/pages/fundamentals/transactions.mdx @@ -105,14 +105,13 @@ creation or garbage collection) and contains eight columns: | `elapsed_ms` | `Integer` | How long the transaction has been running, in milliseconds. | | `database` | `String` | The database the transaction is running on. | -```copy=false -memgraph> SHOW TRANSACTIONS; -+----------+-----------------------+-----------------------------------------------+--------------+----------+-------------------------------+------------+ -| username | transaction_id | query | status | metadata | start_time | elapsed_ms | -+----------+-----------------------+-----------------------------------------------+--------------+----------+-------------------------------+------------+ -| "" | "9223372036854794885" | ["UNWIND range(1,100) AS i CREATE(:L{p:i});"] | "committing" | {} | 2026-05-12T14:32:18.412Z[UTC] | 47 | -| "" | "9223372036854794896" | ["SHOW TRANSACTIONS"] | "running" | {} | 2026-05-12T14:32:18.451Z[UTC] | 8 | -+----------+-----------------------+-----------------------------------------------+--------------+----------+-------------------------------+------------+ +```plaintext copy=false ++----------+-----------------------+------------------------------------------------------+-----------+----------+----------------------------------------+------------+------------+ +| username | transaction_id | query | status | metadata | start_time | elapsed_ms | database | ++----------+-----------------------+------------------------------------------------------+-----------+----------+----------------------------------------+------------+------------+ +| "" | "9223372036854775816" | ["SHOW TRANSACTIONS"] | "running" | {} | 2026-10-12 12:13:47.209533000[Etc/UTC] | 0 | "memgraph" | +| "" | "9223372036854775815" | ["UNWIND range(1, 100) AS i CREATE (:Item {id: i})"] | "running" | {} | 2026-10-12 12:13:47.116640000[Etc/UTC] | 93 | "memgraph" | ++----------+-----------------------+------------------------------------------------------+-----------+----------+----------------------------------------+------------+------------+ ``` #### Filter by status @@ -148,13 +147,14 @@ rows contains: The top-level `start_time` and `elapsed_ms` columns are populated for snapshot rows as well, reflecting when the snapshot started. -```copy=false -memgraph> SHOW TRANSACTIONS; -+----------+----------------+---------------------+-----------+------------------------------------------------------------------+-------------------------------+------------+ -| username | transaction_id | query | status | metadata | start_time | elapsed_ms | -+----------+----------------+---------------------+-----------+------------------------------------------------------------------+-------------------------------+------------+ -| "" | "snapshot" | ["CREATE SNAPSHOT"] | "running" | {phase: "VERTICES", items_done: 142000, items_total: 500000, ... | 2026-05-12T14:32:17.205Z[UTC] | 1247 | -+----------+----------------+---------------------+-----------+------------------------------------------------------------------+-------------------------------+------------+ +```plaintext copy=false ++----------+-----------------------+-----------------------+-----------+-----------------------------------------------------------------------------------+----------------------------------------+------------+------------+ +| username | transaction_id | query | status | metadata | start_time | elapsed_ms | database | ++----------+-----------------------+-----------------------+-----------+-----------------------------------------------------------------------------------+----------------------------------------+------------+------------+ +| "" | "9223372036854775818" | ["SHOW TRANSACTIONS"] | "running" | {} | 2026-10-12 12:13:47.275859000[Etc/UTC] | 0 | "memgraph" | +| "" | "9223372036854775817" | ["CREATE SNAPSHOT"] | "running" | {} | 2026-10-12 12:13:47.221765000[Etc/UTC] | 54 | "memgraph" | +| "" | "snapshot" | ["CREATE SNAPSHOT"] | "running" | {db_name: "memgraph", items_done: 53824, items_total: 3000100, phase: "vertices"} | 2026-10-12 12:13:47.221848000[Etc/UTC] | 55 | "memgraph" | ++----------+-----------------------+-----------------------+-----------+-----------------------------------------------------------------------------------+----------------------------------------+------------+------------+ ``` @@ -444,9 +444,10 @@ specified or another user asked to abort it. A session is one client connection to Memgraph over Bolt. You can list the open sessions and close any of them from another connection, for example an -idle (often pooled) connection that still has a database selected and makes +idle (often pooled) connection that still has a database selected and makes a [`DROP DATABASE`](/database-management/multi-tenancy#drop-database-with-force) -query fail with the `Cannot delete , it is currently being used.` error. +query without `FORCE` fail with the `Cannot delete , it is currently +being used.` error. With `FORCE`, Memgraph closes such sessions itself. Available since Memgraph 3.14. Session queries run on data instances (MAIN and REPLICA), and each instance @@ -489,8 +490,7 @@ on every database, and `alice` has two idle connections open, one on the `analytics` database and one on the `memgraph` database. The session running the query is listed too: -```copy=false -memgraph> SHOW SESSIONS; +```plaintext copy=false +----------------------------------------+----------+-------------+------------------------------+ | session_id | username | database | login_timestamp | +----------------------------------------+----------+-------------+------------------------------+ @@ -498,7 +498,6 @@ memgraph> SHOW SESSIONS; | "e9e40294-db31-4122-9875-75affefc1130" | "alice" | "memgraph" | "2026-10-07 10:30:32.391885" | | "f9892d9b-ca91-4e16-b3df-1ead198cc846" | "alice" | "analytics" | "2026-10-07 10:30:32.228485" | +----------------------------------------+----------+-------------+------------------------------+ -3 rows in set (round trip in 0.001 sec) ``` ### Terminate sessions @@ -542,15 +541,13 @@ match any session): TERMINATE SESSIONS 'f9892d9b-ca91-4e16-b3df-1ead198cc846', '00000000-0000-0000-0000-000000000000'; ``` -```copy=false -memgraph> TERMINATE SESSIONS 'f9892d9b-ca91-4e16-b3df-1ead198cc846', '00000000-0000-0000-0000-000000000000'; +```plaintext copy=false +----------------------------------------+--------+ | session_id | killed | +----------------------------------------+--------+ | "f9892d9b-ca91-4e16-b3df-1ead198cc846" | true | | "00000000-0000-0000-0000-000000000000" | false | +----------------------------------------+--------+ -2 rows in set (round trip in 0.001 sec) ``` What happens to a terminated session depends on what it's doing: @@ -570,7 +567,9 @@ The client of a terminated session loses its connection: - **A query it's running** fails with the transient `Transaction was asked to abort by another user.` error. -- **An idle client** gets a connection error on its next request. +- **An idle client** gets a connection error on its next request. A driver + with a connection pool opens a new connection instead, so the request + succeeds. Because the error is transient, driver retry helpers (for example, the Python driver's `execute_write`) retry the transaction on a new connection, and the From 2268553aa4f3a1e75af0b64fc9777e0077855940 Mon Sep 17 00:00:00 2001 From: Vlasta <95473291+vpavicic@users.noreply.github.com> Date: Tue, 20 Oct 2026 13:37:50 +0200 Subject: [PATCH 5/5] Apply batched suggestions from code review Co-authored-by: andrejtonev <29177572+andrejtonev@users.noreply.github.com> --- pages/fundamentals/transactions.mdx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pages/fundamentals/transactions.mdx b/pages/fundamentals/transactions.mdx index a20f1d7f2..06427c2b6 100644 --- a/pages/fundamentals/transactions.mdx +++ b/pages/fundamentals/transactions.mdx @@ -103,7 +103,7 @@ creation or garbage collection) and contains eight columns: | `metadata` | `Map` | Metadata supplied by the client when the transaction was opened. For in-progress snapshots and garbage collection it contains progress details (see below). | | `start_time` | `ZonedDateTime` | UTC time at which the transaction started. | | `elapsed_ms` | `Integer` | How long the transaction has been running, in milliseconds. | -| `database` | `String` | The database the transaction is running on. | +| `database` | `String` | The database the listed transaction is running on, not the database of the session that runs `SHOW TRANSACTIONS`. In Memgraph Community it's always `memgraph`. | ```plaintext copy=false +----------+-----------------------+------------------------------------------------------+-----------+----------+----------------------------------------+------------+------------+ @@ -467,13 +467,14 @@ SHOW SESSIONS; Each row is one session that is currently logged in. A connection that hasn't logged in yet, or that has logged off, isn't listed. After it logs on again it -reappears with the same `session_id`: +reappears with the same `session_id`. If another user logs on, the row shows +that user and the database of the new login: | Column | Type | Description | |---|---|---| | `session_id` | `String` | Unique id of the session. Use this value with the `TERMINATE SESSIONS` query to close the session. | -| `username` | `String` | The user the session logged in as, or `""` if authentication is disabled. With impersonation, this is still the login user. | -| `database` | `String` | The database the session is using, or `""` if it isn't using one. | +| `username` | `String` | The user the session logged in as, or `""` for a session that logged in while authentication was disabled. With impersonation, this is still the login user. | +| `database` | `String` | The database the session is using: the one selected with `USE DATABASE`, the one named when connecting, or otherwise the user's main database (`memgraph` by default). `""` if the session has no database, for example after its database was dropped. | | `login_timestamp` | `String` | UTC time of the session's most recent login, formatted as `YYYY-MM-DD HH:MM:SS.ffffff` (no time zone suffix). | The `SHOW SESSIONS` query shows your own sessions, and the sessions on every @@ -566,10 +567,13 @@ What happens to a terminated session depends on what it's doing: The client of a terminated session loses its connection: - **A query it's running** fails with the transient `Transaction was asked to - abort by another user.` error. -- **An idle client** gets a connection error on its next request. A driver - with a connection pool opens a new connection instead, so the request - succeeds. + abort by another user.` error. A query that doesn't check for termination + fails when it finishes, with the transient `Aborting transaction commit + because the transaction was requested to stop from other session.` error. +- **An idle client** gets a connection error on its next request, and the + driver opens a new connection for the request after that. Driver retry + helpers (for example, the Python driver's `execute_read`) retry on that + error, so their request succeeds. Because the error is transient, driver retry helpers (for example, the Python driver's `execute_write`) retry the transaction on a new connection, and the