Skip to content

Wait for the continuable job to start before interrupting it - #767

Merged
rosa merged 1 commit into
mainfrom
fix-flaky-continuation-test
Jul 24, 2026
Merged

Wait for the continuable job to start before interrupting it#767
rosa merged 1 commit into
mainfrom
fix-flaky-continuation-test

Conversation

@rosa

@rosa rosa commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes the ContinuationTest#test_continuable_job_can_be_interrupted_and_resumed flake seen twice this week on mysql (on #764's and #765's CI runs), failing with Expected: "stepped" / Actual: nil.

CI log forensics (first-attempt logs + the test.log artifacts) showed TERM arriving before any worker had claimed the job — the fixed sleep 0.2 wasn't enough on a loaded runner. wait_for_jobs_to_be_released_for then returned vacuously (zero claimed executions means it can't distinguish "released" from "never claimed"), and the assertions ran against an untouched JobResult. The artifact timeline even shows the job being claimed ~120ms after the failed assertion and then interrupting perfectly cleanly — the test just asserted too early. Reproduced locally 5/5 by shrinking the sleep, with the exact CI signature.

Same deterministic pattern as the other lifecycle fixes: the job now writes a "started" marker at the top of step_one, and the test waits for it before signaling, so TERM always lands while the job is paused inside step one. The 0.5s pause stays as-is deliberately — it must complete within the pool's shutdown timeout for the graceful between-steps interruption the test verifies.

Stability: 50 stress runs on mysql post-fix (only noise: one proven host-clock-jump from a laptop suspend), full file 10/10 green on rails_main.

🤖 Generated with Claude Code

The test slept a fixed 0.2 seconds after enqueuing and then signaled
TERM, assuming the job would be mid-step by then. On a slow runner the
signal could arrive before any worker had even claimed the job, and
the wait for released jobs would return immediately, unable to tell
"released" from "never claimed", so the test asserted against a job
result that hadn't been touched yet.

Have the job write a "started" marker at the top of its first step and
wait for it before signaling, so the interruption always lands while
the job is paused inside step one, which is the scenario the test
exists to check: interrupt between steps, resume, complete.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rosa
rosa merged commit 74b6b07 into main Jul 24, 2026
171 of 174 checks passed
@rosa
rosa deleted the fix-flaky-continuation-test branch July 24, 2026 17:20
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.

1 participant