node-mongodb-native
node-mongodb-native copied to clipboard
feat(CSOT) - feature branch
Description
What is changing?
New Error
- Added
MongoOperationTimeoutErrorclass that is thrown when a CSOT timeout is encountered
Changes to Timeout
- Add
Timeout.throwIfExpired()method - Add
Timeout.remainingTimegetter method
Updates to AbstractOperation
- Add
timeoutfieldtimeoutis set at construction if thetimeoutMSoption is provided
Implementing CSOT behaviour for server selection
- Update
Topology.selectServerto accept atimeoutoption which it will use determine whether it has timed out when defined. Otherwise, constructs aTimeoutusing theserverSelectionMSoption as before - Update
Topology.selectServerto throw aMongoOperationTimeoutErroron timeout whenoptions.timeoutis provided and retain previous error behaviour otherwise. - Update
Topology._connectto pass downtimeouttoServer.commandcall used to execute ping on first connection
Implementing CSOT behaviour for connection checkout
- Update
Server.commandto accepttimeoutoption. - Update
ConnectionPool.checkOutto accepttimeoutoption- only uses the passed in timeout if the configured
serverSelectionTimeoutMSis greater than the duration on thetimeout, otherwise, computes the time elapsed since server selection completed and creates timeout for theserverSelectionTimeoutMSdeadline
- 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
resolveOptionsto handletimeoutMSoption propagation -
- Add
csotMinhelper 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:lintscript - [ ] 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.