[Bug]: session_commit serial chain stalls indefinitely when the head task hangs in running — no watchdog for a stuck predecessor
Issue Origin
Observed in a real environment (self-hosted deployment, incident reproduced end-to-end on 2026-10-07 23:24 → 2026-10-08 02:01 local time).
Bug Description
session_commit archives of the same session are strictly serialized. When the head task of the chain hangs in running, there is no watchdog or timeout to release the chain: 14 successor tasks behind it cycled "dequeue → dependency check → requeue" for ~2.5 hours with zero progress and no alert of any kind.
The existing self-healing path covers only one failure shape. In _can_run_archive() (openviking/session/session.py, L2693 on current main), the final branch handles an orphaned predecessor: when tracker.has_work(task_id) is False (the predecessor's queue work no longer exists), it writes a .failed.json marker (stage="queue_missing"), fails the tracked task, and returns True so the successor can proceed.
But when the predecessor task still exists and is stuck in running, the check at L2718 is simply:
if tracker.has_work(str(task_id)):
return False
There is no heartbeat, no staleness check on processing_seconds / updated_at, and no timeout circuit-breaker. A head task that never reaches a terminal state therefore blocks the whole serial chain indefinitely.
On the worker side, SessionCommitProcessor (openviking/storage/queuefs/session_commit_processor.py) just puts the message back: _process() re-enqueues it when resume_queued_commit() returns False (session.py L1744 gate → L1680), and on_dequeue() returns ProcessResult.requeued() (L125). So successors keep spinning in a dequeue/requeue loop with nothing to detect the stall.
Steps to Reproduce
Observed on OpenViking 0.4.23 (self-hosted, single node):
- One session accumulated 16+ queued
session_committasks over ~2.5 h (one archive per conversation turn — normal auto-commit behavior). - The head task was dequeued, entered
running, then hung during its model work (in our case the configured model chain timed out on every credential). For 20+ minutes itsprocessing_secondsstayednullwith no state change, while other queue tasks on the same deployment progressed normally (processing_secondsgrowing 461 → 561 s). - The 14 successor tasks kept cycling dequeue → blocked by
_can_run_archive()→ requeue for the rest of the window. Queue depth never drained; no error was raised, no.failed.jsonwas written, nothing was logged or alerted. - Manually cancelling the stuck head task: the next successor was dequeued and started running within ~0.5 s, and the remaining chain drained normally.
Step 4 is the key observation: the serialization gate itself works correctly — the only missing piece is detection of a stuck running head.
Sanitized observation (generic fields only):
head task: status=running, processing_seconds=null (20+ min, no progress)
peer tasks: processing_seconds 461 -> 561 (normal growth, same deployment)
successors: 14 tasks, dequeue -> dependency-wait -> requeue, ~2.5 h, zero progress
manual cancel of head: next successor running within ~0.5 s
Expected Behavior
A running session_commit task should not be able to block its serial chain forever. At least one of:
- A periodic heartbeat for running tasks (refresh
processing_seconds/updated_atwhile the task makes progress). - A watchdog in the queue worker: a
runningtask whoseupdated_atexceeds a configurable threshold (e.g. default 30 min) without a heartbeat is resolved with the same semantics as the existingqueue_missingorphan path — write the.failed.jsonmarker, fail the task, and let the successor proceed. No new recovery machinery is needed: the next commit's Phase-2 replay already handles failed archives. - At minimum, expose a pending-dwell / queue-age metric so operators can alert on a serial chain that has stopped making progress.
Actual Behavior
The chain waits indefinitely and silently. Recovery requires manually cancelling the stuck task (or restarting the server process).
OpenViking Version
0.4.23 (self-hosted). Source references above verified against current main as of 2026-10-08.
Python Version
3.10
Operating System
Linux (Ubuntu 22.04, single node, 2 vCPU / 2 GB RAM)
Model Backend
Other — self-configured model chain over multiple free-tier provider credentials (per-request timeout ~250 s each); the head task hung while its model calls kept timing out.
Additional Context
- Related but distinct: #4345 (open) covers the requeue storm / missing backoff on the dependency-wait path itself. This report is about the missing watchdog that would ever release the chain when the head is stuck — even with perfect backoff, the stall would still be indefinite.
- #4017 and #4392 (both closed) previously reported
session_committasks stuck inrunningand blocking later commits; the watchdog/TTL gap they described still reproduces on 0.4.23. #4017 also noted that task-tracker cleanup only removes COMPLETED/FAILED tasks — the same lifetime gap flagged for the reindex path in #3396. - Suggested watchdog design reuses the existing orphan-cleanup semantics (a
queue_missing-style failed marker), keeping the recovery model unchanged.
Thanks for reporting this! Later commits waiting while an earlier commit is still performing model work is expected under the current per-session ordering. The available evidence does not establish that all model calls and retries had already terminated while OpenViking left the task running; we have not reproduced that failure on current main.
A long-running model call, including one that keeps receiving data and therefore does not hit a read timeout, does not by itself demonstrate a Session lifecycle bug. An overall task deadline or watchdog is a separate timeout-policy decision. We are not adding one based on this report, so closing as not planned.