Repository navigation
fix(teams): a lost worker's run is never retried, whichever path sees it first (#394) - #522
Merged
Merged
Conversation
… it first (#394) Two races in worker termination handling (#343): 1. "Fail without retry" was not durable. The reaper, lease reaper or launch poller failed the execution in one transaction and closed the team run without retry later, in the best-effort `report_ended_execution`. The 2-second team-run loop usually saw the failed execution first and closed the queue item with a retry, and an API restart between the two had the same result. The decision is now read from the stored execution error: - new `Store::team_run_execution_failed_with(run_id, codes)` finds a failed execution of the run whose error code is in `ended_without_retry_codes()` (worker_lost, worker_oom, worker_evicted, worker_exited, harness_unresponsive; not worker_did_not_start, which ran nothing and keeps its retry, also after #399); - `close_queue_loop` never offers a retry for such a run, so the team-run loop, the outcome reconciler and the platform path all close it the same way; - `advance_claimed` routes such a run through `fail_team_run_for_execution` first, so a workflow does not follow a "failed" line past that step. 2. `fail_worker_executions` fabricated a failure on `finish_execution -> Ok(None)`: it cloned the stale record as `failed`, published it, failed the team step and wrote the `worker.*` audit entry, even when the execution had succeeded or a concurrent refresh had already reported it. It now skips executions it did not end; item 1 makes the "still close the team run" fallback unnecessary. Tests: `a_lost_worker_run_is_not_retried_when_the_team_poller_sees_it_first` (four codes plus a harness_error control that keeps its retry), `the_outcome_reconciler_does_not_ retry_a_lost_worker_run` (restart between failing the run and closing its item), and `overlapping_launch_refreshes_report_only_the_failure_they_caused` (two concurrent refreshes plus a late `succeeded`, eight rounds: succeeded -> no event, audit or failed run; failed -> exactly one of each). All three fail with the fix reverted. Unit test for the code list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #394.
Summary
Two races in worker termination handling (#343):
"Fail without retry" was not durable. The reaper, lease reaper or launch poller failed
the execution in one transaction and closed the team run without retry later, in the
best-effort
report_ended_execution. The 2-second team-run loop usually saw the failedexecution first and closed the queue item with a retry, and an API restart between the
two had the same result. The decision is now read from the stored execution error:
Store::team_run_execution_failed_with(run_id, codes)finds a failed executionof the run whose error code is in
ended_without_retry_codes()(worker_lost,worker_oom, worker_evicted, worker_exited, harness_unresponsive; not
worker_did_not_start, which ran nothing and keeps its retry, also after Launcher termination mapping: image pull errors end runs without retry, and an evicted Deployment pod fails a launch whose replacement is running #399);
close_queue_loopnever offers a retry for such a run, so the team-run loop, theoutcome reconciler and the platform path all close it the same way;
advance_claimedroutes such a run throughfail_team_run_for_executionfirst, so aworkflow does not follow a "failed" line past that step.
fail_worker_executionsfabricated a failure onfinish_execution -> Ok(None): itcloned the stale record as
failed, published it, failed the team step and wrote theworker.*audit entry, even when the execution had succeeded or a concurrent refreshhad already reported it. It now skips executions it did not end; item 1 makes the
"still close the team run" fallback unnecessary.
Tests:
a_lost_worker_run_is_not_retried_when_the_team_poller_sees_it_first(four codesplus a harness_error control that keeps its retry),
the_outcome_reconciler_does_not_ retry_a_lost_worker_run(restart between failing the run and closing its item), andoverlapping_launch_refreshes_report_only_the_failure_they_caused(two concurrentrefreshes plus a late
succeeded, eight rounds: succeeded -> no event, audit or failedrun; failed -> exactly one of each). All three fail with the fix reverted. Unit test for
the code list.
Testing
cargo fmt --check,clippy --workspace --all-targets -D warnings: cleancargo test --workspace --no-fail-faston a fresh database: 771 passed, 0 faileda_lost_worker_run_is_not_retried_when_the_team_poller_sees_it_first(three no-retry codes plus aharness_errorcontrol that keeps its retry),the_outcome_reconciler_does_not_retry_a_lost_worker_run(restart between failing the run and closing the queue item),overlapping_launch_refreshes_report_only_the_failure_they_caused(two concurrent refreshes plus a latesucceeded, eight rounds; a race test, it caught the old bug in 1 of 2 runs with the fix reverted); unitended_without_retry_testspnpm docs:check: passedNo migration: the no-retry decision is read from the stored executions (
executions_team_run_idx), so it survives restarts.worker_did_not_startkeeps its retry, matching #501.scripts/smoke-worker-termination.shnot run (no cluster).git merge-treeis clean against every open PR that shares a file (#499, #501, #502, #504, #505, #507, #510, #515, #516, #517).🤖 Generated with Claude Code