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

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

Wiki / SQLSTATE

58030 — io_error

文件读写发生 I/O 错误,如缓冲区写回失败。

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

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

aliases
未知
class name
System Error (errors external to PostgreSQL itself)
condition name
io_error
lang
en
sqlstate
58030

版本定义 PG 18

58030

速览 {#at-a-glance}

58030 由共享缓冲区的一条特定清理路径发出:此前已经记录过写入失败,18.6 中该路径报告的是 WARNING,不是笼统的客户端 ERROR;消息保留数据块和关系对象信息,并提示重复失败可能是永久性的。

含义 {#meaning}

FlushBuffer 启动共享缓冲区写入;永久关系会先刷新 WAL,然后调用 smgrwrite。异常展开进入缓冲区 I/O 的资源所有者回调时,AbortBufferIO 将缓冲区标为 BM_IO_ERROR。如果缓冲区仍有效且为脏页,并且这不是第一次失败,它以 WARNING 和 SQLSTATE 58030 报告,再以错误标记结束缓冲区 I/O。较早的 smgrwrite 失败才可能使客户端语句失败;后面的警告是重复失败通知,本身不能证明客户端事务已进入错误状态。

关系文本由缓冲区标记通过 relpathperm 生成;共享缓冲区写入的错误上下文还可能是 writing block %u of relation "%s"。因此它指出排查位置,但不保证只有该数据块受影响。

另一个存储管理器路径用 FileWrite 扩展关系段。如果该调用返回负值,md.c 以 ERROR 报告 could not extend file "%s": %m 并调用 errcode_for_file_access();保存的 errno 为 EIO 时映射到 58030,为 ENOSPC 时映射到 53100。这个原始 ERROR 可能使客户端语句失败并令显式事务进入失败状态;它与 AbortBufferIO 后续重复失败的 WARNING 是不同的发出路径。

消息 {#messages}

  • WARNING,SQLSTATE 58030:could not write block %u of %s
    • DETAIL:Multiple failures --- write error might be permanent.
  • 共享缓冲区写入周边的错误上下文:writing block %u of relation "%s"。
  • ERROR,SQLSTATE 由 errcode_for_file_access() 选择;保存的 errno 为 EIO 时为 58030:could not extend file "%s": %m
    • HINT:Check free disk space.

第一次写失败可能有不同的主消息和 SQLSTATE,例如由 OS errno 辅助函数选择的代码。应把第一次记录与该警告一起保留。在扩展关系的路径中,EIO 明确选择该条件,而 ENOSPC 选择 53100;不能把这些 errno 分支都压成笼统的磁盘已满诊断。

诊断 {#diagnosis}

保留完整错误链、第一次写错误、该 warning、日志上下文、关系 fork 和数据块、文件系统/设备 errno、挂载状态,以及 WAL 或副本是否确认写入。确认是后端语句、检查点、后台写进程还是其他服务器路径;源码核验不能代替特定部署的存储定位。

处理 {#response}

存储路径不健康时停止重试,检查挂载、设备、权限、空间/配额及存储日志,并在修复前保留关系与副本证据。扩展关系的 ERROR 可能令显式客户端事务失败,继续发 SQL 前先 ROLLBACK 或回到已经建立的保存点;AbortBufferIO 的重复失败 WARNING 本身不要求客户端回滚,但仍需修复存储并确认持久性。原因修复后仅按幂等边界重试整个工作单元;后端/服务器已停止时使用新连接,并在重放前确认提交状态。

版本 {#versions}

锁定目录从 7.4 记录此条件;固定机制和消息角色来自 PostgreSQL 18.6。本源码条目没有诱发自然 I/O 故障。

相关 {#related}

53100、58P03、XX001

来源 {#sources}

src/backend/storage/buffer/bufmgr.c#L4307-L4436

src/backend/storage/buffer/bufmgr.c#L6164-L6225

src/backend/storage/smgr/md.c#L512-L519

src/backend/utils/error/elog.c#L867-L942

结构化证据记录保存固定 warning、detail、源码边界和未运行自然故障的事实。

比较版本

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

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read locked definition snapshot.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "58030 is io_error in SQLSTATE Class 58."
}
claims · resolved-paths
{
  "claim_id": "resolved-paths",
  "limits": "Source confirmation is not natural runtime.",
  "method": "Read the complete fixed write and error-unwind contexts.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1"
  ],
  "statement": "FlushBuffer writes a shared buffer through smgrwrite, and AbortBufferIO emits the fixed 58030 warning only after a prior I/O error is present on a valid dirty buffer."
}
claims · relation-extension-errno
{
  "claim_id": "relation-extension-errno",
  "limits": "The source establishes message roles and code mapping, not a natural I/O failure on a host.",
  "method": "Read the complete negative-write branch and the saved-errno switch.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.2",
    "src.path.3"
  ],
  "statement": "The relation-extension FileWrite path emits ERROR with a %m primary and errcode_for_file_access(); saved EIO maps to 58030 and saved ENOSPC maps to 53100."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use locked catalogue boundary.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 58030 from 7.4; it does not prove the exact introduction or every historical emitter."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "context_template": "writing block %u of relation \"%s\"",
    "detail_template": "Multiple failures --- write error might be permanent.",
    "id": "message.0",
    "primary_template": "could not write block %u of %s",
    "severity_source": "WARNING",
    "sources": [
      "src.path.0",
      "src.path.1"
    ],
    "sqlstate": "58030"
  },
  "severity": "WARNING",
  "sources": [
    "src.path.0",
    "src.path.1"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "could not write block of",
      "position": 0,
      "role": "",
      "template": "could not write block %u of %s"
    },
    {
      "kind": "detail",
      "literal": "Multiple failures --- write error might be permanent.",
      "position": 1,
      "role": "",
      "template": "Multiple failures --- write error might be permanent."
    },
    {
      "kind": "context",
      "literal": "writing block of relation \" \"",
      "position": 2,
      "role": "",
      "template": "writing block %u of relation \"%s\""
    }
  ]
}
messages · message.1
{
  "limits": "",
  "message_id": "message.1",
  "path": "",
  "position": 1,
  "raw": {
    "code_selection": "errcode_for_file_access()",
    "errno_condition": "saved errno EIO",
    "hint_template": "Check free disk space.",
    "id": "message.1",
    "primary_template": "could not extend file \"%s\": %m",
    "severity_source": "ERROR",
    "sources": [
      "src.path.2"
    ],
    "sqlstate": "58030"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.2"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "could not extend file \" \":",
      "position": 0,
      "role": "",
      "template": "could not extend file \"%s\": %m"
    },
    {
      "kind": "hint",
      "literal": "Check free disk space.",
      "position": 1,
      "role": "",
      "template": "Check free disk space."
    }
  ]
}
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#L445"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/storage/buffer/bufmgr.c",
  "position": 1,
  "sha256": "453528ad5ab1bf8b7190ed9f866b934646278e06d802de9e5c25b6b807fcda23",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/bufmgr.c#L4307"
}
sources · src.path.1
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/storage/buffer/bufmgr.c",
  "position": 2,
  "sha256": "453528ad5ab1bf8b7190ed9f866b934646278e06d802de9e5c25b6b807fcda23",
  "source_id": "src.path.1",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/buffer/bufmgr.c#L6164"
}
sources · src.path.2
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/storage/smgr/md.c",
  "position": 3,
  "sha256": "c7e885c50b381337b8b8624bfc8effbd3abba7aa95a290083996354926ec9f69",
  "source_id": "src.path.2",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/smgr/md.c#L512"
}
sources · src.path.3
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/error/elog.c",
  "position": 4,
  "sha256": "766d30a426ba1d9597657bd46fb890da3e37e4ae53a83d1245bf082ed9433c33",
  "source_id": "src.path.3",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/error/elog.c#L867"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:33c9cdf2d83c07adaaa7ae95ddeaf54c606cda334ae29330761bf41fb6b44031

正文语言: zh-Hans · english-manuals:33c9cdf2d83c07adaaa7ae95ddeaf54c606cda334ae29330761bf41fb6b44031