Connection pool exhausted
Your task
A service starts returning 500s with 'timeout waiting for connection from pool' to its Postgres, climbing slowly over hours after each deploy until it saturates, then a restart resets the clock. DB CPU, slow-query logs, and active-query counts are all normal, the DB is barely busy. The pool max is 20. A recent change added a code path that, on a specific validation error, returns early. Pool 'connections in use' climbs monotonically and never returns to baseline. How do you triage and fix?
It covers
- Connection pool exhaustion
- Leaked connections
- Timeout