Skip to content

Commit

Permalink
feat(DRIVERS-2647): ensure endSessions unpins (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
durran authored Nov 1, 2024
1 parent 188ac8e commit cbcf81b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
44 changes: 44 additions & 0 deletions source/load-balancers/tests/transactions.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions source/load-balancers/tests/transactions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,21 @@ tests:
- connectionCheckedOutEvent: {}
# Events for abortTransaction.
- connectionCheckedInEvent: {}

- description: pinned connection is released when session ended
operations:
- *startTransaction
- *transactionalInsert
- *commitTransaction
- &endSession
name: endSession
object: *session0
expectEvents:
- client: *client0
eventType: cmap
events:
# Events for the insert and commitTransaction.
- connectionReadyEvent: {}
- connectionCheckedOutEvent: {}
# Events for endSession.
- connectionCheckedInEvent: {}
3 changes: 3 additions & 0 deletions source/transactions/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ Drivers MUST unpin a ClientSession in the following situations:
be unpinned before performing server selection for the first operation of the new transaction.
5. A non-transactional operation is performed using the ClientSession. The session MUST be unpinned before performing
server selection for the operation.
6. The ClientSession is ended either explicitly via `endSession` method, or implicitly when supported by the driver.

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

## **Changelog**

- 2024-11-01: Specify that ClientSession must be unpinned when ended.

- 2024-10-31: Clarify when drivers must add TransientTransactionError label.

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

0 comments on commit cbcf81b

Please sign in to comment.