-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-7121): prevent connection churn on backpressure errors when establishing connections #4800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f4f55f6 to
e14a3ef
Compare
ad9299d to
151b986
Compare
541a8e0 to
70c1333
Compare
| const res = server.command( | ||
| new RunCommandOperation(ns('admin.$cmd'), { ping: 1 }, {}), | ||
| TimeoutContext.create({ | ||
| serverSelectionTimeoutMS: 30_000, | ||
| waitQueueTimeoutMS: 10_000 | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript wasn't properly inferring the types after command.bind() is called for some reason. After adjusting it to call command directly, I got a compiler error and had to provide a timeout context.
| ...HEARTBEAT_EVENTS | ||
| ]; | ||
|
|
||
| function makeConnectionsError(appError: ApplicationError): sinon.SinonStub[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the large diff here, reviewers. Our test runner's old mocks were too permissive and allowed tests to pass that should have failed. I've adjusted this mocking logic:
- if we need to stub before handshake errors, I create stubs that provide the bare minimum needed for the actual handshake to fail. In practice, this means stubbing
net.createConnection(). - otherwise, I use rely on the old stub logic.
I've also adjusted the code to use switch statements instead of if-statements when switching on discriminated union fields, because TS errors if we haven't exhausted all switch statements.
70c1333 to
d3ec74a
Compare
| const isNetworkTimeoutBeforeHandshakeError = | ||
| error instanceof MongoNetworkError && error.beforeHandshake; | ||
| const isAuthHandshakeError = error.hasErrorLabel(MongoErrorLabel.HandshakeError); | ||
| const isAuthOrEstablishmentHandshakeError = error.hasErrorLabel(MongoErrorLabel.HandshakeError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renaming this is a minor cleanup and clarification - this label is also applied to the MongoDB handshake, not just auth.
Description
Summary of Changes
This PR adopts the backpressure changes from mongodb/specifications#1860 and mongodb/specifications#1855.
Notes for Reviewers
What is the motivation for this change?
Release Highlight
Release notes highlight
Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript