↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / SQLSTATE

57P04 — database_dropped

所连数据库被删除,恢复冲突终止了会话。

英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。

当前阅读 PG 18·选择有来源记录的版本

aliases
未知
class name
Operator Intervention
condition name
database_dropped
lang
en
sqlstate
57P04

版本定义 PG 18

57P04

速览 {#at-a-glance}

57P04 在 recovery conflict 因当前连接所在数据库必须被删除而终止 session 时选用。同一 recovery-conflict primary 也用于其他冲突原因,但那些分支选择 40001;这里决定条件身份的是 database-dropped guard。

含义 {#meaning}

固定调用点以 FATAL 发出 primary terminating connection due to conflict with recovery、动态 recovery-conflict detail 以及 hint In a moment you should be able to reconnect to the database and repeat your command.。SQLSTATE 表达式是明确的:只有 reason == PROCSIG_RECOVERY_CONFLICT_DATABASE 时选择 ERRCODE_DATABASE_DROPPED;同一终止分支的其他 reason 选择 ERRCODE_T_R_SERIALIZATION_FAILURE。数据库分支的 detail 是 User was connected to a database that must be dropped.。

消息 {#messages}

  • primary:terminating connection due to conflict with recovery,FATAL。
  • 数据库删除 detail:User was connected to a database that must be dropped.。
  • hint:In a moment you should be able to reconnect to the database and repeat your command.。
  • 其他 recovery-conflict reason 可能复用相同 primary,但选择 40001 和不同 detail;不能只凭 primary 把它们标成 57P04。

诊断 {#diagnosis}

保留 SQLSTATE、primary/detail/hint、数据库名、backend PID、recovery-conflict reason 及 standby/recovery 日志。确认 detail 指向被删除的数据库后,才按 57P04 处理。FATAL 报告会关闭连接,因此没有可发送 ROLLBACK 的 session。断开前中断的操作是否已提交,需要单独核对。

处理 {#response}

等待 recovery conflict/数据库转换结束,连接到有效数据库,并在重放非幂等操作前核对持久化业务状态。若服务器返回带 40001 的其他 recovery-conflict detail,应使用 serialization/retry 处理。数据库仍在删除或 recovery 日志表明冲突活跃时,不要盲目反复重连。

版本 {#versions}

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

相关 {#related}

57P03、57P02、40001

来源 {#sources}

src/backend/tcop/postgres.c#L3233-3248

src/backend/tcop/postgres.c#L2549-2578

结构化证据记录保存 SQLSTATE guard、动态 detail 及源码/运行范围。

比较版本

SQLSTATE 证据与已记录的运行版本

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "57P04 is database_dropped in SQLSTATE Class 57."
}
claims · resolved-paths
{
  "claim_id": "resolved-paths",
  "limits": "Source confirmation is not natural runtime.",
  "method": "Read complete fixed source contexts.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1"
  ],
  "statement": "The cited PostgreSQL 18.6 source paths support the concrete phase, message, and lifecycle boundary described."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 57P04 from 9.0.4; that boundary does not prove exact implementation introduction."
}
claims · database-guard
{
  "claim_id": "database-guard",
  "limits": "",
  "method": "Read the complete guard and errdetail_recovery_conflict helper.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1"
  ],
  "statement": "The terminating recovery-conflict call selects ERRCODE_DATABASE_DROPPED only for PROCSIG_RECOVERY_CONFLICT_DATABASE; other reasons select ERRCODE_T_R_SERIALIZATION_FAILURE and use a different detail."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "detail_template": "User was connected to a database that must be dropped.",
    "hint_template": "In a moment you should be able to reconnect to the database and repeat your command.",
    "id": "message.0",
    "primary_template": "terminating connection due to conflict with recovery",
    "severity_source": "FATAL",
    "sources": [
      "src.path.0",
      "src.path.1"
    ],
    "sqlstate": "57P04"
  },
  "severity": "FATAL",
  "sources": [
    "src.path.0",
    "src.path.1"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "terminating connection due to conflict with recovery",
      "position": 0,
      "role": "",
      "template": "terminating connection due to conflict with recovery"
    },
    {
      "kind": "detail",
      "literal": "User was connected to a database that must be dropped.",
      "position": 1,
      "role": "",
      "template": "User was connected to a database that must be dropped."
    },
    {
      "kind": "hint",
      "literal": "In a moment you should be able to reconnect to the database and repeat your command.",
      "position": 2,
      "role": "",
      "template": "In a moment you should be able to reconnect to the database and repeat your command."
    }
  ]
}
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#L438"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/postgres.c",
  "position": 1,
  "sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3241"
}
sources · src.path.1
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/tcop/postgres.c",
  "position": 2,
  "sha256": "9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061",
  "source_id": "src.path.1",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L2549"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:c60274ce03a97e641e0dde66c8ccba6f99f45be2b281224088beb143c5179fd3

正文语言: zh-Hans · english-manuals:c60274ce03a97e641e0dde66c8ccba6f99f45be2b281224088beb143c5179fd3