fleet-memory/hindsight-api/hindsight_api/extensions
Nicolò Boschi e0a2ac63e7
fix: run schema migrations in thread to prevent event loop deadlock (#500)
When a new tenant schema is provisioned while retain/recall operations
are in-flight, run_migration() was calling synchronous migration
functions directly on the asyncio event loop. These functions execute
CREATE INDEX CONCURRENTLY, which waits for all active transactions to
commit. But in-flight asyncpg transactions cannot flush their COMMIT
because the event loop is blocked — deadlock.

Fix: wrap all four sync migration calls in asyncio.to_thread() so they
run in the thread pool, keeping the event loop free.

Reproduced with the unfixed code: test_retain_memory timed out with
httpx.ReadTimeout when run concurrently with test_create_tenant.
All 75 integration tests pass after the fix.
2026-03-05 17:19:51 +01:00
..
builtin doc: prepare doc for 0.4.10 (#325) 2026-02-09 11:42:37 +01:00
__init__.py Add bank-scoped validation to engine and HTTP handlers (#454) 2026-03-02 09:55:21 +01:00
base.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
context.py fix: run schema migrations in thread to prevent event loop deadlock (#500) 2026-03-05 17:19:51 +01:00
http.py feat: add extension hooks for root routing and error headers (#470) 2026-03-03 10:50:03 +01:00
loader.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
mcp.py feat: add TenantExtension auth to MCP endpoint (#286) 2026-02-06 12:28:05 -07:00
operation_validator.py Add bank-scoped validation to engine and HTTP handlers (#454) 2026-03-02 09:55:21 +01:00
tenant.py feat: add extension hooks for root routing and error headers (#470) 2026-03-03 10:50:03 +01:00