OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Local Embedded VectorDB Lock Contention in Container Workload

Open zztdandan opened this issue 8 months ago • 1 comments

Bug Description

When running OpenViking with storage.vectordb.backend=local in containerized deployment, periodic watch sync can trigger lock contention on the same local collection path.

This issue was observed in container mode under long-running sync tests, while host-mode runs with the same dataset and comparable settings did not reproduce the same VectorDB-handle lock failure pattern.

Steps to Reproduce

  1. Run OpenViking in Docker/container mode with local embedded VectorDB.
  2. Map a large external docs directory into the container (for example: /mnt/add-resource/docs).
  3. Register watch sync on the mapped resource (for example: every 1 minute or 90 seconds).
  4. Keep the service running for several cycles while semantic and embedding queues are active.
  5. Observe recurring lock/contention errors in logs.

Expected Behavior

OpenViking should continuously process semantic and embedding tasks for watched resources without local VectorDB lock conflicts, and vector writes should progress stably over time.

Actual Behavior

In container mode, we observed intermittent lock contention and repeated lock-timeout warnings, such as:

  • LOCK: already held by process
  • Failed to write to vector database
  • Failed to acquire lifecycle lock on /local/.../resources/...

This can cause temporary write stalls or misleading symptoms that look like vectorization has stopped.

Minimal Reproducible Example

Configuration (excerpt):


{
  "storage": {
    "workspace": "/app/data",
    "vectordb": {
      "backend": "local"
    }
  },
  "vlm": {
    "max_concurrent": 8
  }
}


Workload pattern:

- Resource source: mounted external docs directory
- Watch interval: 1 minute or 90 seconds
- Run window: 10+ minutes with active semantic/embedding pipelines

Error Logs

Typical log snippets during repro:


LOCK: already held by process
Failed to write to vector database
[ResourceProcessor] Failed to acquire lifecycle lock on /local/localtest/resources/dedge-ontology-docs

OpenViking Version

Tested against current main around commit 1efb9fb baseline and follow-up branch validation.

Python Version

Python 3.10

Operating System

Linux

Model Backend

OpenAI

Additional Context

Root cause analysis indicates repeated open/access to the same local collection path under concurrent container workload raises lock contention probability.

zztdandan avatar Mar 20 '26 07:03 zztdandan

This issue should already be addressed by #777 (merged on Mar 19), which shares a single adapter instance across all account backends, eliminating the duplicate RocksDB opens that caused LOCK: already held by process.

If the problem persists after updating to the latest main, note that the Failed to acquire lifecycle lock on /local/.../resources/... error is a different lock — it comes from the AGFS/filesystem layer (path locking from #431), not from the VectorDB RocksDB LOCK. If you are still seeing issues, posting full container logs here would help us trace whether the remaining contention is at the filesystem layer.

Linking #777 as the fix for the VectorDB-level lock contention described here.

qin-ctx avatar Mar 20 '26 07:03 qin-ctx