Skip to content

feat(worker): detect stuck RUNNING jobs via progress heartbeat#790

Merged
bencap merged 1 commit into
release-2026.2.7from
feature/bencap/788/worker-progress-heartbeat
Jul 9, 2026
Merged

feat(worker): detect stuck RUNNING jobs via progress heartbeat#790
bencap merged 1 commit into
release-2026.2.7from
feature/bencap/788/worker-progress-heartbeat

Conversation

@bencap

@bencap bencap commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Replace the pure wall-clock RUNNING-stall check with a progress heartbeat, so a healthy long-running job (e.g. large VEP fan-out) is no longer killed while a genuinely wedged one is still caught. Make the DB-driven sweeper authoritative over termination and keep ARQ's timeout only as a last resort.

  • Add JobRun.progress_updated_at (onupdate=now()) as a zero-code liveness heartbeat, bumped on every committing progress checkpoint; index (status, progress_updated_at) for the sweeper query
  • Detect stalled RUNNING jobs on stale heartbeat (PROGRESS_STALL_MINUTES = 20) OR a wall-clock backstop (RUNNING_TIMEOUT_MINUTES = 450), and recover them abort-first: abort the current attempt and only re-drive once it is confirmed dead or absent, eliminating the double-run where a retry ran alongside the still-live original
  • Handle asyncio.CancelledError in with_job_management: mark the row FAILED/TIMEOUT then re-raise, so an ARQ timeout or a stall-recovery abort no longer orphans the row as RUNNING and Job.abort() can confirm
  • Raise ARQ job_timeout to 8h and enable allow_abort_jobs; tighten the cleanup cron to every 10 minutes
  • Cover new behavior with unit and integration tests

@bencap bencap linked an issue Jul 9, 2026 that may be closed by this pull request
11 tasks
Replace the pure wall-clock RUNNING-stall check with a progress
heartbeat, so a healthy long-running job (e.g. large VEP fan-out) is
no longer killed while a genuinely wedged one is still caught. Make
the DB-driven sweeper authoritative over termination and keep ARQ's
timeout only as a last resort.

- Add JobRun.progress_updated_at (onupdate=now()) as a zero-code
  liveness heartbeat, bumped on every committing progress checkpoint;
  index (status, progress_updated_at) for the sweeper query
- Detect stalled RUNNING jobs on stale heartbeat (PROGRESS_STALL_MINUTES
  = 20) OR a wall-clock backstop (RUNNING_TIMEOUT_MINUTES = 450), and
  recover them abort-first: abort the current attempt and only re-drive
  once it is confirmed dead or absent, eliminating the double-run where
  a retry ran alongside the still-live original
- Handle asyncio.CancelledError in with_job_management: mark the row
  FAILED/TIMEOUT then re-raise, so an ARQ timeout or a stall-recovery
  abort no longer orphans the row as RUNNING and Job.abort() can confirm
- Raise ARQ job_timeout to 8h and enable allow_abort_jobs; tighten the
  cleanup cron to every 10 minutes
- Cover new behavior with unit and integration tests
@bencap bencap force-pushed the feature/bencap/788/worker-progress-heartbeat branch from 2f511bf to 9f10350 Compare July 9, 2026 18:24
@coveralls

coveralls commented Jul 9, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29040562747

Warning

No base build found for commit aa6edb8 on release-2026.2.7.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 89.0%

Details

  • Patch coverage: 50 of 50 lines across 4 files are fully covered (100%).

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 14337
Covered Lines: 12760
Line Coverage: 89.0%
Coverage Strength: 0.89 hits per line

💛 - Coveralls

@bencap bencap merged commit c9e082a into release-2026.2.7 Jul 9, 2026
5 checks passed
@bencap bencap deleted the feature/bencap/788/worker-progress-heartbeat branch July 9, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign stuck-RUNNING-job detection: progress-heartbeat + abort-first recovery

2 participants