Repository navigation
test(worker): fix races in the reconnect test - #940
Merged
Merged
Conversation
Contributor
2 of 6 tasks
mamoodi
approved these changes
Nov 5, 2026
Contributor
|
🚀 Released in 1.87.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
AGENT:
Why
test_the_worker_reconnects_after_the_server_drops_itis flaky. It failed CI three times today: twice onmainand once on #898.The test had two races:
pg_terminate_backend. If theNOTIFYfired before the worker had runLISTENon its new connection, the job waited for the next poll. The test polls every 60s and waits 20s, so it timed out. All three CI failures were this one.run_one_jobreturns as soon as the job body runs. The worker then still records the job as done and fetches the next one. If the connections drop during that fetch, procrastinate raisesConnectorExceptionout of the worker loop and the worker exits. This one shows up locally underpytest -n 8.Summary
LISTENconnection that opened after the admin connection.Issue Number
How to Test
Run the reconnect test many times in parallel, for example through a wrapper test parametrized with
range(60)anduv run pytest -n 8. Onmainthat gives a few failures per 60 runs. On this branch it passes every time, also with a 1s delay forced into procrastinate'sLISTENreconnect.Video/Screenshots
Type
Notes
The worker exiting on a failed query is procrastinate behavior in 3.10.0, the latest release. So the test now covers a connection drop while the worker is idle. In production, a failover that hits an in-flight worker query still stops the worker process, and the container restarts it.
Enterprise server image for this PR: