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

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

Wiki / SQLSTATE

40000 — transaction_rollback(事务回滚)

事务回滚的类别码,具体原因见 40001 等子码。

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

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

aliases
未知
class name
Transaction Rollback
condition name
transaction_rollback
lang
en
sqlstate
40000

版本定义 PG 18

40000 — transaction_rollback(事务回滚)

速览 {#at-a-glance}

40000 是事务回滚的总括条件。18.6 固定源码包含 transaction aborted during system catalog scan 的内部系统目录扫描路径;复现它需要安全 SQL 案例之外的内部故障或可见性条件。不要把序列化失败、死锁或任意客户端取消改称 40000。

含义 {#meaning}

40000 是宽泛的事务回滚条件。genam.c 中解析到的核心路径是防御性内部错误:系统目录扫描期间事务已中止。它不是 40001 表示的常规客户端重试路径,也不是死锁报告。

诊断 {#diagnosis}

若真实出现 40000,保存服务器日志、后端 PID、操作和源码诊断;固定主模板是 transaction aborted during system catalog scan。检查日志是否指向内部目录/索引可见性问题或服务器故障。客户端 ROLLBACK、序列化失败或语句取消都不能证明该码,选定扫描也没有安全的纯 SQL 复现。

处理 {#response}

按服务器要求结束失败事务,并在重试前调查目录/索引和服务器健康状态。只有会话不可用时才重连,重做写入前先核对持久化结果。不要把 40001、40P01 或普通回滚改称 40000;本页只记录内部源码边界。

版本 {#versions}

上面的锁定事实表记录项目快照范围内的目录存在情况。固定源码证据只覆盖下面声明的路径;不能仅从定义推导精确行为引入版本或更广的运行覆盖。

相关 {#related}

可对照有明确机制的40001 序列化失败和40P01 检测到死锁。

来源 {#sources}

  • src.errcodes.18.6(SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • 源码路径(SHA-256 11897b1d8b1ae1f4a1bef9a72e740da7aa83579abf84e4ca5ebacd6530874c28)

比较版本

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

cases · transaction_rollback_boundary
{
  "assertions": [],
  "case_id": "transaction_rollback_boundary",
  "cleanup": "Drop the case schema with an owner connection.",
  "has_snippet": false,
  "position": 0,
  "preconditions": [
    "A runner-owned disposable target is provisioned."
  ],
  "repair": "Treat this umbrella as a transaction rollback outcome only after identifying the concrete source mechanism; do not retry an unknown internal failure blindly.",
  "trigger": "No internal system-catalog-scan fault is injected; the fixed source path remains a source-only boundary.",
  "versions": [
    "10",
    "18"
  ]
}
claims · identity
{
  "claim_id": "identity",
  "limits": "This records the protocol definition and does not imply a natural PostgreSQL throw path.",
  "method": "Read the fixed errcodes.txt row and macro mapping.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "40000 is the transaction_rollback condition in Class 40."
}
claims · source-boundary
{
  "claim_id": "source-boundary",
  "limits": "No representative runtime case is claimed; the path requires a specialized internal or trigger/procedure context.",
  "method": "Trace the fixed source call scan and classify the path before selecting a safe runner case.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.genam.18.6",
    "src.calls.REL_18_6"
  ],
  "statement": "transaction aborted during system catalog scan is a source-confirmed path for 40000."
}
messages · message.catalog-scan-rollback
{
  "limits": "This is an internal catalog-scan path; ordinary client rollback has no basis to use this template.",
  "message_id": "message.catalog-scan-rollback",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.catalog-scan-rollback",
    "limits": "This is an internal catalog-scan path; ordinary client rollback has no basis to use this template.",
    "primary_template": "transaction aborted during system catalog scan",
    "severity_source": "ERROR",
    "sources": [
      "src.genam.18.6"
    ],
    "sqlstate": "40000"
  },
  "severity": "ERROR",
  "sources": [
    "src.genam.18.6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "transaction aborted during system catalog scan",
      "position": 0,
      "role": "",
      "template": "transaction aborted during system catalog scan"
    }
  ]
}
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"
}
sources · src.calls.REL_18_6
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 1,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6",
  "tag": "",
  "url": ""
}
sources · src.genam.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/access/index/genam.c",
  "position": 2,
  "sha256": "11897b1d8b1ae1f4a1bef9a72e740da7aa83579abf84e4ca5ebacd6530874c28",
  "source_id": "src.genam.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/index/genam.c#L496-L498"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:88fa22a579371b5d23925809df8eada17ceba2b46dbd459ffbcd0dfeeee1d089

正文语言: zh-Hans · english-manuals:88fa22a579371b5d23925809df8eada17ceba2b46dbd459ffbcd0dfeeee1d089