Skip to content

PYTHON-6003 Fix flaky test_pool_unpause - #2983

Open
blink1073 wants to merge 2 commits into
mongodb:mainfrom
blink1073:PYTHON-6003
Open

PYTHON-6003 Fix flaky test_pool_unpause#2983
blink1073 wants to merge 2 commits into
mongodb:mainfrom
blink1073:PYTHON-6003

Conversation

@blink1073

@blink1073 blink1073 commented Aug 13, 2026

Copy link
Copy Markdown
Member

PYTHON-6003

Changes in this PR

test_pool_unpause flaked because the default streaming SDAM protocol starts an RTT monitor that sends its own hello calls with the same appName, racing the test's failCommand (mode.times: 2) against the SDAM heartbeat monitor's hello calls. When the RTT monitor won the race, ServerHeartbeatFailedEvent never fired and the test timed out.

Fix: pass serverMonitoringMode="poll" to disable the RTT monitor and remove the race.

Test Plan

  • Reverted the fix and ran test_pool_unpause against a local MongoDB 8.0 server 15 times: reproduced the failure twice.
  • With the fix, ran the async test 20 times and the sync mirror once, and all passed.
  • just lint and just typing pass.

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).

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?

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The default streaming SDAM protocol starts a separate RTT monitor that
issues its own hello calls with the same appName, racing against the
test's failCommand (mode.times=2) for the SDAM heartbeat monitor's own
hello calls. When the RTT monitor's hello wins the race, the SDAM
monitor never sees a failure and ServerHeartbeatFailedEvent never
fires. Force serverMonitoringMode="poll" to remove the RTT monitor and
the race.
@blink1073
blink1073 marked this pull request as ready for review August 13, 2026 15:07
@blink1073
blink1073 requested a review from a team as a code owner August 13, 2026 15:07
@blink1073
blink1073 requested review from aclark4life and a lite review from Copilot August 13, 2026 15:07

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.

Pull request overview

Fixes flakiness in the test_pool_unpause integration test by preventing the streaming SDAM RTT monitor from racing the test’s failCommand budget, ensuring ServerHeartbeatFailedEvent reliably fires.

Changes:

  • Forces serverMonitoringMode="poll" in test_pool_unpause to disable the RTT monitor and remove the hello race.
  • Adds an explanatory comment describing why polling is required for test stability (PYTHON-6003).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/asynchronous/test_discovery_and_monitoring.py Forces polling monitoring mode in the async test_pool_unpause to eliminate RTT-monitor hello interference.
test/test_discovery_and_monitoring.py Sync mirror of the same test adjustment (generated counterpart).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/asynchronous/test_discovery_and_monitoring.py Outdated
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.

2 participants