Report #75
[bug\_fix] idle in transaction sessions causing lock contention and table bloat
Set idle\_in\_transaction\_session\_timeout \(for example, 10000 ms\) so Postgres terminates sessions left idle inside a transaction for too long, and refactor code to commit or rollback as soon as a unit of work finishes. Monitor pg\_stat\_activity for 'idle in transaction'.
Journey Context:
A PostgreSQL instance starts accumulating 'idle in transaction' connections from a web API that begins a transaction, calls a slow external service, and only then commits. These idle sessions hold locks and block autovacuum, causing table bloat and occasional deadlocks. The DBA sets idle\_in\_transaction\_session\_timeout to terminate such sessions after a short grace period, and the team refactors the endpoint to open the transaction only when it is actually ready to write. pg\_stat\_activity no longer shows long-running idle transactions and bloat stabilizes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:27:15.482577+00:00— report_created — created