select open change scope Open full search

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

SQLSTATE / CLASS 57 · OPERATOR INTERVENTION

admin_shutdown

SQLSTATE
57P01
Condition name
admin_shutdown
Class
Operator Intervention
Source macro
ERRCODE_ADMIN_SHUTDOWN
Evidence
Observed at runtime in the source evidence
Analysis & operational context

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

<h1>57P01</h1>

At a glance

57P01 is a server-initiated administrative-shutdown condition. Fixed core paths cover orderly or immediate client termination, worker/parallel termination, and a synchronous-replication wait that explicitly says the transaction has already committed locally but might not have been replicated to the standby.

Meaning

The SQLSTATE is reused at several lifecycle boundaries, so severity and recovery depend on the call site. The immediate-stop signal path sends a client-only WARNING and then exits without normal cleanup; the ordinary client administrator-command path uses FATAL. The synchronous-replication path uses WARNING and includes the detail The transaction has already committed locally, but might not have been replicated to the standby. That warning is followed by connection termination. Parallel and worker paths use their own FATAL or worker control flow. These are not interchangeable statements about whether a business operation committed.

Messages

  • Immediate stop: primary terminating connection due to immediate shutdown command, severity WARNING_CLIENT_ONLY; the process exits after reporting.
  • Client backend administrator command: primary terminating connection due to administrator command, severity FATAL; the connection closes.
  • Synchronous replication wait: primary canceling the wait for synchronous replication and terminating connection due to administrator command, severity WARNING, detail The transaction has already committed locally, but might not have been replicated to the standby.
  • Parallel transaction: primary postmaster exited during a parallel transaction, severity FATAL.
  • Another fixed promotion wait branch reports terminating connection due to unexpected postmaster exit at FATAL with context while waiting on promotion.

Diagnosis

Correlate the complete primary/detail/context, backend PID, administrator or postmaster action, server shutdown/recovery log, and transaction boundary. The selected runtime case covers only the client-backend administrator-command branch. It does not prove the immediate-stop, synchronous-replication, worker, parallel, or promotion outcomes. When the synchronous-replication detail appears, the transaction has already committed locally while remote standby replication is uncertain; query durable state and replication status before replaying a non-idempotent operation. The warning path still terminates the connection, so the old session cannot be used for recovery.

Response

For a FATAL or client-only shutdown report, the connection is not a transaction recovery point: wait for readiness, open a fresh connection, and inspect durable business state or an idempotency key before retrying. For the synchronous-replication branch, preserve the warning, record that local commit has already occurred, and determine standby receipt separately; the connection is still terminated after the warning. Do not assume any 57P01 path leaves a live session for recovery. The accepted case's fresh SELECT 1 proves readiness after terminating the targeted victim, not that an interrupted business operation committed.

Observed diagnostics

The selected registry created a runner-owned victim client backend, a distinct administrator session, and a fresh session on PostgreSQL 18.6 and 10.21. The admin verified the target identity and pg_terminate_backend returned true. The victim driver reported FATAL / 57P01 with terminating connection due to administrator command and closed; the fresh session returned 1 and was IDLE. This bounded case does not cover the other source branches or business commit outcome.

Representative case

Use only the PID returned by the case-created victim session; never substitute an arbitrary production PID or the administrator's own PID. The fresh probe verifies server reachability after the targeted termination. Check durable business state or an idempotency key before replaying a non-idempotent request.

-- victim session created by the case runner
SELECT pg_backend_pid();  -- save as :victim_pid
SELECT 1;                 -- probe before termination

-- admin session; record its own PID, then use only the runner-created victim PID
SELECT pg_backend_pid(); -- save as :admin_pid
SELECT pid, backend_type FROM pg_stat_activity WHERE pid = backend_pid;
SELECT pg_terminate_backend(backend_pid);

-- fresh session after the victim disconnects
SELECT 1;

Versions

The locked catalogue records this condition from 7.4; that catalogue boundary does not prove the exact implementation-introduction version. Fixed source coverage is PostgreSQL 18.6, with the selected runtime case also observed on PostgreSQL 10.21.

Sources

src/backend/tcop/postgres.c#L2974-3001

src/backend/tcop/postgres.c#L3354-3356

src/backend/replication/syncrep.c#L283-305

src/backend/access/transam/parallel.c#L932-940

src/backend/access/transam/xlogfuncs.c#L737-741

The structured evidence record records fixed branches and the bounded runtime case.

Source evidence

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

57P01 is admin_shutdown 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 src.path.3 src.path.4

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

