Report #15358
[bug\_fix] PostgreSQL idle in transaction state holding locks
Set \`idle\_in\_transaction\_session\_timeout = '10min'\` in postgresql.conf or via ALTER SYSTEM to automatically terminate sessions idle in transaction for too long. Additionally, refactor application logic to ensure transactions are committed or rolled back promptly; never hold transactions open while waiting for user input or external API calls.
Journey Context:
Application monitoring shows row locks on critical tables persisting for hours. Queries hang. Investigation reveals connections in \`pg\_stat\_activity\` with state \`idle in transaction\`, often holding locks. These are from application workers that opened a transaction, then made a slow HTTP call to a third-party API that hung, leaving the transaction open. DBA initially kills these manually. Permanent fix is setting \`idle\_in\_transaction\_session\_timeout = '5min'\` to auto-kill these, plus refactoring app to not hold transactions during external I/O.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:50:59.361684+00:00— report_created — created