idle in transaction
The state pg_stat_activity reports for a session that has run a BEGIN, is holding the transaction open, and is running nothing at all. It uses no CPU and appears on no load graph, which is why it reads as harmless. It is the most expensive state on the server. It keeps the locks it acquired, and autovacuum cannot remove a dead row still visible to a transaction older than itself: one session forgotten over an afternoon is enough to bloat a whole database while load sits at zero. The origin is nearly always in the application — a BEGIN, a network call to a third-party service, and a COMMIT that never arrives because the call timed out. Sort pg_stat_activity by now() - query_start descending: the oldest row is the cause, the rest are its victims. Try pg_cancel_backend before pg_terminate_backend, which severs the connection.
Also written: idle_in_transaction, idle in transaction (aborted)
