Stale processing rows are never recovered — recover_stale_sec defaults to 0
Description
When a worker crashes between dequeue and ack, the queue message stays in processing status forever. The QueueFS plugin has a recover_stale_sec parameter that resets stale processing rows to pending, but it defaults to 0 — disabled. There is no Python-layer fallback: the queue manager has no startup recovery logic, so zombie processing rows accumulate silently with every crash.
The Python docstring at named_queue.py:311-312 claims:
If the process crashes between steps 1 and 3, the backend RecoverStale on the next startup resets the message back to 'pending' for retry.
This is incorrect when recover_stale_sec=0 (the default).
Related: #3891 — in-memory coalesce map, same queue-durability family. (The reporter keeps queue-durability defects in separate issues by preference — that is why #3891 / #3892 / #3893 were filed separately.)
Code
openviking/utils/agfs_utils.py:161:
"recover_stale_sec": getattr(queuefs_config, "recover_stale_sec", 0),
The default of 0 means QueueFS never resets processing→pending. At startup, the Python layer does not call any recovery:
QueueManager.start()(queue_manager.py:106-117) — starts worker threads, no queue reconciliation.QueueManager.prepare_task_tracking()(queue_manager.py:119-124) — rebuildsTaskWorkIndexfromsnapshot(), but does not reset processing→pending.QueueManager.setup_standard_queues()(queue_manager.py:126-160) — creates queue objects, no recovery.
The only recovery path is QueueFS itself, gated on recover_stale_sec > 0.
Steps to Reproduce
- Start OpenViking with default config (no
[queuefs]section in ov.conf, sorecover_stale_sec=0). - Enqueue some jobs and let a worker start processing one (dequeue transitions it to
processing). - Kill the worker process (or crash the server) before the worker acks.
- Restart the server.
- Query
queue.db: the row remainsstatus='processing'with its originalprocessing_started_attimestamp. The/dequeueendpoint only returnspendingrows, so the zombie is never retried. QueueManager reports 0 or 1 in-progress, but queue.db shows N processing rows — a silent mismatch.
Observed Impact
After a server crash-loop on 2026-08-08, the Semantic queue had 5 rows stuck in processing with timestamps predating the restart. Only 1 had a live worker behind it; the other 4 were orphaned markers that would persist until the queue database was manually cleaned. The same pattern appeared in the AddResource queue (1 row, 160+ minutes without a worker).
A cleanup script reset 9 processing rows to pending (processing_started_at=NULL) before the restart — after the crash-loop those rows reappeared as processing with their original old start times, suggesting QueueFS re-claimed them from WAL state that was not checkpointed, but with recover_stale_sec=0 they were left stuck instead of reset.
Suggested Fix
- Change the default
recover_stale_secto a reasonable value (e.g. 300 = 5 minutes). A processing message older than this gets reset to pending on the next dequeue attempt or at QueueFS mount time. - At QueueFS mount time, scan for processing rows older than
recover_stale_secand reset them to pending — this handles the crash-while-processing case cleanly regardless of when the next dequeue arrives. - Update the docstring at
named_queue.py:311to note that recovery depends onrecover_stale_sec > 0.
Environment
- OpenViking v0.4.12, self-hosted, native mode, SQLite queue backend
- ov.conf has no
[queuefs]section, confirming the default of 0 is active - Reproduced across multiple crash/restart cycles
Thanks for reporting this! The current SQLite QueueFS implementation gives recover_stale_sec=0 the opposite meaning to the one described here: opening the backend always runs recovery, and a value of zero resets all persisted processing rows to pending. A positive value limits that recovery to rows older than the configured cutoff. See startup recovery and the zero-value branch.
Closing this report because the claimed disabled-on-restart recovery is not the current behavior. This does not imply automatic recovery of every worker stalled inside a still-running process; that is a separate case discussed in #4303.
If processing rows survive an actual backend reopen on a current version, please reopen, or comment requesting reopening, with the version, backend/configuration, restart logs and sanitized row states before and after restart.