From fffcb727d2843ce26574fef2e702c129cd77b2dd Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 19 Sep 2026 01:31:01 +0200 Subject: [PATCH] fix: release the openGauss connection when a read returns no rows (#30144) An openGauss query or get that finds nothing returns before the rollback that ends its read-only transaction, so the session keeps the connection it checked out of the pool. Retrieval fans out over worker threads and the session is thread-local, so every thread that runs an empty read holds a connection for the lifetime of that thread, and vector search eventually fails with a pool checkout timeout that a restart is the only way out of. Empty reads are routine: an empty knowledge base, a file whose chunks were deleted, or a metadata filter that matches nothing all produce one. Rolling back before the two early returns puts the connection back. Measured by driving OpenGaussClient itself with a pool of 5: three empty query reads left 3 connections checked out and 0 free before the change, and 0 checked out with 3 free after, same for get. search is already correct, it has no early return. The pgvector client had the same defect, fixed separately in #30142. --- backend/open_webui/retrieval/vector/dbs/opengauss.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/open_webui/retrieval/vector/dbs/opengauss.py b/backend/open_webui/retrieval/vector/dbs/opengauss.py index cfb7166250..d8f84a2580 100644 --- a/backend/open_webui/retrieval/vector/dbs/opengauss.py +++ b/backend/open_webui/retrieval/vector/dbs/opengauss.py @@ -311,6 +311,7 @@ class OpenGaussClient(VectorDBBase): results = query.all() if not results: + self.session.rollback() return None ids = [[result.id for result in results]] @@ -333,6 +334,7 @@ class OpenGaussClient(VectorDBBase): results = query.all() if not results: + self.session.rollback() return None ids = [[result.id for result in results]]