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

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

百科 / 错误代码 / Class 58 系统错误

58000 system_error

ERROR 源码确认 参考 未实测

类别
Class 58 系统错误
严重等级
ERROR
条件名
system_error
宏名称
ERRCODE_SYSTEM_ERROR
启用版本
9.2
状态
活跃

版本覆盖

速览

58000 是 system-error 条件。在固定 backend 路径中,pg_promote 创建 promotion signal 文件后调用 kill(PostmasterPid, SIGUSR1);信号发送失败时以 ERROR 报告,并把操作系统的 %m 文本展开到消息中。

含义

代表性 backend primary 是 failed to send signal to postmaster: %m。代码在报告 ERROR 前先删除 promotion signal 文件,所以这里是 postmaster 通知路径中的系统调用失败,不是用户值或 SQL 语法错误。共享的 common/exec.c 使用 log_error 宏,并有两个编译时分支:非 FRONTEND 构建展开为 ereport(LOG, (errcodefn, errmsg_internal(...)));FRONTEND 构建忽略 errcode() 参数,把格式化文本写到 stderr。因此 frontend 工具消息不能证明存在客户端协议 58000 诊断,也不能证明客户端事务已回滚。common/logging.h 中独立的 pg_log_error 宏才映射到 PG_LOG_ERROR,但 pclose_check() 并不调用它。

消息

  • backend pg_promote 信号路径:primary 为 failed to send signal to postmaster: %m,severity 为 ERROR;展开文本取决于失败 kill() 调用当时的 OS errno
  • 共享的 pclose_check() 源码:调用点模板是 %s() failed: %m;对 pclose() 会展开为 pclose() failed: <OS 文本>。非 FRONTEND 构建经 ereport(LOG) 携带传入的 ERRCODE_SYSTEM_ERROR;FRONTEND 构建忽略该 code、直接写 stderr,因此不是客户端协议 58000 路径。

报文模板

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

主消息 failed to send signal to postmaster: %m

来源:src/backend/access/transam/xlogfuncs.c @ REL_18_6

主消息 %s() failed: %m

来源:src/common/exec.c @ REL_18_6 · src/common/exec.c @ REL_18_6

诊断

保留 %m 展开后的完整 primary、操作类型(promotion signal、pclose 或其他系统 helper)、进程身份及服务器或工具日志上下文。对 backend pg_promote,检查 postmaster PID、信号权限/进程存活状态和 OS 错误。没有实际 errno 时,不要把系统错误替换成笼统的磁盘、权限或进程诊断;单凭 SQLSTATE 也不能判断事务结果。

处理

先修正展开消息所指出的操作系统条件,再确认 postmaster/服务器健康后重试。backend ERROR 通常会使当前显式事务进入错误状态,继续前先执行 ROLLBACKROLLBACK TO SAVEPOINT;autocommit 下也应在原因修正后再重试。pclose_check 的 frontend 日志由工具自身控制流处理,不应据此要求 SQL 回滚。若连接已断开,待服务器 ready 后重连并核对业务效果。

版本

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

来源

证据

断言

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

  • 58000 is system_error in SQLSTATE Class 58.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The fixed backend pg_promote path reports ERROR with ERRCODE_SYSTEM_ERROR; the shared pclose_check source has separate non-FRONTEND ereport(LOG) and FRONTEND stderr macro branches, so frontend output is not asserted as a client-protocol 58000 response.

    核实方式Read the complete backend call site, common exec macro definition/call site, and logging macro definitions.

    不覆盖Source confirmation is not natural runtime.

    来源src/backend/access/transam/xlogfuncs.c · src/common/exec.c · src/include/common/logging.h · src/common/exec.c

  • The locked catalogue records 58000 from 9.2.0; that boundary does not prove exact implementation introduction.

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

同类错误代码

Class 58 系统错误 下的其他成员。