Report #57002
[bug\_fix] FATAL: terminating connection due to idle-in-transaction timeout \(Postgres\)
Configure \`idle\_in\_transaction\_session\_timeout\` in postgresql.conf \(e.g., '5min'\) to automatically kill connections holding transactions open without work. Application fix: ensure transactions are committed or rolled back before calling external services or long computations.
Journey Context:
An e-commerce platform experiences sporadic outages where no new checkouts can proceed; queries hang indefinitely. Investigation shows \`pg\_stat\_activity\` reveals one connection in state \`idle in transaction\` for 45 minutes, with \`wait\_event\_type\` showing it holds a row lock on the inventory table. Tracing the application logs reveals a developer added a \`BEGIN; SELECT ... FOR UPDATE\` at the start of the checkout flow, then called an external payment API that took 2 minutes to respond before the \`COMMIT\`. During this time, the transaction held locks, blocking all other checkouts. Setting \`idle\_in\_transaction\_session\_timeout = '60s'\` in Postgres config causes the database to automatically terminate the rogue backend after 60 seconds of idleness, releasing the locks and logging an error that helps developers identify the code path missing a commit/rollback.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:09:58.399311+00:00— report_created — created