-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Component/s: Load Balancer, Transactions
-
Needed
-
Summary
The 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
Drivers MUST NOT use the same connection for two concurrent transactions run under different sessions from the same client.
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":
- Start a ClientSession.
- Run startTransaction in the session.
- Run insertMany in the transaction.
- Run commitTransaction.
- Run endSession.
We should amend the When to unpin section to explicitly require drivers to unpin connections from a ClientSession when endSession is called.
Motivation
Who 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 (GODRIVER-2867) is moderately urgent because it is the root cause of a mongosync bug that is blocking a customer migration (HELP-46291). Its urgency depends on how many other drivers are impacted by the problem and the rate of adoption of impacted services, like Serverless. Overall, it seems moderately urgent to figure out how many drivers are impacted.
Is this ticket required by a downstream team?
No.
Is this ticket only for tests?
No.
Acceptance Criteria
- Amend the "When to unpin" section of the Transactions spec to explicitly require drivers to unpin connections from a ClientSession when endSession is called.
- Add a load balancer spec test that asserts that pinned connections are returned to the connection pool when endSession is called.
- is related to
-
GODRIVER-2867 Connection leak caused by connection-to-transaction pinning when connected to a load balancer
- Closed
- split to
-
CDRIVER-4756 Drivers should unpin connections when ending a session
- Backlog
-
CSHARP-4829 Drivers should unpin connections when ending a session
- Backlog
-
CXX-2779 Drivers should unpin connections when ending a session
- Backlog
-
GODRIVER-3034 Drivers should unpin connections when ending a session
- Backlog
-
RUST-1790 Drivers should unpin connections when ending a session
- Backlog
-
PHPLIB-1299 Drivers should unpin connections when ending a session
- Blocked
-
RUBY-3343 Drivers should unpin connections when ending a session
- Ready for Work
-
MOTOR-1204 Drivers should unpin connections when ending a session
- Closed
-
NODE-5722 Drivers should unpin connections when ending a session
- Closed
-
PYTHON-4020 Drivers should unpin connections when ending a session
- Backlog
-
JAVA-5228 Drivers should unpin connections when ending a session
- Backlog