select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 57 · OPERATOR INTERVENTION

idle_session_timeout

SQLSTATE
57P05
Condition name
idle_session_timeout
Class
Operator Intervention
Source macro
ERRCODE_IDLE_SESSION_TIMEOUT
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>57P05</h1>

At a glance

57P05 terminates a session after idle_session_timeout expires while the backend is truly idle between commands. The fixed code starts this timer only in the no-transaction branch; idle-in-transaction has a separate condition and timer.

Meaning

The fixed primary is terminating connection due to idle-session timeout at FATAL. In PostgresMain, the idle-session timer is enabled after the backend reports STATE_IDLE and only in the branch where IsTransactionOrTransactionBlock() is false. The timer is disabled as soon as a command is read. This makes 57P05 a session-lifecycle termination, distinct from statement timeout 57014, lock timeout 55P03, idle-in-transaction timeout 25P03, and transaction timeout 25P04.

Messages

  • Primary: terminating connection due to idle-session timeout.
  • Severity: FATAL; the timer interrupt terminates the connection rather than returning a recoverable statement ERROR.
  • Boundary: a truly idle session between commands uses 57P05; a session idle inside an open transaction uses the separate idle-in-transaction timer/condition.

Diagnosis

Capture the primary, backend PID, idle_session_timeout value and source, last command, pg_stat_activity state, transaction status, and server log. Verify whether the session was idle or idle in transaction when the timer started. Elapsed client request time alone cannot distinguish this from statement or lock timeout, and the SQLSTATE should be interpreted with the connection's last ReadyForQuery state.

Response

Close or recreate the expired connection and make long-lived work explicit rather than holding an unused session. Adjust idle_session_timeout only when policy permits and the workload needs it. Because FATAL closes the connection, there is no useful ROLLBACK command to send on that session; after reconnecting, verify durable effects before replaying a non-idempotent command. If the workload was idle in a transaction, diagnose 25P03/25P04 and transaction ownership separately.

Versions

The locked catalogue records this condition from 14.0; that boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6.

Sources

src/backend/tcop/postgres.c#L3504-3513

src/backend/tcop/postgres.c#L4585-4650

src/backend/tcop/postgres.c#L4704-4721

The structured evidence record records the message and idle-state boundary.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

57P05 is idle_session_timeout in SQLSTATE Class 57.

Method: Read fixed definition.

src.errcodes.18.6

The cited PostgreSQL 18.6 source paths support the concrete phase, message, and lifecycle boundary described.

Method: Read complete fixed source contexts.

Limits: Source confirmation is not natural runtime.

src.path.0 src.path.1 src.path.2

The locked catalogue records 57P05 from 14.0; that boundary does not prove exact implementation introduction.

Method: Use catalogue boundary.

src.errcodes.18.6

The idle-session timer starts only in the no-transaction STATE_IDLE branch and is disabled when input arrives; idle-in-transaction uses a separate timer and condition.

Method: Read the complete PostgresMain state branches and timeout disable path.

src.path.1 src.path.2

Message templates

FATAL · message.0

Primary

terminating connection due to idle-session timeout

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Version history 1
  1. PG 13 → 14added

Definition snapshot: english-manuals:9caff5ef859b2856572a29240e4… · English manual source