Repository navigation
Conversation
gh: Panic: `sync: negative WaitGroup counter` in `AWSBatchJob.RunFinished` under high concurrent job load Fixes #136
sclaw
force-pushed
the
bugfix/negative-wg-counter
branch
from
October 15, 2026 14:31
52f09ed to
e56c1d0
Compare
…ttempt to avoid pull quota limits. Also run docker build in foreground so pyecho:latest is available.
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 #136.
Context
SEPEX submits AWS Batch jobs, then keeps each active job in memory while status updates arrive. When a job reaches a terminal status, the status handler closes it and calls
RunFinished()to release its completion waiter. On API restart, recovery rebuilds active AWS Batch jobs from database records and checks their current AWS status.What went wrong
New AWS Batch jobs increment
wgRunduringCreate(), but recovered jobs did not increment it before becoming active. The first terminal update for a recovered job calledRunFinished(), which decremented a zero-valued WaitGroup and crashed the API withsync: negative WaitGroup counter. Repeated restarts could reattach the same unfinished jobs and trigger the crash again.Overlapping completion paths could also attempt cleanup more than once. A status update, recovery, and a dismissal can all lead to job closure.
Changes
wgRunbefore adding a recovered AWS Batch job to the active-job map.RunFinished()andClose()run once per AWS Batch job, so overlapping completion paths cannot decrement the counter or send cleanup twice.RunFinished()concurrently for multiple jobs and verifies each waiter unblocks.Verification
From
api/:go test -race ./jobs -count=1passed.Live AWS Batch load and restart behavior was not tested; that still needs deployment-level verification.