mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-26 17:30:27 -04:00
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.
This commit is contained in:
@@ -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]]
|
||||
|
||||
Reference in New Issue
Block a user