A job that says running after its process died - #22
Merged
Conversation
Analysis runs inside the web process, so a deploy replaces the container and takes the work with it. The row keeps saying running for ever. Observed tonight: a thorough detection pass killed at frame 8050 of 9000 by a deploy, still reporting running twenty minutes later, indistinguishable in the panel from one still going — the progress simply stops advancing, which is also what a slow pass looks like. At startup this process owns no running work by definition, so anything the database still calls running was interrupted and nothing is coming to finish it. Those rows are failed with a reason, and the reason is written to the job log where the person who started it is looking. Queued rows go the same way: nothing picks them up either. Finished work is left alone, including jobs that already failed for their own reasons — the sweep must not overwrite why something actually broke. Writing the test found the bug in the first version of this: it updated updated_at, which the jobs table does not have. That would have thrown on every boot with any interrupted job present. Co-Authored-By: Claude Opus 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.
Do not merge this while a detection run is in progress — merging deploys, and deploying kills the run. That is the bug, not a side effect of the fix.
What happened on your server
That is a
thoroughpass killed 950 frames from the end when the #21 deploy replaced the container. It still saysrunning. It will sayrunningfor ever.In the panel that is indistinguishable from a slow run: the progress just stops advancing, which is also what a ten-minute pass looks like from the outside.
The fix
Analysis runs inside the web process, so at startup this process owns no running work by definition. Anything the database still calls running was interrupted and nothing is coming to finish it.
Those rows are failed with a reason, and the reason goes to the job log — where the person who started it is looking, rather than the server's stderr. Queued rows go the same way, since nothing picks those up either.
Finished work is untouched, including jobs that already failed for their own reasons: the sweep must not overwrite why something actually broke.
Found by writing the test
The first version updated
updated_at. Thejobstable has no such column — it hasfinished_at. That would have thrown on every boot that found an interrupted job, which is exactly the boot where it matters.The deeper problem, not fixed here
Every deploy kills any running analysis. Tonight that cost you a run at 8050/9000. This PR makes the loss visible; it does not prevent it. Doing that properly means detection surviving the web process — a separate worker, or resumable jobs that pick up from the last completed frame. Worth doing, and worth its own change rather than being smuggled into this one.
Verification
464 tests pass (4 new), lint and typecheck clean.