Skip to content

[Bug]: Multiple stdio MCP sessions can contend for the same OpenViking data directory and surface misleading errors #473

@Hilbert-beinghappy

Description

@Hilbert-beinghappy

Bug Description

When OpenViking is used as an MCP server via stdio in a multi-session host (for example, a host that starts one MCP process per session), multiple OpenViking MCP instances can end up pointing to the same data directory at the same time.

In my case, this caused lock/resource contention in the shared storage layer. The resulting user-visible errors were misleading: instead of clearly reporting a lock/resource conflict, the client later surfaced errors such as Collection 'context' does not exist or Transport closed.

The root cause was not a broken OpenViking index. After switching the client from multiple stdio instances to a single shared HTTP MCP endpoint, the problem disappeared.

Steps to Reproduce

  1. Configure an MCP host to launch OpenViking via stdio.
  2. Open multiple sessions so that the host starts multiple OpenViking MCP processes.
  3. Let all of them point to the same OpenViking config/data directory.
  4. Call MCP tools such as search or add_resource.
  5. Observe lock/resource contention and downstream failures.

In my setup, using a single shared HTTP MCP server instead of per-session stdio instances avoided the problem.

Expected Behavior

  • OpenViking should either handle this situation safely, or fail early with a clear lock/resource contention error.
  • The error should clearly indicate that multiple MCP server instances are competing for the same underlying resources.
  • Documentation should clarify when stdio is appropriate and when a shared HTTP MCP server is the safer deployment mode.

Actual Behavior

  • Multiple stdio OpenViking MCP instances ended up competing for the same shared data/storage resources.
  • The visible errors were misleading, including Collection 'context' does not exist.
  • After the backend service itself was repaired, raw HTTP MCP calls succeeded, but an already-open client session still reported Transport closed until the MCP bridge was reloaded or a new session was opened.

Minimal Reproducible Example

Example MCP host configuration pattern:
[mcp_servers.openviking]
type = "stdio"
command = "python"
args = ["server.py", "--transport", "stdio", "--config", "/path/to/ov.conf", "--data", "/path/to/data"]

Then start two or more independent sessions/clients that use the same configuration and the same OpenViking data directory, and call search.

As a workaround, this shared HTTP configuration worked reliably for me:
[mcp_servers.openviking]
url = "http://127.0.0.1:2033/mcp"

Error Logs

Collection 'context' does not exist
Transport closed

OpenViking Version

0.1.17

Python Version

3.12.7

Operating System

macOS

Model Backend

Other

Additional Context

I verified that the backend service itself was healthy by calling the MCP HTTP endpoint directly:

  • /mcp initialize returned 200 OK
  • /mcp tools/list succeeded
  • /mcp tools/call(search) succeeded and returned results

This strongly suggests that the main issue was not a broken index, but transport/configuration conflict caused by multiple stdio MCP instances and, in some clients, stale MCP connections after the backend was restarted.

This may be especially relevant to the new MCP stdio support discussed in #305. Even if the stale-session part is partly host-side, clearer documentation and clearer lock/contention errors on the OpenViking side would still help a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions