Skip to content

bug: Race condition in mcp-server/server.py _init() under concurrent requests #74

Closed as not planned

Description

@GunaPalanivel

Context

mcp-server/server.py uses lazy initialization in _init() (lines 18–23) to set up the MilvusClient and encoder. There's no lock around this.

Problem

Under concurrent WebSocket connections at startup, multiple callers can enter _init() before the first one completes — so the client and encoder get initialized multiple times, or a second request reads partially-initialized state.

Why This Order

Needs to land after #28 (MilvusClient standardization) since both touch the same init path. Must be fixed before the Kagent-managed agent layer builds on top of these servers.

Acceptance Criteria

  • _init() is safe under concurrent calls — second caller blocks until first completes, then reuses the result
  • No double-initialization in logs under load
  • Verified with a concurrent connection test

Related

Activity

  1. KavyaDabhi commented on Mar 4, 2026

    @KavyaDabhi

    Hi! I'm an ECE student preparing my GSoC proposal around expanding this MCP server. I've successfully spun up the local kind cluster and traced this logic. I'd love to pick this up and submit a PR to add a thread lock to the _init() function. Could you assign this to me?

  2. added a commit that references this issue on Mar 22, 2026
    835a14d
  3. chasecadet commented on Nov 20, 2026

    @chasecadet
    Contributor

    Thank you for reporting this!

    We are closing pre-restructure issues targeting the legacy server/, server-https/, manifests/, kagent-feast-mcp/, or in-process SentenceTransformer prototype code. In #207, #210, #233, #240, and #249, kubeflow/docs-agent migrated to dedicated TEI (text-embeddings-inference), FastMCP (docs-agent-mcp/mcp-server/), shared modular KFP pipelines (docs-agent-mcp/pipelines/), and Helm charts (docs-agent-mcp/charts/).

    If you still observe an equivalent issue on the current main stack, please feel free to open a new issue using the current issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions