Skip to content

Commit cbcf81b

Browse files
authored
feat(DRIVERS-2647): ensure endSessions unpins (#1711)
1 parent 188ac8e commit cbcf81b

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

source/load-balancers/tests/transactions.json

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/load-balancers/tests/transactions.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,21 @@ tests:
596596
- connectionCheckedOutEvent: {}
597597
# Events for abortTransaction.
598598
- connectionCheckedInEvent: {}
599+
600+
- description: pinned connection is released when session ended
601+
operations:
602+
- *startTransaction
603+
- *transactionalInsert
604+
- *commitTransaction
605+
- &endSession
606+
name: endSession
607+
object: *session0
608+
expectEvents:
609+
- client: *client0
610+
eventType: cmap
611+
events:
612+
# Events for the insert and commitTransaction.
613+
- connectionReadyEvent: {}
614+
- connectionCheckedOutEvent: {}
615+
# Events for endSession.
616+
- connectionCheckedInEvent: {}

source/transactions/transactions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ Drivers MUST unpin a ClientSession in the following situations:
641641
be unpinned before performing server selection for the first operation of the new transaction.
642642
5. A non-transactional operation is performed using the ClientSession. The session MUST be unpinned before performing
643643
server selection for the operation.
644+
6. The ClientSession is ended either explicitly via `endSession` method, or implicitly when supported by the driver.
644645

645646
Note that committing a transaction on a pinned ClientSession MUST NOT unpin the session as `commitTransaction` may be
646647
called multiple times.
@@ -1073,6 +1074,8 @@ objective of avoiding duplicate commits.
10731074

10741075
## **Changelog**
10751076

1077+
- 2024-11-01: Specify that ClientSession must be unpinned when ended.
1078+
10761079
- 2024-10-31: Clarify when drivers must add TransientTransactionError label.
10771080

10781081
- 2024-10-28: Note read preference must always be primary in a transaction.

0 commit comments

Comments
 (0)