[Bug]: Server restart causes queue avalanche + misleading FileExistsError from lock reservation exhaustion
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.pyonlocalhost: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
- Have a queue with a handful (10+) of pending
add_resourcejobs systemctl restart openviking(main server only —embed_serveris a separate unit)- Within 2–5 s of restart, the main server is back but
embed_serverbriefly returns 404 on/v1/embeddings - 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
FileExistsErrorfor 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:
- Circuit breaker's re-enqueue policy for embedding failures uses a fixed 30 s interval with no backoff cap → snowball
- Lock-manager reservation exhaustion is being mapped to
FileExistsErrorsomewhere in the write path — wrong exception class for the actual condition - No cross-service readiness gate between
openviking-serverandembed_serverat startup
Additional Context
ov diagnostics_proceduresskill we maintain internally now includes a rule "never assumeadd_resourceFileExistsErrormeans a real disk conflict — verify withlsfirst" 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
mainafter 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
FileExistsErrorin logs makes on-call debugging harder - On low-memory boxes (ours is 1.8 GB) the extra pressure occasionally trips OOM on
embed_servercold-start