node-mongodb-native
node-mongodb-native copied to clipboard
feat(CSOT) - feature branch
Description
What is changing?
New Error
- Added
MongoOperationTimeoutError
class that is thrown when a CSOT timeout is encountered
Changes to Timeout
- Add
Timeout.throwIfExpired()
method - Add
Timeout.remainingTime
getter method
Updates to AbstractOperation
- Add
timeout
field-
timeout
is set at construction if thetimeoutMS
option is provided
-
Implementing CSOT behaviour for server selection
- Update
Topology.selectServer
to accept atimeout
option which it will use determine whether it has timed out when defined. Otherwise, constructs aTimeout
using theserverSelectionMS
option as before - Update
Topology.selectServer
to throw aMongoOperationTimeoutError
on timeout whenoptions.timeout
is provided and retain previous error behaviour otherwise. - Update
Topology._connect
to pass downtimeout
toServer.command
call used to execute ping on first connection
Implementing CSOT behaviour for connection checkout
- Update
Server.command
to accepttimeout
option. - Update
ConnectionPool.checkOut
to accepttimeout
option- only uses the passed in timeout if the configured
serverSelectionTimeoutMS
is greater than the duration on thetimeout
, otherwise, computes the time elapsed since server selection completed and creates timeout for theserverSelectionTimeoutMS
deadline
- only uses the passed in timeout if the configured
Test changes
- Implement Server Selection prose tests from CSOT spec. Left out last two since they require implementation of the connection creation cancellation behaviour that was decided against in DRIVERS-2347
- Implement unit tests from CSOT spec related to server selection and connection checkout. Skipped tests with appropriate messages
Misc changes
- Update
resolveOptions
to handletimeoutMS
option propagation -
- Add
csotMin
helper method that implements the CSOT min algorithm described here
- Add
Is there new documentation needed for these changes?
What is the motivation for this change?
Release Highlight
Fill in title or leave empty for no highlight
Double check the following
- [ ] Ran
npm run check:lint
script - [ ] Self-review completed using the steps outlined here
- [ ] PR title follows the correct format:
type(NODE-xxxx)[!]: description
- Example:
feat(NODE-1234)!: rewriting everything in coffeescript
- Example:
- [ ] Changes are covered by tests
- [ ] New TODOs have a related JIRA ticket
Bookkeeping: Waiting for Warren to respond to Bailey's comments and will proceed with review then.
@aditi-khare-mongoDB @nbbeeken should we conditionally clear the timeout on success/a non-timeout failure based on whether or not we created the timeout inside the function that we race the timeout with?
I ask because we don't always own Timeout instance we're using in Topology.selectServer
or in ConnectionPool.checkOut
.