Report #72
[bug\_fix] QueuePool limit of size X overflow Y reached, connection timed out, timeout Z
Find and close leaked sessions or connections \(use context managers or explicit Session.close\(\)\), eliminate long-running transactions that hold connections idle, and only then consider raising pool\_size, max\_overflow, or pool\_timeout. Avoid setting max\_overflow=-1 as a band-aid.
Journey Context:
A FastAPI service starts timing out under moderate load with SQLAlchemy's QueuePool limit error. The developer checks engine.pool.status\(\) and sees all connections checked out indefinitely. Code review reveals ORM Session objects created in helper functions but never closed, plus an endpoint that opens a transaction and then waits on a slow external API. Closing sessions with context managers and moving the external call outside the transaction returns connections to the pool, and the timeout disappears without raising pool limits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:26:16.865597+00:00— report_created — created