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

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

Wiki / SQLSTATE

72000 — snapshot_too_old

快照过旧无法读取该行,PG 17 已移除此码。

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

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

aliases
未知
class name
Snapshot Failure
condition name
snapshot_too_old
lang
en
sqlstate
72000

版本定义 PG 16

72000

速览 {#at-a-glance}

72000 是历史 snapshot_too_old 错误。PostgreSQL 16.15 仍定义并发出它;该 SQLSTATE 在 PostgreSQL 17 大版本移除。因此 16.15 是最后一个大版本线中的后续小版本快照,不是移除点。

含义 {#meaning}

固定的 16.15 源码中,old_snapshot_threshold 是 PGC_POSTMASTER 整数 GUC,-1 关闭功能。TestForOldSnapshot 内联 guard 要求阈值非负、快照为 MVCC 或 TOAST 且 LSN 有效,并且页面 LSN 晚于快照;随后调用 TestForOldSnapshot_impl,它还要求关系是允许提前清理的永久、非系统目录关系,并比较 snapshot.whenTaken 与 GetOldSnapshotThresholdTimestamp()。快照太旧时发出 ERROR 72000,主消息为 snapshot too old。

阈值时间戳由旧快照的时间到 XID 映射维护,供提前清理和 vacuum 使用。PG16.15 文档说明阈值之前已死数据可以被 vacuum,读取在快照建立后修改过的页面可能失败;物化游标或系统目录可能不触发错误。为检测条件而保留的关系空间不会直接归还 OS,除非显式执行 VACUUM FULL 等操作。

消息 {#messages}

  • ERROR,SQLSTATE 72000:snapshot too old。

锁定目录在 PG17/18 没有当前定义行。不要推断替代 SQLSTATE,也不要把无关的当前错误声称为等价物。

诊断 {#diagnosis}

在 PostgreSQL 9.6–16 上记录大版本、SHOW old_snapshot_threshold、事务快照年龄、关系类型、页面读取路径以及 vacuum/提前清理历史。检查关系是否被 guard 排除(例如系统目录)、读取是否使用物化游标或结果集,以及设置是否在服务器启动时生效。源码核验不能建立实际集群的阈值或清理历史。

处理 {#response}

这是语句级 ERROR;显式事务中继续发 SQL 前先回滚整个事务,或回到已经建立的保存点。旧快照无法原地修复:结束或缩短长期读取事务,按历史大版本设置合适的启动配置(GUC 为 PGC_POSTMASTER,修改需重启),再以幂等边界重跑整个读取单元。PG17 及以后应先确认当前错误和机制,不要仅凭历史名称安装 72000 handler。

版本 {#versions}

锁定定义文件记录 72000 从 9.6.0 到 16.15,PG17/18 无定义。16.15 源码提供 GUC 与 guard;固定缓冲区管理器发出路径来自 commit 7d3e000c5961a544302072058a1184e9a588837b。目录边界说明它在 PG17 大版本线移除,而不是在 16.15 小版本移除。

相关 {#related}

40001、XX001

来源 {#sources}

src/backend/storage/buffer/bufmgr.c#L5663-L5675

src/include/storage/bufmgr.h#L363-L392

src/backend/utils/time/snapmgr.c#L1697-L1714

src/backend/utils/misc/guc_tables.c#L3295-L3302

doc/src/sgml/config.sgml#L2827-L2884

结构化证据记录保存历史定义、guard、GUC、文档和源码/运行边界。

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read locked historical definition snapshot.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.definition.rel16.artifact"
  ],
  "statement": "72000 is snapshot_too_old in SQLSTATE Class 72 in the locked REL_16_15 definition artifact."
}
claims · resolved-paths
{
  "claim_id": "resolved-paths",
  "limits": "Source confirmation is not natural runtime.",
  "method": "Read the inline guard, implementation, and threshold mapping contexts.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1",
    "src.path.2"
  ],
  "statement": "The PG16.15 guard checks snapshot type, LSN/page ordering, relation eligibility, and threshold timestamp before raising ERROR 72000 with snapshot too old."
}
claims · configuration-and-history
{
  "claim_id": "configuration-and-history",
  "limits": "",
  "method": "Read fixed GUC and documentation plus locked version membership.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.3",
    "src.path.4",
    "src.definition.rel16.artifact"
  ],
  "statement": "old_snapshot_threshold is a PGC_POSTMASTER setting, disabled by -1, and the PG16.15 documentation describes the vacuum/read conditions; the catalogue boundary places removal in the PG17 major line."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Compare locked version snapshots.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.definition.rel16.artifact"
  ],
  "statement": "The locked definition artifact records 72000 through 16.15 and absent from PG17/18 snapshots; it does not assert a replacement SQLSTATE."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.0",
    "primary_template": "snapshot too old",
    "severity_source": "ERROR",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "72000"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "snapshot too old",
      "position": 0,
      "role": "",
      "template": "snapshot too old"
    }
  ]
}
sources · src.definition.rel16.artifact
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/definitions/REL_16_15.txt",
  "position": 0,
  "sha256": "1d1d741b7b7c6dfd8275287e31c79befed75f3b9349e1a42ef0ca147c429ff88",
  "source_id": "src.definition.rel16.artifact",
  "tag": "REL_16_15",
  "url": ""
}
sources · src.path.0
{
  "commit": "7d3e000c5961a544302072058a1184e9a588837b",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/storage/buffer/bufmgr.c",
  "position": 1,
  "sha256": "dd070e7dfee25fa7beabd63abf35d3116105f0517e83dd0743a9c73d8f50cfec",
  "source_id": "src.path.0",
  "tag": "REL_16_15",
  "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/storage/buffer/bufmgr.c#L5663"
}
sources · src.path.1
{
  "commit": "7d3e000c5961a544302072058a1184e9a588837b",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/include/storage/bufmgr.h",
  "position": 2,
  "sha256": "9068c40143d84d3827bae5275bf13f6890d6b232a08922088187b0019ea94587",
  "source_id": "src.path.1",
  "tag": "REL_16_15",
  "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/include/storage/bufmgr.h#L363"
}
sources · src.path.2
{
  "commit": "7d3e000c5961a544302072058a1184e9a588837b",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/time/snapmgr.c",
  "position": 3,
  "sha256": "7d87a04c85bd146f639bc4280bbb643f1000af231737f6055cbd4c35984f502c",
  "source_id": "src.path.2",
  "tag": "REL_16_15",
  "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/utils/time/snapmgr.c#L1697"
}
sources · src.path.3
{
  "commit": "7d3e000c5961a544302072058a1184e9a588837b",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/misc/guc_tables.c",
  "position": 4,
  "sha256": "2e3efa81095d9fbc77afe7c3c0960f3440f33be768a1ac02461596161cf95468",
  "source_id": "src.path.3",
  "tag": "REL_16_15",
  "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/utils/misc/guc_tables.c#L3295"
}
sources · src.path.4
{
  "commit": "7d3e000c5961a544302072058a1184e9a588837b",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "doc/src/sgml/config.sgml",
  "position": 5,
  "sha256": "b256738f2425571a921f176e6e6d4b936a8164a0c79381c4c216d26c9749514c",
  "source_id": "src.path.4",
  "tag": "REL_16_15",
  "url": "https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/doc/src/sgml/config.sgml#L2827"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 16 · english-manuals:63d701e90ea317bcc80ade81930daed5f8330c89beed576a3950dc55d865222d

正文语言: zh-Hans · english-manuals:63d701e90ea317bcc80ade81930daed5f8330c89beed576a3950dc55d865222d