Skip to content

PYTHON-6194 Fix SpecRunnerThread lost wakeup race - #3152

Merged
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6194
Oct 27, 2026
Merged

NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6194

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

PYTHON-6194

Changes in this PR

Make SpecRunnerTask/SpecRunnerThread hold the lock when modifying any state to ensure no wakeup calls are missed by waiters.

Test Plan

Existing test suite.

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?

@NoahStapp
NoahStapp requested a review from a team as a code owner October 27, 2026 13:58
@NoahStapp
NoahStapp requested review from sleepyStick and a balanced review from Copilot October 27, 2026 13:58

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

Deterministic regression coverage is needed to verify prompt scheduling and shutdown without relying on the wait timeout.

1 open issue
What changed in this PR

This PR fixes the lost-wakeup race in the specification test runners by protecting queue and shutdown state with the condition lock.

Changes:

  • Move queue updates and shutdown-state changes inside the lock.
  • Check the wait predicate and dequeue work under the lock, while executing work outside it.
  • Apply matching changes to the asynchronous runner and its generated synchronous counterpart.
File Description
test/​utils_spec_runner.py Updates condition locking in the generated synchronous runner.
test/​asynchronous/​utils_spec_runner.py Updates condition locking and the wait loop in the asynchronous source.

Review effort: Balanced

Comment thread test/asynchronous/utils_spec_runner.py
@NoahStapp
NoahStapp merged commit a3ffd33 into mongodb:main Oct 27, 2026
80 checks passed
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