Skip to content

PYTHON-6262 getMore retries and multi-mongos retryable writes fail in load-balanced mode - #3218

Open
blink1073 wants to merge 4 commits into
mongodb:mainfrom
blink1073:PYTHON-6262
Open

blink1073 wants to merge 4 commits into
mongodb:mainfrom
blink1073:PYTHON-6262

Conversation

@blink1073

@blink1073 blink1073 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

PYTHON-6262

Changes in this PR

In load-balanced mode, cursors pin to a single connection and every getMore must run on it. The pinned-connection path bypassed the retryable-read wrapper, so a retryable overload error from the server aborted the cursor instead of being retried.

  • Sends pinned getMores through the retryable-read path, retrying on the pinned connection.
  • Runs the full test suite in the load-balancer task, in addition to the load-balancer-marked tests.
  • Skips the multi-mongos retryable-writes test on load-balanced topologies, where a retry routed to a different mongos is not observable.

Test Plan

Adds an integration test that pins a cursor and fails getMore with a retryable overload error. The cursor drains while the failures stay within the adaptive retry limit and raises once they exceed it. Needs a live server with failCommand enabled.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s). PYTHON-6167 splits the per-suite task families, including separating sync and async tasks.

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A retryable overload reply can leave exhaust-stream state stale, causing a receive-only retry to block indefinitely with the default socket timeout.

1 open issue
What changed in this PR

This PR addresses PYTHON-6262 by routing pinned cursor getMore operations through PyMongo’s retryable-read handling, allowing overload retries on the same connection in load-balanced mode.

Changes:

  • Passes pinned connection managers through the shared retry machinery.
  • Adds regression coverage for pinned retries and skips an incompatible multi-mongos test.
  • Expands load-balancer CI coverage and documents the fix.
File Description
test/​test_retryable_writes.py Generated sync skip for the multi-mongos test in load-balanced mode.
test/​test_client_backpressure.py Generated sync coverage for pinned overload retries and retry limits.
test/​asynchronous/​test_retryable_writes.py Skips the multi-mongos test in load-balanced mode.
test/​asynchronous/​test_client_backpressure.py Tests pinned overload retries and retry limits.
pymongo/​synchronous/​mongo_client.py Generated sync integration of pinned connections into retry handling.
pymongo/​mongo_client_shared.py Stores the pinned connection manager in shared retry state.
pymongo/​asynchronous/​mongo_client.py Routes pinned reads through retry handling while reusing their connection.
doc/​changelog.rst Documents the load-balanced getMore retry fix.
.evergreen/​scripts/​test_generate_config.py Tests the expanded load-balancer marker selection.
.evergreen/​scripts/​run_tests.py Includes default sync and async suites in load-balancer runs.

Review effort: Balanced

Comment thread pymongo/asynchronous/mongo_client.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new test fails before exercising the retry guard on pre-7.1 mongos/load-balanced deployments and in Stable API require-v1 variants because it lacks version gating and omits the configured server_api option.

2 open issues
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Pinned-connection retries and receive-only exhaust handling require live-server validation, including a load-balanced topology with failCommand enabled, which could not be exercised in this review environment.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@blink1073
blink1073 marked this pull request as ready for review November 13, 2026 01:15
@blink1073
blink1073 requested a review from a team as a code owner November 13, 2026 01:15

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants