Recover jobs stuck in Cancelling when no worker acknowledges the cancel#1768
Open
mattdawkins wants to merge 2 commits into
Open
Recover jobs stuck in Cancelling when no worker acknowledges the cancel#1768mattdawkins wants to merge 2 commits into
mattdawkins wants to merge 2 commits into
Conversation
Collaborator
|
I think that #1769 is probably a better PR to resolve this issue. It resolves more the cause of the problem then addressing a symptom (the cancellation status) I think I may close this one in favor of that one. |
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.
Problem
Users report that cancelling a job in the web interface sometimes leaves it at Cancelling for days.
Cancelling a job makes
girder_plugin_workerset statusCANCELING (824)and broadcast a Celeryrevoke(). The job only leaves that state when a live worker acknowledges — either the running task polls and notices the revoke, or Celery discards the revoked message at delivery. Nothing on the server ever times out, so there are permanent dead ends:CANCELING → RUNNINGtransition in its prerun handler).Fix
dive_server/stale_cancellation.py: a sweep that finds jobs sitting inCANCELINGwith no update for 60 seconds, moves them toCANCELED(a transition the worker plugin's table allows), appends an explanatory line to the job log, and re-broadcasts the revoke so a worker that reconnects later discards the still-queued message instead of running it.dive_server/__init__.py: runs the sweep every 30 seconds via a CherryPyMonitorin the Girder server process. The sweep never raises, sinceBackgroundTaskpermanently stops on the first uncaught exception.job_statuspush notifications.Jobs a worker is actively acknowledging never hit the timeout: any job update (including log writes) refreshes
updated, and the subprocess monitor resolves a live cancel within ~30 seconds. Force-cancelling is safe even if the task message is still queued or a worker is in a long non-polling phase — a revoked delivery or late acknowledgment becomes a no-op status write, and a resurrected task fails its first status update instead of silently running.Tests
tests/test_stale_cancellation.pycovers the query cutoff, the force-cancel path, the revoke re-broadcast, and that one failing job doesn't halt the sweep.🤖 Generated with Claude Code