OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Server restart causes queue avalanche + misleading FileExistsError from lock reservation exhaustion

Open livechenjt-prog opened this issue 4 months ago • 0 comments

Bug Description

Restarting openviking-server while embed_server is still coming up triggers a self-inflicted queue avalanche. Every in-flight add_resource job re-enqueues itself every 30 s once the embedding circuit breaker opens, and after enough churn the lock manager exhausts its 100-attempt reservation loop and starts raising FileExistsError for paths that don't actually exist on disk.

The service eventually self-heals when embed_server comes back and the breaker closes, but during the window (30 s – several minutes on our 1.8 GB ECS box) the queue is effectively poisoned and the FileExistsError trail looks like a disk conflict, which is misleading.

Environment

  • OpenViking version: 0.4.4 → reproduced again on 0.4.7
  • auth_mode: api_key
  • embedding provider: local embed_server.py on localhost:8008, bge-small-zh-v1.5
  • Server: Aliyun ECS, 1.8 GB RAM, 2 vCPU, Ubuntu (systemd-managed)
  • Journal captured on 2026-07-02 and again 2026-07-08

Steps to Reproduce

  1. Have a queue with a handful (10+) of pending add_resource jobs
  2. systemctl restart openviking (main server only — embed_server is a separate unit)
  3. Within 2–5 s of restart, the main server is back but embed_server briefly returns 404 on /v1/embeddings
  4. Watch journalctl -u openviking

Expected

  • Transient embedding failures should be retried with exponential backoff, not re-enqueued every 30 s
  • Lock-manager reservation exhaustion should surface as an explicit "queue backpressure" error, not FileExistsError for a path that isn't actually there
  • Queue depth should recover monotonically once the breaker closes

Actual

Observed chain (timestamps from our journal, condensed):

T+0    systemctl restart openviking
T+1    openviking-server up; embed_server still initializing model
T+2    First jobs hit /v1/embeddings → 404 page not found
T+3    Circuit breaker opens for embedding provider
T+3-30 Every 30 s: each pending job re-enters the queue
T+45   Queue depth 10 → 40+ (each item re-enqueued ~1x)
T+60   Lock manager reservation loop (100 attempts) times out
       → FileExistsError: '.../resources/<uri>/...' (path DOES NOT exist on disk)
T+90   embed_server ready, breaker closes
T+120  Queue drains, but log is now full of misleading FileExistsError

Verified ls on the paths reported in FileExistsError — the directories didn't exist. It's a lock-reservation artifact, not a real filesystem conflict.

Root Cause Analysis (from the outside)

We can't read the internals, but the external symptoms suggest:

  1. Circuit breaker's re-enqueue policy for embedding failures uses a fixed 30 s interval with no backoff cap → snowball
  2. Lock-manager reservation exhaustion is being mapped to FileExistsError somewhere in the write path — wrong exception class for the actual condition
  3. No cross-service readiness gate between openviking-server and embed_server at startup

Additional Context

  • ov diagnostics_procedures skill we maintain internally now includes a rule "never assume add_resource FileExistsError means a real disk conflict — verify with ls first" specifically because of this bug
  • Related surface: the same restart pattern is what triggers observer-API confusion (see #1604 area) — startup ordering is generally underspecified
  • Falsification signal: if this is already fixed on main after 0.4.7, please point us at the commit and we'll close

Impact

  • Every planned restart (config change, model swap, memory swap release) has a self-inflicted 60–120 s window of noisy queue thrash
  • Misleading FileExistsError in logs makes on-call debugging harder
  • On low-memory boxes (ours is 1.8 GB) the extra pressure occasionally trips OOM on embed_server cold-start

livechenjt-prog avatar Jul 10 '26 08:07 livechenjt-prog