Q&A
Q&AWhy is one global SQLAlchemy Session unsafe in an async FastAPI service?
A Session carries mutable identity-map and transaction state and is not safe for concurrent requests.
Read the concise answer
Concurrent coroutines can interleave operations on the same Session, mixing transaction state and identity-map contents. Create a session per request or task, scope its transaction clearly, and size the connection pool across all worker processes and replicas. A global Engine/pool is different from a shared mutable Session.