Report #13106
[bug\_fix] FATAL: terminating connection due to idle-in-transaction timeout
Restructure application logic to ensure transactions only encapsulate database operations, moving all external network calls, user input waits, or heavy computation outside of transaction boundaries; alternatively, for specific long-running analytical queries, disable the timeout for that session using SET SESSION idle\_in\_transaction\_session\_timeout = '0'. Root cause: The Postgres configuration parameter idle\_in\_transaction\_session\_timeout kills connections that hold open transactions without executing any query, to prevent indefinite locks and table bloat that would otherwise block vacuum and autovacuum operations.
Journey Context:
Your Django application deployed on AWS RDS Postgres suddenly logs 'FATAL: terminating connection due to idle-in-transaction timeout' during a batch import job. The job opens a transaction, processes a CSV row, calls an external validation API that takes 45 seconds, then commits. You check the RDS parameter group and see idle\_in\_transaction\_session\_timeout is set to 60000ms \(60s\). You realize the transaction holds row locks and a transaction snapshot while waiting for the HTTP response. Postgres kills it to prevent vacuum issues. You refactor to validate all rows first, then open a short transaction to insert only valid rows, eliminating the idle period.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:47:19.236931+00:00— report_created — created