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

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

文档 / SQL 状态码 / Class 57 操作员干预

57P04 database_dropped

ERROR 源码确认 参考 未实测

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

版本覆盖

速览

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

含义

固定调用点以 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.

消息

  • 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

报文模板

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

主消息 terminating connection due to conflict with recovery
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.

来源:src/backend/tcop/postgres.c @ REL_18_6 · src/backend/tcop/postgres.c @ REL_18_6

诊断

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

处理

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

版本

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

来源

证据

断言

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

  • 57P04 is database_dropped in SQLSTATE Class 57.

    核实方式Read fixed definition.

    来源src/backend/utils/errcodes.txt

  • The cited PostgreSQL 18.6 source paths support the concrete phase, message, and lifecycle boundary described.

    核实方式Read complete fixed source contexts.

    不覆盖Source confirmation is not natural runtime.

    来源src/backend/tcop/postgres.c · src/backend/tcop/postgres.c

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

    核实方式Use catalogue boundary.

    来源src/backend/utils/errcodes.txt

  • 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.

    核实方式Read the complete guard and errdetail_recovery_conflict helper.

    来源src/backend/tcop/postgres.c · src/backend/tcop/postgres.c

同类 SQL 状态码

状态码 条件名 宏名称 严重等级 版本
Class 57 操作员干预 Operator Intervention 7 个
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 被终止。 活跃