Idle-in-Transaction Detection

Find leaking connections.

Overview

Idle-in-transaction is the PostgreSQL state where a connection has begun a transaction but is doing nothing while holding locks and table snapshots. Caught early, it is a one-line application fix; left alone, it becomes a database-wide cascade.

The approach

Three habits keep idle-in-transaction under control: monitor pg_stat_activity, set the server-side timeout, and fix the application-side connection-pool bug.

Why this compounds

Each caught leak prevents one cascade-incident class. The team learns the pattern through repeated detection; new applications ship with the timeout from day one.