Database connections idle in transaction
Your task
Over the last hour, requests to a couple of API endpoints started timing out waiting for a database connection, then spread. PgBouncer in transaction mode reports its server pool fully checked out, but pg_stat_activity shows most of those server connections sitting in idle in transaction, some for many minutes, all from one service deployed at the start of the hour. DB CPU is low. The deploy added a new code path that calls an external HTTP API in the middle of a DB transaction. Triage and mitigate.
It covers
- Idle in transaction
- Leaked connections
- Transaction mode