Skip to content

Commit 1b4ce24

Browse files
authored
DRIVERS-1577 Note caveats for killAllSessions (#952)
1 parent b217e4f commit 1b4ce24

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

source/unified-test-format/unified-test-format.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ Unified Test Format
33
===================
44

55
:Spec Title: Unified Test Format
6-
:Spec Version: 1.2.3
6+
:Spec Version: 1.2.4
77
:Author: Jeremy Mikola
88
:Advisors: Prashant Mital, Isabel Atkinson, Thomas Reggi
99
:Status: Accepted
1010
:Type: Standards
1111
:Minimum Server Version: N/A
12-
:Last Modified: 2021-03-24
12+
:Last Modified: 2021-04-08
1313

1414
.. contents::
1515

@@ -2635,22 +2635,34 @@ sections.
26352635
Terminating Open Transactions
26362636
`````````````````````````````
26372637

2638-
Open transactions can cause tests to block indiscriminately. Test runners SHOULD
2639-
terminate all open transactions at the start of a test suite and after each
2640-
failed test by killing all sessions in the cluster. Using the internal
2641-
MongoClient, execute the ``killAllSessions`` command on either the primary or,
2642-
if connected to a sharded cluster, all mongos servers.
2638+
Open transactions can cause tests to block indiscriminately. When connected to
2639+
MongoDB 3.6 or later, test runners SHOULD terminate all open transactions at the
2640+
start of a test suite and after each failed test by killing all sessions in the
2641+
cluster. Using the internal MongoClient, execute the ``killAllSessions`` command
2642+
on either the primary or, if connected to a sharded cluster, all mongos servers.
26432643

26442644
For example::
26452645

26462646
db.adminCommand({
26472647
killAllSessions: []
26482648
});
26492649

2650-
The test runner MAY ignore any command failure with error Interrupted(11601) to
2651-
work around `SERVER-38335`_.
2650+
The test runner MAY ignore the following command failures:
2651+
2652+
- Interrupted(11601) to work around `SERVER-38335`_.
2653+
- Unauthorized(13) to work around `SERVER-54216`_.
2654+
- CommandNotFound(59) if the command is executed on a pre-3.6 server
26522655

26532656
.. _SERVER-38335: https://jira.mongodb.org/browse/SERVER-38335
2657+
.. _SERVER-54216: https://jira.mongodb.org/browse/SERVER-54216
2658+
2659+
Note that Atlas, by design, does not allow database users to kill sessions
2660+
belonging to other users. This makes it impossible to guarantee that an existing
2661+
transaction will not block test execution. To work around this, test runners
2662+
SHOULD either ignore Unauthorized(13) command failures or avoid calling
2663+
``killAllSessions`` altogether when connected to Atlas (e.g. by detecting
2664+
``mongodb.net`` in the hostname or allowing the test runner to be configured
2665+
externally).
26542666

26552667

26562668
StaleDbVersion Errors on Sharded Clusters
@@ -2965,6 +2977,10 @@ spec changes developed in parallel or during the same release cycle.
29652977
Change Log
29662978
==========
29672979

2980+
:2021-04-08: List additional error codes that may be ignored when calling
2981+
``killAllSessions`` and note that the command should not be called
2982+
when connected to Atlas.
2983+
29682984
:2021-03-22: Split ``serverApi`` into its own section. Note types for ``loop``
29692985
operation arguments. Clarify how ``loop`` iterations are counted
29702986
for ``storeIterationsAsEntity``.

0 commit comments

Comments
 (0)