@@ -3,7 +3,7 @@ Driver Transactions Specification
3
3
=================================
4
4
5
5
:Spec Title: Driver Transactions Specification
6
- :Spec Version: 1.5.5
6
+ :Spec Version: 1.5.6
7
7
:Author: Shane Harvey
8
8
:Spec Lead: A\. Jesse Jiryu Davis
9
9
:Advisory Group: A\. Jesse Jiryu Davis, Matt Broadstone, Robert Stam, Jeff Yemin, Spencer Brody
@@ -810,26 +810,32 @@ certain retries of commitTransaction and abortTransaction) to the same mongos.
810
810
When to unpin
811
811
^^^^^^^^^^^^^
812
812
813
- Drivers MUST unpin a ClientSession when a command within a transaction,
814
- including commitTransaction and abortTransaction, fails with a
815
- TransientTransactionError. Transient errors indicate that the transaction
816
- in question has already been aborted or that the pinned mongos is
817
- down/unavailable. Unpinning the session ensures that a subsequent
818
- abortTransaction (or commitTransaction) does not block waiting on a server
819
- that is unreachable.
820
-
821
- Additionally, drivers MUST unpin a ClientSession when any individual
822
- commitTransaction command attempt fails with an UnknownTransactionCommitResult
823
- error label. In cases where the UnknownTransactionCommitResult causes an
824
- automatic retry attempt, drivers MUST unpin the ClientSession before performing
825
- server selection for the retry.
826
-
827
- Aborting a transaction or starting a new transaction on a pinned
828
- ClientSession MUST unpin the session. Committing a transaction on a pinned
829
- ClientSession MUST NOT unpin the session as commitTransaction may be called
830
- multiple times. Additionally, any non-transaction operation using a pinned
831
- ClientSession MUST unpin the session and the operation MUST perform normal
832
- server selection.
813
+ Drivers MUST unpin a ClientSession in the following situations:
814
+
815
+ #. The transaction is aborted. The session MUST be unpinned regardless of
816
+ whether or the ``abortTransaction `` command succeeds or fails, or was
817
+ executed at all. If the operation fails with a retryable error, the
818
+ session MUST be unpinned before performing server selection for the retry.
819
+ #. Any operation in the transcation, including ``commitTransaction `` fails with
820
+ a TransientTransactionError. Transient errors indicate that the
821
+ transaction in question has already been aborted or that the pinnned
822
+ mongos is down/unavailable. Unpinning the session ensures that a
823
+ subsequent ``abortTransaction `` (or ``commitTransaction ``) does not block
824
+ waiting on a server that is unreachable.
825
+ #. Any ``commitTransaction `` attempt fails with an
826
+ ``UnknownTransactionCommitResult `` error label. If the error is also
827
+ considered retryable, the session MUST be unpinned before performing
828
+ server selection for the retry.
829
+ #. A new transaction is started on the ClientSession after the previous
830
+ transaction has been committed. The session MUST be unpinned before
831
+ performing server selection for the first operation of the new
832
+ transaction.
833
+ #. A non-transactional operation is performed using the ClientSession. The
834
+ session MUST be unpinned before performing server selection for the
835
+ operation.
836
+
837
+ Note that committing a transaction on a pinned ClientSession MUST NOT unpin
838
+ the session as ``commitTransaction `` may be called multiple times.
833
839
834
840
recoveryToken field
835
841
~~~~~~~~~~~~~~~~~~~
@@ -1400,6 +1406,8 @@ durable, which achieves the primary objective of avoiding duplicate commits.
1400
1406
**Changelog **
1401
1407
-------------
1402
1408
1409
+ :2020-04-07: Clarify that all abortTransaction attempts should unpin the session,
1410
+ even if the command is not executed.
1403
1411
:2020-04-07: Specify that sessions should be unpinned once a transaction is aborted.
1404
1412
:2019-10-21: Specify that a commit error can have two error labels
1405
1413
:2019-07-30: Clarify when the cached recoveryToken should be cleared.
0 commit comments