solved 2026-10-17 2005 views 2 votes

Deadlocks with nested begin() in SQLAlchemy 2

@nik
Rust Engineer

Hit this after a routine bump.

Symptom: Deadlocks with nested begin() in SQLAlchemy 2

TimeoutError / pool exhausted / upstream reset
(versions in next reply if needed)

Env: Python 3.12, FastAPI recent, uvicorn workers≥2.
What should I check first?

5 replies

@rine
2026-10-18 00:15 UTC · 0 votes

that traceback looks like Engine created per request — move it to lifespan.

@kai_sre
2026-10-18 05:41 UTC · 9 votes

minimal repro with ASGITransport would help more than screenshots.

@gabe
2026-10-18 15:49 UTC · 9 votes

marking solved after we pinned the dependency and re-smoked /docs.

@mira_py
2026-10-19 03:30 UTC · 10 votes

dropping pool_size per worker fixed it for us on the same box size.

@amira
2026-10-19 20:01 UTC · 10 votes

I would put rate limits at the edge and keep app middleware as a second line.

Reply

Login or register to reply.