open-webui/backend/open_webui
Classic298 d0c2bfdbff
fix(db): release connection before LLM call in OpenAI /chat/completions (#20572)
Remove Depends(get_session) from the /chat/completions endpoint to prevent database connections from being held during the entire duration of LLM calls (30-60+ seconds for streaming responses).

Previously, the database session was acquired at request start and held until the streaming response completed. Under concurrent load, this exhausted the connection pool, causing QueuePool timeout errors for other database operations.

The fix allows Models.get_model_by_id() and has_access() to manage their own short-lived sessions internally, releasing the connection immediately after the quick authorization checks complete - before the slow external LLM API call begins.
2026-01-11 23:34:11 +04:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac/fix: DATABASE_ENABLE_SESSION_SHARING env var 2026-01-10 00:16:04 +04:00
migrations feat: chat_file table 2025-12-21 23:17:53 +04:00
models chore: format 2026-01-09 20:44:31 +04:00
retrieval chore: format 2026-01-09 22:27:53 +04:00
routers fix(db): release connection before LLM call in OpenAI /chat/completions (#20572) 2026-01-11 23:34:11 +04:00
socket chore: format 2026-01-08 01:55:56 +04:00
static refac 2025-08-10 00:02:58 +04:00
storage chore/perf: Remove old SRC level log env vars with no impact (#20045) 2025-12-20 08:16:14 -05:00
test rm: outdated tests 2025-12-28 23:35:09 +04:00
tools chore: format 2026-01-09 22:27:53 +04:00
utils refac 2026-01-11 00:52:43 +04:00
__init__.py Update __init__.py 2025-04-15 09:55:35 +02:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py enh: WHISPER_MULTILINGUAL 2026-01-09 19:42:13 +04:00
constants.py feat/enh: optional password validation 2025-11-20 17:44:49 -05:00
env.py refac/fix: DATABASE_ENABLE_SESSION_SHARING env var 2026-01-10 00:16:04 +04:00
functions.py chore/perf: Remove old SRC level log env vars with no impact (#20045) 2025-12-20 08:16:14 -05:00
main.py enh: WHISPER_MULTILINGUAL 2026-01-09 19:42:13 +04:00
tasks.py chore/perf: Remove old SRC level log env vars with no impact (#20045) 2025-12-20 08:16:14 -05:00