57P03 — cannot_connect_now
服务器处于启动或恢复中,暂不接受连接。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Operator Intervention
- condition name
- cannot_connect_now
- lang
- en
- sqlstate
- 57P03
版本定义 PG 18
57P03
速览 {#at-a-glance}
57P03 在连接启动阶段、数据库尚未达到可接受连接状态时发出。固定 guard 区分 startup、shutdown、recovery、禁用 hot standby,以及两种不同的 recovery 尚未达到一致状态。
含义 {#meaning}
startup packet 在正常认证完成前被拒绝。所有固定分支都使用 FATAL,因此尝试连接直接结束,不会进入客户端事务。hot-standby 分支不能只看 primary:detail 会区分功能禁用、recovery snapshot 尚未 ready,以及 recovery 尚未达到一致状态。
消息 {#messages}
- 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。
诊断 {#diagnosis}
记录 primary/detail/hint、startup 阶段、hot-standby 配置、recovery 一致性/snapshot 状态、服务器 ready 日志及目标服务器角色。反复出现带 snapshot detail 的 not yet accepting 指向 hint 所说的 primary 端子事务条件;一致性 detail 则表示 recovery 尚未过早阶段。不要把它当成 INERROR 事务:连接在 session 事务建立前就被拒绝。
处理 {#response}
按界限退避,等待相关 startup、shutdown 或 recovery 状态转换。若 hot standby 是有意禁用的,要注意 hot_standby 是 PGC_POSTMASTER 设置:修改服务器所属的配置来源后必须重启服务器,SIGHUP/reload 不能激活该设置。若 hint 指向 primary 上长时间写事务,则处理该运维原因。ready 后建立新连接。被拒绝的 startup 路径没有事务可回滚;若此前客户端操作在状态转换中断开,重放前先核对业务结果。
版本 {#versions}
锁定目录从 7.4 记录此条件;该目录边界不等于精确实现引入版本。固定源码覆盖 PostgreSQL 18.6。
相关 {#related}
来源 {#sources}
src/backend/tcop/backend_startup.c#L298-338
src/backend/utils/misc/guc_tables.c#L1895-1903
结构化证据记录保存全部固定 startup gate 以及源码/运行范围。
比较版本
SQLSTATE 证据与已记录的运行版本
claims · identity
{
"claim_id": "identity",
"limits": "",
"method": "Read fixed definition.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "57P03 is cannot_connect_now in SQLSTATE Class 57."
}claims · resolved-paths
{
"claim_id": "resolved-paths",
"limits": "Source confirmation is not natural runtime.",
"method": "Read the complete startup guard and hot_standby GUC definition.",
"position": 1,
"runtime": [],
"sources": [
"src.path.0",
"src.path.1"
],
"statement": "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."
}claims · history
{
"claim_id": "history",
"limits": "",
"method": "Use catalogue boundary.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "The locked catalogue records 57P03 from 7.4; that boundary does not prove exact implementation introduction."
}claims · hot-standby-context
{
"claim_id": "hot-standby-context",
"limits": "",
"method": "Read the fixed guc_tables.c entry.",
"position": 3,
"runtime": [],
"sources": [
"src.path.1"
],
"statement": "hot_standby has GUC context PGC_POSTMASTER; a SIGHUP/reload cannot activate a changed value for the running server."
}messages · message.0
{
"limits": "",
"message_id": "message.0",
"path": "",
"position": 0,
"raw": {
"id": "message.0",
"primary_template": "the database system is starting up",
"severity_source": "FATAL",
"sources": [
"src.path.0"
],
"sqlstate": "57P03"
},
"severity": "FATAL",
"sources": [
"src.path.0"
],
"templates": [
{
"kind": "primary",
"literal": "the database system is starting up",
"position": 0,
"role": "",
"template": "the database system is starting up"
}
]
}messages · message.1
{
"limits": "",
"message_id": "message.1",
"path": "",
"position": 1,
"raw": {
"detail_template": "Hot standby mode is disabled.",
"id": "message.1",
"primary_template": "the database system is not accepting connections",
"severity_source": "FATAL",
"sources": [
"src.path.0"
],
"sqlstate": "57P03"
},
"severity": "FATAL",
"sources": [
"src.path.0"
],
"templates": [
{
"kind": "primary",
"literal": "the database system is not accepting connections",
"position": 0,
"role": "",
"template": "the database system is not accepting connections"
},
{
"kind": "detail",
"literal": "Hot standby mode is disabled.",
"position": 1,
"role": "",
"template": "Hot standby mode is disabled."
}
]
}messages · message.2
{
"limits": "",
"message_id": "message.2",
"path": "",
"position": 2,
"raw": {
"detail_template": "Recovery snapshot is not yet ready for hot standby.",
"hint_template": "To enable hot standby, close write transactions with more than %d subtransactions on the primary server.",
"id": "message.2",
"primary_template": "the database system is not yet accepting connections",
"severity_source": "FATAL",
"sources": [
"src.path.0"
],
"sqlstate": "57P03"
},
"severity": "FATAL",
"sources": [
"src.path.0"
],
"templates": [
{
"kind": "primary",
"literal": "the database system is not yet accepting connections",
"position": 0,
"role": "",
"template": "the database system is not yet accepting connections"
},
{
"kind": "detail",
"literal": "Recovery snapshot is not yet ready for hot standby.",
"position": 1,
"role": "",
"template": "Recovery snapshot is not yet ready for hot standby."
},
{
"kind": "hint",
"literal": "To enable hot standby, close write transactions with more than subtransactions on the primary server.",
"position": 2,
"role": "",
"template": "To enable hot standby, close write transactions with more than %d subtransactions on the primary server."
}
]
}messages · message.3
{
"limits": "",
"message_id": "message.3",
"path": "",
"position": 3,
"raw": {
"detail_template": "Consistent recovery state has not been yet reached.",
"id": "message.3",
"primary_template": "the database system is not yet accepting connections",
"severity_source": "FATAL",
"sources": [
"src.path.0"
],
"sqlstate": "57P03"
},
"severity": "FATAL",
"sources": [
"src.path.0"
],
"templates": [
{
"kind": "primary",
"literal": "the database system is not yet accepting connections",
"position": 0,
"role": "",
"template": "the database system is not yet accepting connections"
},
{
"kind": "detail",
"literal": "Consistent recovery state has not been yet reached.",
"position": 1,
"role": "",
"template": "Consistent recovery state has not been yet reached."
}
]
}messages · message.4
{
"limits": "",
"message_id": "message.4",
"path": "",
"position": 4,
"raw": {
"id": "message.4",
"primary_template": "the database system is shutting down",
"severity_source": "FATAL",
"sources": [
"src.path.0"
],
"sqlstate": "57P03"
},
"severity": "FATAL",
"sources": [
"src.path.0"
],
"templates": [
{
"kind": "primary",
"literal": "the database system is shutting down",
"position": 0,
"role": "",
"template": "the database system is shutting down"
}
]
}messages · message.5
{
"limits": "",
"message_id": "message.5",
"path": "",
"position": 5,
"raw": {
"id": "message.5",
"primary_template": "the database system is in recovery mode",
"severity_source": "FATAL",
"sources": [
"src.path.0"
],
"sqlstate": "57P03"
},
"severity": "FATAL",
"sources": [
"src.path.0"
],
"templates": [
{
"kind": "primary",
"literal": "the database system is in recovery mode",
"position": 0,
"role": "",
"template": "the database system is in recovery mode"
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L437"
}sources · src.path.0
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/tcop/backend_startup.c",
"position": 1,
"sha256": "5516f3d6d83ae6fc66ca6bad9a7cea3cd2f8de53f0597c26baa2bd224ac270bb",
"source_id": "src.path.0",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/backend_startup.c#L307"
}sources · src.path.1
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/misc/guc_tables.c",
"position": 2,
"sha256": "7b3b81dcfd95f6543b01b2dd4262e93d03113065e18ed8f780b7125a4976e8df",
"source_id": "src.path.1",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/misc/guc_tables.c#L1895"
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:986afd11fc48803fba07d18c5f343b5e645a6c45b47903a3e3e8f2cd5c88a6e8
正文语言: zh-Hans · english-manuals:986afd11fc48803fba07d18c5f343b5e645a6c45b47903a3e3e8f2cd5c88a6e8