mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[PR #23706] [MERGED] fix(retrieval): offload sync VECTOR_DB_CLIENT calls in async paths via AsyncVectorDBClient #82198
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23706
Author: @Classic298
Created: 4/14/2026
Status: ✅ Merged
Merged: 4/14/2026
Merged by: @tjbck
Base:
dev← Head:claude/fix/async-vector-db-client📝 Commits (4)
7d865dbfix(retrieval): offload sync VECTOR_DB_CLIENT calls in async paths via AsyncVectorDBClientb563d4afix(retrieval): restore explicit AsyncVectorDBClient signatures matching VectorDBBase3ebc2b0fix(retrieval): parallelize hybrid-search collection prefetch; document async facade contracts4a9bd01fix(retrieval): guard /delete against null file.hash and let HTTPException reach the client📊 Changes
7 files changed (+232 additions, -50 deletions)
View changed files
📝
backend/open_webui/retrieval/utils.py(+25 -10)➕
backend/open_webui/retrieval/vector/async_client.py(+135 -0)📝
backend/open_webui/routers/files.py(+6 -6)📝
backend/open_webui/routers/knowledge.py(+14 -14)📝
backend/open_webui/routers/memories.py(+8 -8)📝
backend/open_webui/routers/retrieval.py(+40 -8)📝
backend/open_webui/tools/builtin.py(+4 -4)📄 Description
The vector DB backends (Chroma, pgvector, Qdrant, Milvus, Pinecone, Weaviate, …) are uniformly synchronous and their methods perform blocking network or disk I/O. Multiple async route handlers and helpers were calling them directly on the event loop — file processing, memories, knowledge bases, hybrid search bookkeeping — so a single upsert/delete/search would freeze every other in-flight request for the duration of the call.
Introduce
AsyncVectorDBClient, a thin async facade that wraps the existing sync client and dispatches each method throughasyncio.to_thread. It mirrorsVectorDBBaseexactly and forwards *args/**kwargs so backend-specific extra parameters keep working.Update every async-context call site (routers/retrieval, routers/files, routers/memories, routers/knowledge, retrieval/utils, tools/builtin) to await
ASYNC_VECTOR_DB_CLIENTinstead of calling the sync client directly. Two helpers that were sync-only also acquire async siblings or are awaited viaasyncio.to_threadat their async call site (remove_knowledge_base_metadata_embedding,get_all_items_from_collections,query_doc).The original sync
VECTOR_DB_CLIENTis unchanged, so callers that already run insiderun_in_threadpool(e.g.save_docs_to_vector_dband the syncquery_doc/get_dochelpers) are unaffected.Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.