SQLSTATE 25P03Severity mediumLab verified

Incident brief

Idle in transaction session timeout

A session left an open transaction sitting idle (no query in flight) for longer than idle_in_transaction_session_timeout. PostgreSQL terminated the connection instead of letting it hold locks and a snapshot indefinitely.

Reproduced on PostgreSQL 16.14Verified 2026-07-16 (Docker lab, PostgreSQL 16.14)Reviewed by Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What
Idle in transaction session timeout
What triggers it
SET idle_in_transaction_session_timeout to a short value.
The fix
Don't leave a BEGIN open while waiting on something outside the database (user input, an external API call). Commit or roll back first, then reopen a transaction when you're ready to continue.
Proof
Reproduced on PostgreSQL 16.14 → A transaction left genuinely idle (no query sent, only a client-side pause) past the configured timeout was terminated by the server with SQLSTATE 25P03.

The fix

What to do right now

The immediate, application-level response to this error.

  • Don't leave a BEGIN open while waiting on something outside the database (user input, an external API call). Commit or roll back first, then reopen a transaction when you're ready to continue.
  • Set idle_in_transaction_session_timeout as a safety net so a forgotten open transaction can't hold locks and an old snapshot forever.
Fix — SQL
-- application pattern: don't hold BEGIN open across an external wait
COMMIT; -- release the transaction before waiting on something external
-- ... do the external work here, outside any transaction ...
BEGIN;  -- reopen only when ready to continue

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 16.14
Last verified
2026-07-16 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed