mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 06:03:26 -05:00
[PR #20545] [MERGED] fix: release database connections immediately after auth instead of holding during LLM calls #129321
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/20545
Author: @Classic298
Created: 1/10/2026
Status: ✅ Merged
Merged: 1/10/2026
Merged by: @tjbck
Base:
dev← Head:db-perf📝 Commits (1)
a18252ffix: release database connections immediately after auth instead of holding during LLM calls📊 Changes
1 file changed (+10 additions, -8 deletions)
View changed files
📝
backend/open_webui/utils/auth.py(+10 -8)📄 Description
fix: release database connections immediately after auth instead of holding during LLM calls
Authentication was using Depends(get_session) which holds a database connection for the entire request lifecycle. For chat completions, this meant connections were held for 30-60 seconds while waiting for LLM responses, despite only needing the connection for ~50ms of actual database work.
With a default pool of 15 connections, this limited concurrent chat users to ~15 before pool exhaustion and timeout errors:
The fix removes Depends(get_session) from get_current_user. Each database operation now manages its own short-lived session internally:
This is safe because:
Combined with the telemetry efficiency fix, this resolves connection pool exhaustion for high-concurrency deployments, particularly on network-attached databases like AWS Aurora where connection hold time is more impactful.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.