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

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

百科 / 错误代码 / Class 57 操作员干预

57P03 cannot_connect_now

ERROR 源码确认 详解 未实测

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

版本覆盖

速览

57P03 在连接启动阶段、数据库尚未达到可接受连接状态时发出。固定 guard 区分 startup、shutdown、recovery、禁用 hot standby,以及两种不同的 recovery 尚未达到一致状态。

含义

startup packet 在正常认证完成前被拒绝。所有固定分支都使用 FATAL,因此尝试连接直接结束,不会进入客户端事务。hot-standby 分支不能只看 primary:detail 会区分功能禁用、recovery snapshot 尚未 ready,以及 recovery 尚未达到一致状态。

消息

  • startup gate:primary the database system is starting up,FATAL。
  • hot standby 禁用:primary the database system is not accepting connections,FATAL;detail 为 Hot standby mode is disabled.
  • recovery snapshot 未 ready:primary the database system is not yet accepting connections,FATAL;detail 为 Recovery snapshot is not yet ready for hot standby.;hint 为 To enable hot standby, close write transactions with more than %d subtransactions on the primary server.
  • recovery 尚未一致:primary the database system is not yet accepting connections,FATAL;detail 为 Consistent recovery state has not been yet reached.
  • shutdown gate:primary the database system is shutting down,FATAL。
  • recovery gate:primary the database system is in recovery mode,FATAL。

报文模板

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

主消息 the database system is starting up

来源:src/backend/tcop/backend_startup.c @ REL_18_6

主消息 the database system is not accepting connections
DETAIL Hot standby mode is disabled.

来源:src/backend/tcop/backend_startup.c @ REL_18_6

主消息 the database system is not yet accepting connections
DETAIL Recovery snapshot is not yet ready for hot standby.
HINT To enable hot standby, close write transactions with more than %d subtransactions on the primary server.

来源:src/backend/tcop/backend_startup.c @ REL_18_6

主消息 the database system is not yet accepting connections
DETAIL Consistent recovery state has not been yet reached.

来源:src/backend/tcop/backend_startup.c @ REL_18_6

主消息 the database system is shutting down

来源:src/backend/tcop/backend_startup.c @ REL_18_6

主消息 the database system is in recovery mode

来源:src/backend/tcop/backend_startup.c @ REL_18_6

诊断

记录 primary/detail/hint、startup 阶段、hot-standby 配置、recovery 一致性/snapshot 状态、服务器 ready 日志及目标服务器角色。反复出现带 snapshot detail 的 not yet accepting 指向 hint 所说的 primary 端子事务条件;一致性 detail 则表示 recovery 尚未过早阶段。不要把它当成 INERROR 事务:连接在 session 事务建立前就被拒绝。

处理

按界限退避,等待相关 startup、shutdown 或 recovery 状态转换。若 hot standby 是有意禁用的,要注意 hot_standbyPGC_POSTMASTER 设置:修改服务器所属的配置来源后必须重启服务器,SIGHUP/reload 不能激活该设置。若 hint 指向 primary 上长时间写事务,则处理该运维原因。ready 后建立新连接。被拒绝的 startup 路径没有事务可回滚;若此前客户端操作在状态转换中断开,重放前先核对业务结果。

版本

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

来源

证据

断言

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

  • 57P03 is cannot_connect_now in SQLSTATE Class 57.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The fixed startup guards support all listed startup/recovery messages, and guc_tables.c defines hot_standby as PGC_POSTMASTER, so enabling it requires a server restart rather than a reload.

    核实方式Read the complete startup guard and hot_standby GUC definition.

    不覆盖Source confirmation is not natural runtime.

    来源src/backend/tcop/backend_startup.c · src/backend/utils/misc/guc_tables.c

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

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

  • hot_standby has GUC context PGC_POSTMASTER; a SIGHUP/reload cannot activate a changed value for the running server.

    核实方式Read the fixed guc_tables.c entry.

    来源src/backend/utils/misc/guc_tables.c

同类错误代码

Class 57 操作员干预 下的其他成员。