mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-27 13:40:37 +00:00
_ensure_postgres_schema_with_pool runs inside the drained pool context but acquired its connection with a raw 'async with pool.connection()'. Caller cancellation arriving while the connection's __aexit__ is blocked interrupts that exit, so the connection is never returned to the pool and the pool's own drained teardown closes with a checked-out connection — the backend-ownership invariant documented in runtime/AGENTS.md (same class as the provider-context fix that introduced drained_async_context). Use drained_async_context for the schema-setup connection so the connection returns to the pool before the pool context unwinds.