diff --git a/source/transactions/tests/README.md b/source/transactions/tests/README.md index 8714009ca2..809ee4a05e 100644 --- a/source/transactions/tests/README.md +++ b/source/transactions/tests/README.md @@ -75,8 +75,29 @@ driver, use command monitoring instead. ## PoolClearedError Prose Test -Test that `PoolClearedError` has `TransientTransactionError` label. Since there is no simple way to trigger -`PoolClearedError`, this test should be implemented in a way that suites each driver the best. +### PoolClearedError has TransientTransactionError label when raised while not committing a transaction. + +- Create a MongoClient running against a sharded cluster with a single mongos or a replica set with a single mongod + - transactions require a 4.0+ server when non-sharded and 4.2+ when sharded +- Start a new session on the client. +- Start a transaction on the session. +- Obtain a connection pool for the mongos or mongod. +- Set pool to the paused state. +- Attempt to check out a connection from the pool. +- Ensure that a `PoolClearedError` is raised. +- Ensure that the `PoolClearedError` has the `TransientTransactionError` label. + +### PoolClearedError does not have TransientTransactionError label when raised while committing a transaction. + +- Create a MongoClient running against a sharded cluster with a single mongos or a replica set with a single mongod + - transactions require a 4.0+ server when non-sharded and 4.2+ when sharded +- Start a new session on the client. +- Start a transaction on the session. +- Obtain a connection pool for the mongos or mongod. +- Set pool to the paused state. +- Attempt to commit the transaction. +- Ensure that a `PoolClearedError` is raised. +- Ensure that the `PoolClearedError` does not have the `TransientTransactionError` label. ## Options Inside Transaction Prose Tests. diff --git a/source/transactions/transactions.md b/source/transactions/transactions.md index 1e270cbed0..dc09427685 100644 --- a/source/transactions/transactions.md +++ b/source/transactions/transactions.md @@ -64,8 +64,8 @@ string error labels. Drivers may also add error labels to errors that they retur #### Transient Transaction Error -Any command, network, or driver error that includes the "TransientTransactionError" error label in the "errorLabels" -field. +Any command or network error (including "PoolClearedError") that includes the "TransientTransactionError" error label in +the "errorLabels" field. ### **Naming variations** @@ -688,13 +688,12 @@ string error labels. ### Transient Transaction Error -- Any command error that includes the "TransientTransactionError" error label in the "errorLabels" field. In the case of - command errors, the server adds the label. -- Any network error or server selection error encountered running any command besides commitTransaction in a - transaction. In the case of network errors or server selection errors where the client receives no server reply, the - client MUST add the label. If a network error occurs while running the commitTransaction command then it is not - known whether the transaction committed or not, and thus the "TransientTransactionError" label MUST NOT be added. -- `PoolClearedError`. Driver MUST add the label to this error. +Any command error that includes the "TransientTransactionError" error label in the "errorLabels" field. Any network +error (including "PoolClearedError") or server selection error encountered running any command besides commitTransaction +in a transaction. In the case of command errors, the server adds the label; in the case of network errors or server +selection errors where the client receives no server reply, the client MUST add the label. If a network error occurs +while running the commitTransaction command then it is not known whether the transaction committed or not, and thus the +"TransientTransactionError" label MUST NOT be added. #### Retrying transactions that fail with TransientTransactionError