文档 / SQL 状态码 / Class 57 操作员干预
57P03 cannot_connect_now
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
the database system is not accepting connections
Hot standby mode is disabled.
the database system is not yet accepting connections
Recovery snapshot is not yet ready for hot standby.
To enable hot standby, close write transactions with more than %d subtransactions on the primary server.
the database system is not yet accepting connections
Consistent recovery state has not been yet reached.
the database system is shutting down
the database system is in recovery mode
诊断
记录 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_standby 是 PGC_POSTMASTER 设置:修改服务器所属的配置来源后必须重启服务器,SIGHUP/reload 不能激活该设置。若 hint 指向 primary 上长时间写事务,则处理该运维原因。ready 后建立新连接。被拒绝的 startup 路径没有事务可回滚;若此前客户端操作在状态转换中断开,重放前先核对业务结果。
版本
锁定目录从 7.4 记录此条件;该目录边界不等于精确实现引入版本。固定源码覆盖 PostgreSQL 18.6。
来源
- 上游源码 src/backend/utils/errcodes.txt 第 437 行
- 上游源码 src/backend/tcop/backend_startup.c 第 307 行
- 上游源码 src/backend/utils/misc/guc_tables.c 第 1895 行
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
57P03 is cannot_connect_now in SQLSTATE Class 57.
-
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.
-
The locked catalogue records 57P03 from 7.4; that boundary does not prove exact implementation introduction.
-
hot_standby has GUC context PGC_POSTMASTER; a SIGHUP/reload cannot activate a changed value for the running server.
同类 SQL 状态码
| 状态码 | 条件名 | 宏名称 | 严重等级 | 版本 |
|---|---|---|---|---|
| 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 被终止。 | 活跃 | |||