[DRIVERS-2647] Drivers should unpin connections when ending a session Created: 09/Jun/23 Updated: 31/Jan/24 |
|
| Status: | Backlog |
| Project: | Drivers |
| Component/s: | Load Balancer, Transactions |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Matt Dale | Assignee: | Qingyang Hu |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Driver Changes: | Needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Quarter: | FY25Q1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Downstream Changes Summary: | Summary of necessary driver changes Commits for syncing spec/prose tests Context for other referenced/linked tickets |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Engineering Lead: | |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Start date: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Driver Compliance: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
SummaryThe Transactions and Load Balancer specs together describe the process for "pinning" a connection to a ClientSession when connected to a load-balancer so that all transaction operations are sent to the same mongos. The Load Balancers spec also requires that drivers not use the pinned connection for other transactions concurrently
which drivers may implement by giving exclusive access to the pinned connection to the ClientSession. The When to unpin section in the Transactions spec enumerates the conditions when a connection should be unpinned from a ClientSession. However, the list doesn't specify unpinning when a ClientSession is explicitly ended with endSession. According to the When to unpin section, the following sequence of events may never lead to a connection being unpinned from a ClientSession, effectively creating a connection "leak":
We should amend the When to unpin section to explicitly require drivers to unpin connections from a ClientSession when endSession is called. MotivationWho is the affected end user?Users running transactions on load-balanced databases (e.g. Atlas Serverless or dedicated clusters connecting via a VPC private link). How does this affect the end user?Connections used to run transactions may never be returned to the connection pool, resulting in a connection leak. If the driver is configured with a max connection pool size (or using the default), the driver may eventually run out of unpinned connections and hang. How likely is it that this problem or use case will occur?If a driver unpins connections strictly as described in When to unpin in the Transactions spec, a connection leak will happen anytime a customer creates a session, runs a transaction, and ends the session while connected to a load-balanced database. Some drivers already unpin connections when ending sessions and are unaffected. If the problem does occur, what are the consequences and how severe are they?A driver will either open and then then not use many extra connections or it will hang and stop working. Is this issue urgent?The issue in the Go driver ( Is this ticket required by a downstream team?No. Is this ticket only for tests?No. Acceptance Criteria
|
| Comments |
| Comment by George Wangensteen [ 19/Jul/23 ] |
|
I discussed this with max.hirschhorn@mongodb.com and we think that it is important that drivers also require unpinning after commitTransaction succeeds. If an application mints new sessions explicitly to run transactions, but does not explicitly end those sessions (relying on i.e. garbage collection), connections could also be 'leaked' / not unpinned for prolonged periods of time. |