open-webui/backend/open_webui
Claude a03bde4701
fix(db): tighten aiosqlite terminate-shim install scope and worker wake-up
Address PR review findings on the original shim:

1. Source-shape gating (avoid shadowing future upstream fixes)
   The install now inspects the original implementation source and
   only patches when it actually references `self._connection.stop` —
   the buggy pattern this shim exists to fix. If a newer SQLAlchemy
   ships a working `_terminate_force_close` we leave it alone.

2. Wake the aiosqlite worker, don't just flag it
   In aiosqlite ≥0.20 the worker thread blocks on `_tx.get()`. Setting
   `_running = False` alone never unblocks it — the queue needs a
   sentinel push for the loop to observe the flag. The replacement
   now puts `(None, None)` onto `_tx` first and then flips
   `_running`, so the worker exits promptly instead of relying on a
   subsequent unrelated queue item or GC.

3. Conditional install (no global mutation on non-sqlite deployments)
   Move `_install_aiosqlite_compat()` inside the
   `if 'sqlite' in ASYNC_SQLALCHEMY_DATABASE_URL` branch in
   `internal/db.py`, so PostgreSQL / MySQL / etc. deployments get no
   SQLAlchemy monkey-patch at all.

https://claude.ai/code/session_01JSr4NZSskEUQvoJnavVXh8
2026-04-14 12:41:35 +00:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal fix(db): tighten aiosqlite terminate-shim install scope and worker wake-up 2026-04-14 12:41:35 +00:00
migrations refac 2026-04-01 18:26:46 -05:00
models refac 2026-04-13 21:29:03 -05:00
retrieval refac 2026-04-13 16:03:36 -05:00
routers refac 2026-04-13 21:29:03 -05:00
socket fix: invalidate stale Socket.IO sessions on role change and user deletion (#23642) 2026-04-12 16:19:38 -05:00
static refac 2026-03-23 23:39:52 -05:00
storage refac 2026-04-12 19:08:30 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools chore: format 2026-04-12 22:11:10 -05:00
utils refac 2026-04-14 01:17:39 -05:00
__init__.py refac (#22987) 2026-03-24 15:41:26 -05:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-04-14 00:07:50 -05:00
constants.py refac 2026-04-13 14:08:58 -05:00
env.py refac 2026-04-13 16:25:44 -05:00
functions.py refac: async db 2026-04-12 14:22:11 -05:00
main.py refac 2026-04-14 00:07:50 -05:00
tasks.py refac 2026-03-17 17:58:01 -05:00