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. |
||
|---|---|---|
| .. | ||
| builtin | ||
| __init__.py | ||
| base.py | ||
| context.py | ||
| http.py | ||
| loader.py | ||
| mcp.py | ||
| operation_validator.py | ||
| tenant.py | ||