Skip to content

Conversation

@baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Nov 19, 2025

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

  • Lint is passing (npm run check:lint)
  • 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
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@baileympearson baileympearson force-pushed the NODE-7121 branch 2 times, most recently from f4f55f6 to e14a3ef Compare November 19, 2025 21:16
@baileympearson baileympearson changed the title wip feat(NODE-7121): prevent connection churn on backpressure errors when establishing connections feat(NODE-7121): prevent connection churn on backpressure errors when establishing connections Dec 2, 2025
@baileympearson baileympearson removed the wip label Dec 2, 2025
@baileympearson baileympearson marked this pull request as ready for review December 2, 2025 21:22
@baileympearson baileympearson requested a review from a team as a code owner December 2, 2025 21:22
@tadjik1 tadjik1 self-assigned this Dec 8, 2025
@tadjik1 tadjik1 added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Dec 8, 2025
@tadjik1
Copy link
Member

tadjik1 commented Dec 9, 2025

This file is missing from the sync: source/server-discovery-and-monitoring/tests/errors/error_handling_handshake.yml

Copy link
Member

@tadjik1 tadjik1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @baileympearson, great work on syncing and improving tests! Just a few small comments from my side.

@tadjik1 tadjik1 requested a review from a team December 9, 2025 08:52
@tadjik1 tadjik1 added the Team Review Needs review from team label Dec 9, 2025
"servers": {
"a:27017": {
"type": "Unknown",
"topologyVersion": null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a corresponding updated yml file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I missed this? I copy the full directory in when syncing tests 🤷

Fixed.

if (error instanceof MongoError) {
error.addErrorLabel(MongoErrorLabel.HandshakeError);
}
// If we encounter an error executing the initial handshake, apply backpressure labels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says that the labels should be applied "to network errors or network timeouts" - can we update the comment accordingly? And, in this case, are we expecting all errors to be network errors? is it worth explicitly checking to make sure that the error is a network error?

There's also this wording:

For errors that the driver can distinguish as never occurring due to server overload,
such as DNS lookup failures, TLS related errors, or errors encountered establishing a connection to a socks5 proxy,
the driver MUST clear the connection pool and MUST mark the server Unknown for these error types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are non network errors possible here but they're very unlikely and/or would show up and be handled in non-prod environments.

some examples:

  • MongoParseErrors, if we fail to parse a wire protocol response (arguably a network error?)
  • Server errors, if the handshake doc is invalid (would most likely show up non-prod, would also prevent any connections being established and connect would fail).

I've gone ahead and just filtered out only network errors though (network timeout errors subclass network errors) though.

socket = await connectedSocket;
return socket;
} catch (error) {
// If we encounter a SystemOverloaded error while establishing a socket, apply the backpressure labels to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above, the spec says that the labels should be applied "to network errors or network timeouts" - can we update this comment accordingly? I assume in this case we do expect all errors to be network errors, but is it worth double checking that this is the case and that there aren't any that we could reliably determine aren't due to server overload?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've clarified the comment here. lmk what you think

});
});

context('Connection Pool Backpressure', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we annotate the test with the corresponding prose wording from the spec (as we do for other prose tests to make them easier to follow & audit)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@tadjik1 tadjik1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @baileympearson!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Primary Review In Review with primary reviewer, not yet ready for team's eyes Team Review Needs review from team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants