OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

Queue rows in 'processing' status are orphaned forever after a server restart — no startup reclaim, no visibility timeout

Open pengfus opened this issue 4 months ago • 1 comments

Environment

  • OpenViking v0.4.5 (docker, sqlite-backed queue at _system/queue/queue.db); behavior re-verified 2026-07-11

Bug

When the server stops (restart, crash, OOM-kill) while semantic messages are being processed, their rows in queue_messages remain in status='processing' forever:

  • there is no startup pass that reclaims processing rows back to pending;
  • there is no visibility timeout / lease on processing_started_at that would re-deliver them later.

The corresponding semantic work (directory summaries, vectorization triggers) is silently lost. Nothing surfaces the loss: queue counts look small, no error is logged, and callers that already got wait=true responses have no reason to retry. Combined with the fact that routine operations enqueue semantic work constantly, every restart leaks a few units of semantic state that never converge.

Reproduction

  1. Enqueue semantic work that takes a while (e.g. register a resource tree with wait=false).
  2. Restart the server while the message is mid-processing (status='processing' in queue_messages).
  3. After restart, observe the row still in processing indefinitely (we waited 10+ minutes and across an additional restart — it is never picked up again; the dequeuer only selects pending rows).

Measured impact

On our test instance a restart left 3 rows orphaned in processing; the affected directory-refresh work simply never happened until we manually reset them:

UPDATE queue_messages SET status='pending', processing_started_at=NULL WHERE status='processing';

(after which they were picked up and completed normally).

Expected behavior

Either of the standard queue semantics would fix this:

  • on startup, reset rows owned by dead consumers (processing → pending), since a fresh process provably owns no in-flight work; or
  • honor processing_started_at as a lease: rows whose lease expired get re-delivered.

Related context: when such interrupted messages carry a lock_handoff, re-delivery used to hot-loop on the dead lock handle — that part is #3150. This issue is about the rows that are never re-delivered at all.

pengfus avatar Jul 13 '26 09:07 pengfus

Thanks for reporting this and for the detailed reproduction.

We rechecked the current main implementation. When the SQLite queue backend opens, it runs stale-message recovery; with the default recover_stale_sec=0, all rows left in processing are returned to pending. This behavior was added in #1500 and is covered by the restart/recovery test.

The behavior reported against v0.4.5 is therefore already handled in current main, so we are closing this as completed. If it reproduces on a current build, please share the exact commit/version, QueueFS backend configuration, and whether the same persisted queue database was reused.

qin-ctx avatar Jul 14 '26 03:07 qin-ctx