# sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30.00

- **ID:** `python/fastapi-db-session-not-closed`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Dependency yields a DB session but never closes it on exceptions, leaking connections until the pool is exhausted.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 0.100+ | active | — | — |

## Workarounds

1. **** (97% success)
   ```
   def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()
   ```
2. **** (96% success)
   ```
   def get_db():
    with SessionLocal() as db:
        yield db
   ```

## Dead Ends

- **** — Delays exhaustion; underlying leak persists. (80% fail)
- **** — Detects dead connections, does not free leaked ones. (85% fail)
