You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In both server/app.py and server-https/app.py, the milvus_search() function executes PyMilvus gRPC calls (connections.connect(), collection.load(), collection.search()). Because these are synchronous, I/O-bound methods and they are called directly within an async def context without being wrapped in asyncio.to_thread or a thread pool, they block the entire ASGI event loop.
This causes the entire server to freeze under concurrent connections.
Note: This is distinct from Issue Implement connection pooling for Milvus #28 (connection pooling), which addresses how many connections are opened. This issue addresses what thread those connections run on to prevent event loop starvation.
Proposed Solution
Refactor milvus_search() to wrap the PyMilvus executions in await asyncio.to_thread(<blocking_call>, *args).
Hi, I'm a GSoC 2026 applicant reviewing the docs-agent codebase for my proposal on Project 1 (Agentic RAG).
I noticed this issue while going through the server code. The core problem is that pymilvus uses gRPC under the hood, and gRPC calls are blocking by default. When collection.search() is called from within an async route handler, it blocks the entire asyncio event loop, no other requests can be served until that call completes.
The fix is to wrap the synchronous pymilvus calls in asyncio.to_thread() (Python 3.9+), offloading the blocking I/O to a thread pool:
If Issue #28's connection pooling fix is also applied, initializing the collection object once at startup, then asyncio.to_thread wraps the search call without paying a fresh TCP handshake penalty each time.
This matters especially for the agentic architecture planned for GSoC. An agent making 5-10 tool calls in a single user turn would fully serialize under the current implementation. Combining these two fixes would significantly reduce per-query latency.
Happy to submit a PR for this if the asyncio.to_thread approach looks good to maintainers. Is there a reason to prefer a different executor pattern here?
Activity
GunaPalanivel commentedon Feb 28, 2026
I'll be working on this — tracking issue filed as part of my #72 pre-work. PR incoming.
fix(server): Offload blocking PyMilvus calls to thread pool to unfree…
ibrahimalee commentedon Mar 31, 2026
Hi, I'm a GSoC 2026 applicant reviewing the docs-agent codebase for my proposal on Project 1 (Agentic RAG).
I noticed this issue while going through the server code. The core problem is that pymilvus uses gRPC under the hood, and gRPC calls are blocking by default. When collection.search() is called from within an async route handler, it blocks the entire asyncio event loop, no other requests can be served until that call completes.
The fix is to wrap the synchronous pymilvus calls in asyncio.to_thread() (Python 3.9+), offloading the blocking I/O to a thread pool:
results = await asyncio.to_thread(collection.search, ...)
If Issue #28's connection pooling fix is also applied, initializing the collection object once at startup, then asyncio.to_thread wraps the search call without paying a fresh TCP handshake penalty each time.
This matters especially for the agentic architecture planned for GSoC. An agent making 5-10 tool calls in a single user turn would fully serialize under the current implementation. Combining these two fixes would significantly reduce per-query latency.
Happy to submit a PR for this if the asyncio.to_thread approach looks good to maintainers. Is there a reason to prefer a different executor pattern here?
chasecadet commentedon Nov 20, 2026
Thank you for reporting this!
We are closing pre-restructure issues targeting the legacy
server/,server-https/,manifests/,kagent-feast-mcp/, or in-processSentenceTransformerprototype code. In #207, #210, #233, #240, and #249,kubeflow/docs-agentmigrated 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
mainstack, please feel free to open a new issue using the current issue templates.