Method: Use catalogue boundary.

src.errcodes.18.6

The admin_terminate_backend case passed on PostgreSQL 18.6 and 10.21 with SQLSTATE, severity or disconnect outcome, recovery/repair, cleanup, and isolated-target stop assertions.

Method: Execute the shared registry and inspect the selected summaries.

Limits: This is one bounded mechanism; it does not establish every source branch or business outcome.

runtime.ops-57p01-latest-2.latest runtime.ops-57p01-pg10-1.pg10 manifest.57P01 snippet-registry.57P01

Message templates

WARNING_CLIENT_ONLY (client-visible warning; process exits after reporting) · message.0

Primary

terminating connection due to immediate shutdown command
FATAL · message.1

Primary

terminating connection due to administrator command
WARNING · message.2

Primary

canceling the wait for synchronous replication and terminating connection due to administrator command

Detail

The transaction has already committed locally, but might not have been replicated to the standby.
FATAL · message.3

Primary

postmaster exited during a parallel transaction
FATAL · message.4

Primary

terminating connection due to unexpected postmaster exit

Context

while waiting on promotion

Reproduction & repair cases

admin_terminate_backend · PG 10, 18

Preconditions

  • A runner-owned disposable target is provisioned.
  • The victim PID is obtained from the connection being terminated.

Trigger: Create a runner client session, terminate only its backend PID from a separate runner session, and reconnect.

Expected assertions

  • The terminated backend reports SQLSTATE 57P01 and FATAL administrator-command text
  • The selected PID is verified as a runner-created client backend and differs from the admin PID
  • The victim connection closes after termination
  • A fresh runner connection executes SELECT 1 successfully

Repair: Treat the old connection as unusable after administrator termination; inspect the operation outcome and establish a fresh connection before continuing.

Cleanup: Close all runner connections and drop the case schema with an owner connection.

Recorded runtime evidence

18.6 (Homebrew) · passed

Run: ops-57p01-latest-2

{
  "admin_pid": "distinct admin PID",
  "victim_pid": "runner-created victim PID",
  "fresh_probe": 1,
  "admin_status": "IDLE",
  "fresh_status": "IDLE",
  "backend_identity": [
    "runner-created victim",
    "client backend"
  ],
  "terminate_result": true,
  "driver_diagnostic": {
    "text": "terminating connection due to administrator command",
    "context": null,
    "severity": "FATAL",
    "sqlstate": "57P01",
    "table_name": null,
    "column_name": null,
    "schema_name": null,
    "source_file": "postgres.c",
    "source_line": "3356",
    "message_hint": null,
    "datatype_name": null,
    "exception_type": "AdminShutdown",
    "internal_query": null,
    "message_detail": null,
    "constraint_name": null,
    "message_primary": "terminating connection due to administrator command",
    "source_function": "ProcessInterrupts",
    "internal_position": null,
    "statement_position": null,
    "severity_nonlocalized": "FATAL"
  },
  "termination_scope": "Only the runner-created client backend PID was targeted; the target postmaster and unrelated sessions were not targeted.",
  "victim_probe_before": 1,
  "victim_connection_closed": true
}
10.21 (Debian 10.21-1.pgdg90+1) · passed

Run: ops-57p01-pg10-1

{
  "admin_pid": "distinct admin PID",
  "victim_pid": "runner-created victim PID",
  "fresh_probe": 1,
  "admin_status": "IDLE",
  "fresh_status": "IDLE",
  "backend_identity": [
    "runner-created victim",
    "client backend"
  ],
  "terminate_result": true,
  "driver_diagnostic": {
    "text": "terminating connection due to administrator command",
    "context": null,
    "severity": "FATAL",
    "sqlstate": "57P01",
    "table_name": null,
    "column_name": null,
    "schema_name": null,
    "source_file": "postgres.c",
    "source_line": "2931",
    "message_hint": null,
    "datatype_name": null,
    "exception_type": "AdminShutdown",
    "internal_query": null,
    "message_detail": null,
    "constraint_name": null,
    "message_primary": "terminating connection due to administrator command",
    "source_function": "ProcessInterrupts",
    "internal_position": null,
    "statement_position": null,
    "severity_nonlocalized": "FATAL"
  },
  "termination_scope": "Only the runner-created client backend PID was targeted; the target postmaster and unrelated sessions were not targeted.",
  "victim_probe_before": 1,
  "victim_connection_closed": true
}

Definition snapshot: english-manuals:ca00d36e7b3dae7977b4af2b74d… · English manual source