Currently, the sessions spec has drivers perform server selection to determine sessions support if the support status is not currently known: https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst#how-to-check-whether-a-deployment-supports-sessions
This approach has some known race conditions, as documented in the spec as well (https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst#possible-race-conditions-when-checking-whether-a-deployment-supports-sessions).
Drivers should update their logic to defer checking for sessions support after a connection has actually been checked out. The driver should then check that the particular server supports sessions - that is, the connection has non-null logicalSessionTimeoutMinutes.
If the user supplied an explicit session and it turns out at this point sessions are not supported for the server, the driver can then raise an error.
If no user session was supplied (so an implicit session is used) and it turns out at this point sessions are not supported for the server, the driver can ignore the implicit session (the spec already instructs to do this.)
This approach simplifies session support checking and eliminates 3 of the 4 possible race conditions around sessions.
This ticket is being proposed as a subset of the original work imagined in DRIVERS-2337.
This ticket also relates to DRIVERS-759, which changed the spec to permit drivers to defer sessions support checks but would still have sessions support checks performed via server selection.
New Prose Tests
- Test that an implicit session is not sent to a server that does not support sessions
- Test that `startSession` does not error but the explicit session raises a client-side error if specified for a server that does not support sessions
Note: Server selection logging work DRIVERS-1671 will define additional tests to confirm that no server selection is performed to determine session support.
- is depended on by
-
DRIVERS-1671 Add log messages to Server selection spec
- Implementing
- is related to
-
DRIVERS-1204 Easier debugging with standardized logging
- In Progress
- related to
-
DRIVERS-2337 Assume all >=3.6 servers support sessions
- Backlog
-
DRIVERS-759 Drivers may defer checking if a deployment supports sessions until the session's first operation
- Implementing
- split to
-
CDRIVER-4566 Do not perform server selection to determine sessions support
- Backlog
-
CXX-2643 Do not perform server selection to determine sessions support
- Backlog
-
RUBY-3212 Do not perform server selection to determine sessions support
- Backlog
-
PHPLIB-1073 Do not perform server selection to determine sessions support
- Blocked
-
JAVA-4860 Do not perform server selection to determine sessions support
- Closed
-
CSHARP-4504 Do not perform server selection to determine sessions support
- Closed
-
GODRIVER-2742 Do not perform server selection to determine sessions support
- Closed
-
MOTOR-1090 Do not perform server selection to determine sessions support
- Closed
-
NODE-5017 Do not perform server selection to determine sessions support
- Closed
-
PYTHON-3587 Do not perform server selection to determine sessions support
- Closed
-
RUST-1585 Do not perform server selection to determine sessions support
- Closed