Diagnostic Queries
Symptoms
A session was terminated because it sat idle inside an open transaction longer than idle_in_transaction_session_timeout. PostgreSQL raises SQLSTATE 25P03 (idle_in_transaction_session_timeout).
- An open transaction was idle too long.
- PostgreSQL terminated the connection to release locks/resources.
- Common with apps that BEGIN and then stall.
What the server log shows
FATAL: terminating connection due to idle-in-transaction timeout
Why PostgreSQL raises this — what the manual says
Section 19.11.1 Statement Behavior (idle_in_transaction_session_timeout):
“Terminate any session that has been idle (that is, waiting for a client query) within an open transaction for longer than the specified amount of time.”
Idle-in-transaction sessions hold locks and pin old row versions, harming vacuum and concurrency. To protect the system, PostgreSQL terminates sessions idle beyond the timeout and reports 25P03.
Common causes
- Application
BEGINfollowed by long inactivity. - A transaction left open awaiting user/external input.
- Connection-pool bugs leaving transactions open.
Relevant GUC parameters
| Parameter | Default | Effect |
|---|---|---|
idle_in_transaction_session_timeout |
0 | Terminate sessions idle in a transaction beyond this; 0 disables. |
How to fix it
- Commit/rollback promptly; avoid keeping transactions open during waits.
- Fix the application/pool to not leave idle transactions.
- Tune the timeout to match legitimate transaction durations.
Related & next steps
Reference: PostgreSQL 18 Section 20.10 “Client Connection Defaults”.
Thanks — noted. This helps keep the database accurate.