Repository navigation
feat(jobs): resume jobs after a restart - #99
Merged
Merged
Conversation
A job running when its worker was killed stayed 'running' forever, and a graceful shutdown just stopped the timer, leaving the running job to the same fate. - The worker renews a running job's lock while its handler runs, and before claiming releases running jobs whose lock is older than JOB_LOCK_TTL_MS (10 min) back to pending. - On shutdown it claims nothing more, aborts the handler's new JobContext.signal and waits up to JOB_SHUTDOWN_WAIT_MS (25s). A handler that stops on the signal (throws) goes back to pending without using an attempt; claimed jobs not yet started are handed back. Handlers that ignore the new optional argument behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012GTictazJTxnndn2m4LbtH
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.
Requested by הדסה · project thread
Problem
runningforever. Nothing released it.Change
lockedAteveryJOB_LOCK_TTL_MS / 4. Before each claim it putsrunningjobs whose lock is older thanJOB_LOCK_TTL_MS(default 10 min) back topending(JobService.releaseStale).onModuleDestroy, now async): the worker claims nothing more and aborts the newJobContext.signal(the handler's optional 2nd argument). It then waits up toJOB_SHUTDOWN_WAIT_MS(default 25s, which fits a 40sstop_grace_period).pendingwithout using up an attempt (JobService.release).Consumer: buzz-code/dnd-management-nra#180 (generate_audio moves onto
jobs).Tests
utils/jobs: 50/50 pass (run from the dnd consumer).Generated by Claude Code