选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

文档 / SQL 状态码 / Class 57 操作员干预

57P02 crash_shutdown

ERROR 源码确认 参考 未实测

类别
Class 57 操作员干预
严重等级
ERROR
条件名
crash_shutdown
宏名称
ERRCODE_CRASH_SHUTDOWN
启用版本
7.4
状态
活跃

版本覆盖

速览

57P02 是 crash-shutdown 路径。crash-and-restart 周期开始时,backend 向客户端发送 client-only WARNING,说明 postmaster 命令其回滚并退出;随后由于共享内存可能已损坏,进程不运行正常清理回调而退出。

含义

固定 primary 是 terminating connection because of crash of another server process。detail 说明 postmaster 因另一个服务器进程异常退出、可能破坏共享内存,而命令当前 server process 回滚并退出;hint 建议稍后重连。源码使用 WARNING_CLIENT_ONLY 而不是 FATAL,使信号处理器能先把消息发给客户端再强制进程退出。连接仍会关闭,之后不能在原 session 发送普通恢复命令。

消息

  • primary:terminating connection because of crash of another server process
  • detail:The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
  • hint:In a moment you should be able to reconnect to the database and repeat your command.
  • severity 来源:WARNING_CLIENT_ONLY,这是发给客户端但不写服务器日志的 warning;报告后进程退出。因此不能把它理解成可在同一 session 继续的语句级 WARNING。

报文模板

源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。

主消息 terminating connection because of crash of another server process
DETAIL The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT In a moment you should be able to reconnect to the database and repeat your command.

来源:src/backend/tcop/postgres.c @ REL_18_6 · src/include/utils/elog.h @ REL_18_6

诊断

把 SQLSTATE 和完整诊断与 postmaster 崩溃/恢复日志、backend PID 及执行中的命令关联。源码明确要求回滚当前事务,但连接在 crash 周期中断开,重放非幂等请求前仍必须核对持久化业务状态。要和有序管理员 shutdown(57P01)及启动拒绝(57P03)区分。

处理

不要在已断开的连接上发送 ROLLBACK,也不要人为制造崩溃测试此路径。等待 postmaster 恢复并 ready,建立新连接,检查持久化业务状态和受影响对象;只有在操作幂等或已确认先前效果后再重试。保留 primary/detail/hint 及服务器日志用于事故诊断。

版本

锁定目录从 7.4 记录此条件;该目录边界不等于精确实现引入版本。固定源码覆盖 PostgreSQL 18.6。

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

  • 57P02 is crash_shutdown in SQLSTATE Class 57.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

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

    核实方式Read complete fixed source contexts.

    不覆盖Source confirmation is not natural runtime.

    来源src/backend/tcop/postgres.c · src/include/utils/elog.h

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

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

同类 SQL 状态码

状态码 条件名 宏名称 严重等级 版本
Class 57 操作员干预 Operator Intervention 7 个
57000 operator_intervention ERRCODE_OPERATOR_INTERVENTION ERROR 7.4
运维干预类别的通用条件,核心未见直接调用。 活跃
57014 query_canceled ERRCODE_QUERY_CANCELED ERROR 7.4
语句被取消,含 statement_timeout 到期。 活跃
57P01 admin_shutdown ERRCODE_ADMIN_SHUTDOWN ERROR 7.4
管理员关闭服务器或终止后端,会话被断开。 活跃
57P02 crash_shutdown ERRCODE_CRASH_SHUTDOWN ERROR 7.4
postmaster 因崩溃重启而令后端回滚退出。 活跃
57P03 cannot_connect_now ERRCODE_CANNOT_CONNECT_NOW ERROR 7.4
服务器处于启动或恢复中,暂不接受连接。 活跃
57P04 database_dropped ERRCODE_DATABASE_DROPPED ERROR 9.0
所连数据库被删除,恢复冲突终止了会话。 活跃
57P05 idle_session_timeout ERRCODE_IDLE_SESSION_TIMEOUT ERROR 14
空闲会话超过 idle_session_timeout 被终止。 活跃