fix(batch): reconcile in-flight jobs on restart instead of zombies#1995
Merged
Conversation
…mbies After a restart, a job restored in a non-terminal state (SUBMITTED/PENDING/ RUNNABLE/STARTING/RUNNING) had no background driver (status-sync / dependency-waiter) re-spawned, and its backing ECS task was already STOPPed by the ECS reconcile — so it could never reach a terminal state and hung forever. DescribeJobs would report RUNNING indefinitely, dependent jobs never released, array parents never aggregated. Add BatchService::reconcile_persisted_jobs(), invoked from main.rs right after the batch snapshot is restored (mirroring ECS reconcile_persisted_tasks): every non-terminal job is failed with statusReason "Job interrupted by a fakecloud restart" and a stoppedAt, then the snapshot is re-saved. Tests: unit test (submit -> reconcile -> FAILED + reason, idempotent); a Docker-gated e2e that submits a real long-running container, waits until it's in-flight, restarts the persistent server, and asserts the job comes back FAILED rather than a zombie.
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.
2026-06-27 bug-hunt Tier 4 finding 4.1.
Bug
After a restart, a Batch job restored in a non-terminal state (SUBMITTED/PENDING/RUNNABLE/STARTING/RUNNING) had no background driver (
spawn_status_sync/spawn_dependency_waiter) re-spawned, and its backing ECS task was already STOPPed by the ECS reconcile — so it could never reach a terminal state and hung forever.DescribeJobsreported RUNNING indefinitely,dependsOnjobs never released, array parents never aggregated. Same failure shape as #1338/#914/#1752.Fix
BatchService::reconcile_persisted_jobs(), invoked frommain.rsright after the batch snapshot is restored (mirroring ECSreconcile_persisted_tasks). Every non-terminal job is failed withstatusReason = "Job interrupted by a fakecloud restart"+ astoppedAt, then the snapshot is re-saved. Idempotent (already-terminal jobs untouched).Tests
sleep 120) container on a persistent server, wait until it's genuinely in-flight,restart(), assert it comes back FAILED with the reason — not a zombie.Summary by cubic
Reconcile in-flight Batch jobs on restart by failing them with a clear reason, instead of leaving zombies that hang forever and block dependencies. Adds
BatchService::reconcile_persisted_jobs()and runs it on server startup so non-terminal jobs move to FAILED withstoppedAt.SUBMITTED/PENDING/RUNNABLE/STARTING/RUNNINGjob withstatusReason = "Job interrupted by a fakecloud restart"and setstoppedAt(idempotent).dependsOnand array aggregations.Written for commit 7d8ec85. Summary will update on new commits.