Why it exists
MokoGIT already had timeout-based janitor crons - a zombie-task reaper and abandoned-job and abandoned-run reapers - but they all key off a long stale-update timeout and none of them consider whether the runner is actually alive. That leaves two gaps that the heal-wedged-runners cron closes:
- A runner dies or is restarted mid-task. The task it owned is still marked running, so it keeps holding a dispatch slot even though nothing is executing it. The zombie reaper will eventually clear it, but only after its full stale timeout elapses - during which that slot is wasted.
- Jobs sit waiting while runners are online but not actually fetching work (a poll-stalled runner that heartbeats but never claims a job). This is the condition that stalled a stable release for about an hour. Nothing was recovering the queue on its own.
Because it keys on liveness rather than a fixed timeout, the cron reacts in minutes rather than waiting out a timeout window.
How it works
The cron runs on a schedule and performs two passes.
Pass 1: free orphaned running tasks
It finds every task currently marked running and checks the liveness of the runner that owns each one. A runner counts as alive only if it exists and its last-online heartbeat is within the offline grace window (a few minutes - long enough to ride out a brief heartbeat gap or a normal short queue, so the cron never flaps). A runner that is missing, errored, or past that grace window is treated as offline, and its still-running task is an orphan.
For each orphaned task the cron, inside a transaction, stops the task with a failure status - the same stop primitive the existing zombie cron uses - and records the job the task belonged to. It then does a best-effort archival of the task's logs, mirroring the normal task-stop path, so the run's history stays intact. Each freed task is logged with a warning naming the task and the offline runner, so the recovery is visible to operators.
Once all orphaned tasks for this pass are freed, the cron pushes a status update for the affected jobs and re-emits them, so a healthy runner can immediately claim the now-freed work rather than the queue sitting idle.
Pass 2: re-nudge a stalled waiting queue
The cron then looks for jobs that have been waiting past the same grace window while runners are online - the classic poll-stall signature (runners heartbeating but not fetching work). The server cannot restart a runner from the inside, so this pass does not mutate task state. Instead it:
- Re-nudges job emission for each distinct waiting run (a no-op if dispatch is actually healthy, so it is safe to run every cycle).
- Logs loudly - how many jobs are waiting, for how long, and how many runners are online - so an operator knows to bounce the wedged runner if the stall persists.
This pass is deliberately detect-and-nudge only. It never stops or cancels anything, because a waiting job with online runners might simply be queued behind legitimate work.
Why it is safe
The cron is conservative by design. It only ever mutates state in pass 1, and only when the runner is provably gone (missing or offline past the grace window), using the same stop primitive as the existing zombie reaper. It does not run at server startup, so it never acts during the churn of a deploy when runners are briefly re-registering. And the waiting-queue pass is a pure nudge - re-emitting ready jobs is a no-op when dispatch is healthy.
How it relates to the other janitors
- Zombie-task reaper - stops tasks whose update timestamp is stale past a long timeout, with no knowledge of runner liveness. Heal-wedged-runners is the faster, liveness-aware complement: it frees an orphaned slot the moment the runner is confirmed offline, rather than waiting the full stale timeout.
- Dispatch-stall detector - a separate cron that alerts when a job waits past its grace window while an online, idle, label-capable runner exists (strict-FIFO head-of-line starvation). That one is detect-and-alert for the online-runner starvation case; heal-wedged-runners handles the offline-runner heal and the re-nudge.
- Abandoned-job and abandoned-run reapers - cancel jobs and runs that were never dispatched or that wedged in waiting/blocked past the abandoned timeout. These address never-started work, not a runner that died mid-task.
Together these form a layered safety net: this cron reacts fastest to a dead runner, and the timeout-based reapers remain the long-stop backstop.
Running and checking it
The cron is enabled by default and runs on its own short schedule; you do not need to configure anything to get the protection. Administrators can inspect or trigger it from the admin Cron Jobs page:
- Go to Site Administration, then Monitoring, then Cron Jobs (the server monitoring area).
- Find the heal_wedged_runners task in the list to see its schedule and last-run time.
- Use the run-now control to trigger it on demand.
When it acts, the cron writes warning-level lines to the server log - one per freed orphaned task (naming the task and offline runner) and a summary line when it detects a possible dispatch stall. Those log lines are the signal to bounce a wedged runner if the condition keeps recurring.
Caveats
- The cron cannot restart a runner. For a poll-stalled (online-but-not-fetching) runner it can only re-nudge emission and alert - an operator still has to bounce the runner process.
- It acts on pass 1 only when the runner is confirmed offline past the grace window. A runner with a brief heartbeat gap inside the grace window is left alone, by design, to avoid flapping.
- Freeing an orphaned task marks it failed. If a runner comes back from the dead after being declared offline, its old task has already been stopped and the work will have been re-dispatched.
- It does not run at startup, so immediately after a deploy the timeout-based reapers (which do run at start) are what clear any pre-existing zombies.
Get help
Open a support ticket or call (931) 820-0265.