test(NODE-7470): test that backpressure retries are non-blocking#4891
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the client backpressure retry behavior and adds a unified spec test to ensure connections are returned to the pool between retry attempts when the server reports overload (particularly relevant for load-balanced topologies where sessions can pin connections).
Changes:
- Added a new unified spec test asserting
connectionCheckedOut/connectionCheckedInpairing across overload retry attempts. - Updated the retry loop to unpin pinned sessions when retrying
SystemOverloadedErrorso connections can be checked back into the pool. - Added generated JSON alongside the YAML spec.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/spec/client-backpressure/backpressure-connection-checkin.yml | New unified spec asserting connections are checked back in during overload retries. |
| test/spec/client-backpressure/backpressure-connection-checkin.json | Generated JSON version of the new unified spec. |
| src/operations/execute_operation.ts | Adds session unpinning logic on SystemOverloadedError within the retry loop. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR updates the Node driver’s client backpressure coverage and fixes a load-balanced (LB) retry behavior where cursor-creating operations could keep a session’s pinned connection checked out across SystemOverloadedError retries, instead of returning it to the pool during backoff.
Changes:
- Add a new unified test that asserts connections are checked back into the pool between overload retry attempts.
- Update retry logic to unpin LB sessions on
SystemOverloadedErrorfor cursor-creating operations (mirroring existing unpin behavior forMongoNetworkError).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/spec/client-backpressure/backpressure-connection-checkin.yml | Adds unified YAML test asserting per-attempt CMAP check-out/check-in for overload retries. |
| test/spec/client-backpressure/backpressure-connection-checkin.json | JSON equivalent of the new unified test for overload retry connection check-in behavior. |
| src/operations/execute_operation.ts | Unpins pinned LB sessions on SystemOverloadedError during retry loop so connections return to the pool during backoff. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
NODE-7470
Summary of Changes
Sync client backpressure tests to latest
Fixed bug that appears on LB topologies: unpin sessions on
SystemOverloadedErrorduring retries so that connections are checked back into the pool during the backoff period, rather than being held for the entire retry sequence. This was already handled forMongoNetworkErrorbut not for server-side overload errors, which caused the connection to remain pinned in load-balanced mode across all retry attempts.Notes for Reviewers
N/A
Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript