{"Entry":{"collection":"sqlstate","key":"25P04","name":"25P04","aliases":[],"metadata":{"aliases":[],"case_count":2,"class_code":"25","condition_name":"transaction_timeout","condition_names":["transaction_timeout"],"content_hash":"1d5e7f6895cb4e56744bc32e076e03bbc043a62bd5f69a181164c1c0de147e17","depth":"full","editorial_review":"reviewed","evidence_tier":"observed_runtime","imported_at":"2026-09-30T17:45:27.300917+08:00","introduced":null,"known_present_by":"17.0","macros":["ERRCODE_TRANSACTION_TIMEOUT"],"name_zh":"事务超时","present_in":["17","18","19"],"preview_in":["19"],"primary_macro":"ERRCODE_TRANSACTION_TIMEOUT","removed":null,"runtime_verification":"passed","severity_classes":["E"],"snippet_count":2,"source_rev":"english-manuals:978606527e6134aa67f519a3abfcd9b4b446e0fe2ac90ab13a12c74630d5908f","sqlstate":"25P04","status":"active","summary_zh":"事务运行超过 transaction_timeout 被终止。"}},"Definition":{"Collection":"sqlstate","Key":"25P04","SourceDatabase":"center","Version":"18","SourceTable":"sqlstate","SourceKey":"25P04","SourceRevision":"english-manuals:978606527e6134aa67f519a3abfcd9b4b446e0fe2ac90ab13a12c74630d5908f","Facts":{"aliases":[],"class_name":"Invalid Transaction State","condition_name":"transaction_timeout","doc":{"anchor":"ERRCODES-APPENDIX","file":"errcodes-appendix.html","lang":"en","sha256":"56dacf78e618ff0fd8c533e05db597b80d7ebbad7f8e512a888217d0640aa328","slug":"18"},"lang":"en","sqlstate":"25P04"},"ManualEvidence":{"doc":{"anchor":"ERRCODES-APPENDIX","file":"errcodes-appendix.html","lang":"en","sha256":"56dacf78e618ff0fd8c533e05db597b80d7ebbad7f8e512a888217d0640aa328","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"sqlstate","Key":"25P04","SourceDatabase":"center","Version":"","Locale":"zh-Hans","Title":"25P04 — 事务超时（transaction_timeout）","Summary":"事务运行超过 transaction_timeout 被终止。","BodyHTML":"\u003ch1\u003e25P04 — 事务超时（transaction_timeout）\u003c/h1\u003e\n\u003ch2\u003e速览 {#at-a-glance}\u003c/h2\u003e\n\u003cp\u003e\u003ccode\u003e25P04\u003c/code\u003e 是 \u003ccode\u003etransaction_timeout\u003c/code\u003e 触发的 FATAL 条件，覆盖显式 \u003ccode\u003eBEGIN\u003c/code\u003e 事务和由单条语句隐式启动的事务。选定的 18.6 案例使用 300 ms；PG10 因设置不可用而在源码/版本预检阶段跳过，不会探测未知设置。另有 PG16.15/PG17.11 的版本边界对照：PG16 返回设置不可用的 \u003ccode\u003e42704\u003c/code\u003e，PG17 实际产生 FATAL \u003ccode\u003e25P04\u003c/code\u003e；该对照独立于选定基础案例。\u003c/p\u003e\n\u003ch2\u003e含义 {#meaning}\u003c/h2\u003e\n\u003cp\u003e\u003ccode\u003etransaction_timeout\u003c/code\u003e 限制显式或隐式事务的存活时间，包括事务打开期间执行或等待的时间。触发后 PostgreSQL 发出 \u003ccode\u003eterminating connection due to transaction timeout\u003c/code\u003e 并终止会话。它不同于只中止一条语句的 \u003ccode\u003estatement_timeout\u003c/code\u003e，也不同于只覆盖客户端在开放事务中空闲时间的 \u003ccode\u003eidle_in_transaction_session_timeout\u003c/code\u003e。若 \u003ccode\u003etransaction_timeout\u003c/code\u003e 小于或等于其中任一设置，较长的超时会被忽略；预备事务不受此设置约束。\u003c/p\u003e\n\u003ch2\u003e诊断 {#diagnosis}\u003c/h2\u003e\n\u003cp\u003e在支持该设置的服务器上，先在目标会话自身检查有效的 \u003ccode\u003eSHOW transaction_timeout\u003c/code\u003e、\u003ccode\u003eSHOW statement_timeout\u003c/code\u003e 和 \u003ccode\u003eSHOW idle_in_transaction_session_timeout\u003c/code\u003e。控制连接上的 \u003ccode\u003eSHOW\u003c/code\u003e 或 \u003ccode\u003epg_settings\u003c/code\u003e 反映的是观察者后端，不能用来确认另一个会话实际通过 \u003ccode\u003eSET\u003c/code\u003e 得到的值。再从控制连接查看 \u003ccode\u003epg_stat_activity\u003c/code\u003e 的 \u003ccode\u003epid\u003c/code\u003e、\u003ccode\u003eapplication_name\u003c/code\u003e、\u003ccode\u003estate\u003c/code\u003e、\u003ccode\u003exact_start\u003c/code\u003e、\u003ccode\u003estate_change\u003c/code\u003e、\u003ccode\u003equery_start\u003c/code\u003e、\u003ccode\u003equery\u003c/code\u003e 等字段，定位所属应用或连接池，并判断事务是在执行还是空闲。按 backend PID、SQLSTATE 25P04、\u003ccode\u003eerror_severity = FATAL\u003c/code\u003e 和精确报文匹配日志收集器记录。选定的 18.6 运行中驱动也暴露了 25P04，原连接已关闭；新的连接成功执行 \u003ccode\u003eSELECT 1\u003c/code\u003e。PG10 在发送 \u003ccode\u003eSET transaction_timeout\u003c/code\u003e 之前就由最低版本预检跳过。\u003c/p\u003e\n\u003ch2\u003e处理 {#response}\u003c/h2\u003e\n\u003cp\u003e丢弃已终止的会话并重连。对合法的长事务，可缩短工作、拆分工作单元或提高有效超时以控制在预算内；不要为了掩盖错误而降低超时。只有部署明确接受取消该保护时才设为 \u003ccode\u003e0\u003c/code\u003e。服务器关闭终止的会话时会在退出前回滚开放且尚未完成的事务；死亡连接不能再接收 \u003ccode\u003eROLLBACK\u003c/code\u003e。已知尚未在该会话上提交的事务，不能通过该连接恢复。若另一种网络故障使客户端无法确定 \u003ccode\u003eCOMMIT\u003c/code\u003e 是否到达服务器，应从新连接对账业务结果再重试；选定案例没有发送提交，不能据此声称存在这种不确定性。本批 PG10 没有兼容设置。\u003c/p\u003e\n\u003ch2\u003eFATAL 报文 {#messages}\u003c/h2\u003e\n\u003cp\u003e服务器源码固定报出 \u003ccode\u003eterminating connection due to transaction timeout\u003c/code\u003e，严重级别为 \u003ccode\u003eFATAL\u003c/code\u003e；原连接会被终止。\u003c/p\u003e\n\u003ch2\u003e实测诊断 {#observed}\u003c/h2\u003e\n\u003cp\u003e\u003ccode\u003e18.6 (Homebrew) / latest\u003c/code\u003e：FATAL SQLSTATE \u003ccode\u003e25P04\u003c/code\u003e；主报文 \u003ccode\u003eterminating connection due to transaction timeout\u003c/code\u003e；backend PID \u003ccode\u003e30576\u003c/code\u003e；原连接已关闭 \u003ccode\u003eTrue\u003c/code\u003e；CSV 日志 \u003ccode\u003e25P04\u003c/code\u003e；JSON 日志 \u003ccode\u003e25P04\u003c/code\u003e；新连接探测 \u003ccode\u003e1\u003c/code\u003e。\n\u003ccode\u003e10.21 (Debian 10.21-1.pgdg90+1) / pg10\u003c/code\u003e：案例 \u003ccode\u003enot_applicable\u003c/code\u003e（最低版本预检；未探测该目标不支持的设置）。\u003c/p\u003e\n\u003cp\u003e单独的边界对照：\u003ccode\u003e16.15 / pg16\u003c/code\u003e 因设置不可用返回 \u003ccode\u003e42704\u003c/code\u003e 并保持 \u003ccode\u003eIDLE\u003c/code\u003e，因此不计作 25P04 覆盖；\u003ccode\u003e17.11 / pg17\u003c/code\u003e 在 300 ms 后由 PID \u003ccode\u003e73\u003c/code\u003e 产生 FATAL \u003ccode\u003e25P04\u003c/code\u003e，CSV 与 JSON 都记录 FATAL \u003ccode\u003e25P04\u003c/code\u003e，原连接关闭，新连接为 \u003ccode\u003eIDLE\u003c/code\u003e。这些记录不计入选定基础案例。\u003c/p\u003e\n\u003ch2\u003e代表案例 {#case}\u003c/h2\u003e\n\u003cp\u003e下列 SQL 片段不是一次性粘贴脚本：在测试连接上执行设置、PID 和 \u003ccode\u003eBEGIN\u003c/code\u003e 后停止发送查询，由独立观察连接或日志收集器等待 FATAL；原连接终止后，另开新连接执行最后的探测。运行器从共享语句清单（registry）读取这些语句，完整断言、日志收集器关联、环境和清理见 \u003ca href=\"#cases\" rel=\"nofollow\"\u003e案例导出\u003c/a\u003e。\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e-- set_timeout\nSET transaction_timeout = \u0026#39;300ms\u0026#39;;\n-- backend_pid\nSELECT pg_backend_pid();\n-- begin\nBEGIN;\n-- probe\nSELECT 1;\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e上述片段的 SQLSTATE、诊断、状态和修复断言来自共享语句清单（registry）（SHA-256 \u003ccode\u003ed05a26e56716c5c8c178f741843e6b14be87423ec9d1eb1a026ff67a57ce4658\u003c/code\u003e）；\u003ca href=\"#sources\" rel=\"nofollow\"\u003e结构化证据\u003c/a\u003e。\u003c/p\u003e\n\u003cp\u003e作者证据 ID：\u003ccode\u003eidentity\u003c/code\u003e、\u003ccode\u003etimeout-path\u003c/code\u003e、\u003ccode\u003eruntime\u003c/code\u003e、\u003ccode\u003eruntime.version-boundary\u003c/code\u003e。选定基础运行记录：\u003ccode\u003eruntime.25P04-batch2c-latest-20260909.latest\u003c/code\u003e。单独的边界记录：\u003ccode\u003eruntime.25P04-boundary-pg16-20260909.pg16\u003c/code\u003e 和 \u003ccode\u003eruntime.25P04-boundary-pg17-20260909.pg17\u003c/code\u003e。\u003c/p\u003e\n\u003cp\u003e单独的边界对照已经记录了可用性结果：PG16 返回 \u003ccode\u003e42704\u003c/code\u003e，PG17 继续并实际产生 FATAL \u003ccode\u003e25P04\u003c/code\u003e。这个边界块是分支说明，不能整块一次性粘贴执行。在 PG16 上先执行 \u003ccode\u003eSHOW transaction_timeout\u003c/code\u003e；得到预期的 \u003ccode\u003e42704\u003c/code\u003e 后，如需证明连接仍健康，应在同一连接执行 \u003ccode\u003eSELECT 1\u003c/code\u003e，然后停止，跳过 \u003ccode\u003eSET transaction_timeout\u003c/code\u003e、\u003ccode\u003eBEGIN\u003c/code\u003e 和等待超时。在 PG17 或更高版本上，只有 \u003ccode\u003eSHOW\u003c/code\u003e 成功后才在目标连接执行 \u003ccode\u003eSET transaction_timeout\u003c/code\u003e、记录 PID 并执行 \u003ccode\u003eBEGIN\u003c/code\u003e；随后停止发送查询，由观察连接或日志收集器等待旧连接出现 FATAL 并关闭，最后只在新连接上执行探测。这些边界记录用于诊断对照，不增加选定基础案例数量。\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e-- availability_probe\nSHOW transaction_timeout;\n-- set_timeout\nSET transaction_timeout = \u0026#39;300ms\u0026#39;;\n-- backend_pid\nSELECT pg_backend_pid();\n-- begin\nBEGIN;\n-- probe\nSELECT 1;\n\u003c/code\u003e\u003c/pre\u003e\n\u003ch2\u003e版本与边界 {#versions}\u003c/h2\u003e\n\u003cp\u003e锁定目录首次观察到 \u003ccode\u003etransaction_timeout\u003c/code\u003e 为 17.0。选定的 18.6 案例以 CSV/JSON 日志收集证据和新连接探测通过。单独的 PG17.11 边界案例实际记录了 FATAL \u003ccode\u003e25P04\u003c/code\u003e，PG16.15 则记录设置不可用的 \u003ccode\u003e42704\u003c/code\u003e；两者都不替代选定基础运行。PG10 是真实的 \u003ccode\u003enot_applicable\u003c/code\u003e 最低版本预检跳过：handler 不会发送或探测未知设置，因此这不构成更早版本边界证据。\u003c/p\u003e\n\u003ch2\u003e相关 {#related}\u003c/h2\u003e\n\u003cp\u003e\u003ca href=\"/wiki/sqlstate/25P03/\" rel=\"nofollow\"\u003e25P03 事务中空闲超时\u003c/a\u003e、\u003ca href=\"/wiki/sqlstate/40001/\" rel=\"nofollow\"\u003e40001 可串行化失败\u003c/a\u003e、\u003ca href=\"/wiki/sqlstate/57014/\" rel=\"nofollow\"\u003e57014 查询取消\u003c/a\u003e。\u003c/p\u003e\n\u003ch2\u003e来源 {#sources}\u003c/h2\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt\" rel=\"nofollow\"\u003e\u003ccode\u003esrc.errcodes.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003esrc.calls.REL_18_6\u003c/code\u003e — \u003ccode\u003eraw/calls/REL_18_6.jsonl\u003c/code\u003e (SHA-256 \u003ccode\u003e9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3473-L3501\" rel=\"nofollow\"\u003e\u003ccode\u003esrc.postgres.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10252-L10347\" rel=\"nofollow\"\u003e\u003ccode\u003esrc.config.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003effca322c15315ba670733d6b320f23cbba7374db0d18937298ffc07b58799ef6\u003c/code\u003e) · \u003ca href=\"/docs/18/runtime-config-client.html\" rel=\"nofollow\"\u003eofficial documentation\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/monitoring.sgml#L706-L875\" rel=\"nofollow\"\u003e\u003ccode\u003edoc.monitoring.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e06b147f8d966fe46821871703ffcee8a3449cc3f7de5b64b9177f48569fe96f6\u003c/code\u003e) · \u003ca href=\"/docs/18/monitoring-stats.html\" rel=\"nofollow\"\u003e官方监控文档\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/system_views.sql#L604-L605\" rel=\"nofollow\"\u003e\u003ccode\u003esrc.system_views.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e418f4ae7472fe0742e6fbdc7a055581602c5131e082aa6f17e2c7269bf711972\u003c/code\u003e) · \u003ca href=\"/docs/18/view-pg-settings.html\" rel=\"nofollow\"\u003e官方 \u003ccode\u003epg_settings\u003c/code\u003e 文档\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/protocol.sgml#L61-L65\" rel=\"nofollow\"\u003e\u003ccode\u003edoc.protocol.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e745339e07ebbc2bb67d98b258e25772ada644ef26011e3cd6b3fcbb435235f89\u003c/code\u003e) · \u003ca href=\"/docs/18/protocol.html\" rel=\"nofollow\"\u003e官方协议文档\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n","SourceRevision":"english-manuals:978606527e6134aa67f519a3abfcd9b4b446e0fe2ac90ab13a12c74630d5908f","ContentHash":"00cbf1db0ef3dc12b4c8e9c6b1ca9cb0002f55dc654530dadd965bb6e20b7803","Payload":{"body_md":"# 25P04 — 事务超时（transaction_timeout）\n\n## 速览 {#at-a-glance}\n\n`25P04` 是 `transaction_timeout` 触发的 FATAL 条件，覆盖显式 `BEGIN` 事务和由单条语句隐式启动的事务。选定的 18.6 案例使用 300 ms；PG10 因设置不可用而在源码/版本预检阶段跳过，不会探测未知设置。另有 PG16.15/PG17.11 的版本边界对照：PG16 返回设置不可用的 `42704`，PG17 实际产生 FATAL `25P04`；该对照独立于选定基础案例。\n\n\n## 含义 {#meaning}\n\n`transaction_timeout` 限制显式或隐式事务的存活时间，包括事务打开期间执行或等待的时间。触发后 PostgreSQL 发出 `terminating connection due to transaction timeout` 并终止会话。它不同于只中止一条语句的 `statement_timeout`，也不同于只覆盖客户端在开放事务中空闲时间的 `idle_in_transaction_session_timeout`。若 `transaction_timeout` 小于或等于其中任一设置，较长的超时会被忽略；预备事务不受此设置约束。\n\n## 诊断 {#diagnosis}\n\n在支持该设置的服务器上，先在目标会话自身检查有效的 `SHOW transaction_timeout`、`SHOW statement_timeout` 和 `SHOW idle_in_transaction_session_timeout`。控制连接上的 `SHOW` 或 `pg_settings` 反映的是观察者后端，不能用来确认另一个会话实际通过 `SET` 得到的值。再从控制连接查看 `pg_stat_activity` 的 `pid`、`application_name`、`state`、`xact_start`、`state_change`、`query_start`、`query` 等字段，定位所属应用或连接池，并判断事务是在执行还是空闲。按 backend PID、SQLSTATE 25P04、`error_severity = FATAL` 和精确报文匹配日志收集器记录。选定的 18.6 运行中驱动也暴露了 25P04，原连接已关闭；新的连接成功执行 `SELECT 1`。PG10 在发送 `SET transaction_timeout` 之前就由最低版本预检跳过。\n\n## 处理 {#response}\n\n丢弃已终止的会话并重连。对合法的长事务，可缩短工作、拆分工作单元或提高有效超时以控制在预算内；不要为了掩盖错误而降低超时。只有部署明确接受取消该保护时才设为 `0`。服务器关闭终止的会话时会在退出前回滚开放且尚未完成的事务；死亡连接不能再接收 `ROLLBACK`。已知尚未在该会话上提交的事务，不能通过该连接恢复。若另一种网络故障使客户端无法确定 `COMMIT` 是否到达服务器，应从新连接对账业务结果再重试；选定案例没有发送提交，不能据此声称存在这种不确定性。本批 PG10 没有兼容设置。\n\n## FATAL 报文 {#messages}\n\n服务器源码固定报出 `terminating connection due to transaction timeout`，严重级别为 `FATAL`；原连接会被终止。\n\n## 实测诊断 {#observed}\n\n`18.6 (Homebrew) / latest`：FATAL SQLSTATE `25P04`；主报文 `terminating connection due to transaction timeout`；backend PID `30576`；原连接已关闭 `True`；CSV 日志 `25P04`；JSON 日志 `25P04`；新连接探测 `1`。\n`10.21 (Debian 10.21-1.pgdg90+1) / pg10`：案例 `not_applicable`（最低版本预检；未探测该目标不支持的设置）。\n\n单独的边界对照：`16.15 / pg16` 因设置不可用返回 `42704` 并保持 `IDLE`，因此不计作 25P04 覆盖；`17.11 / pg17` 在 300 ms 后由 PID `73` 产生 FATAL `25P04`，CSV 与 JSON 都记录 FATAL `25P04`，原连接关闭，新连接为 `IDLE`。这些记录不计入选定基础案例。\n\n## 代表案例 {#case}\n\n下列 SQL 片段不是一次性粘贴脚本：在测试连接上执行设置、PID 和 `BEGIN` 后停止发送查询，由独立观察连接或日志收集器等待 FATAL；原连接终止后，另开新连接执行最后的探测。运行器从共享语句清单（registry）读取这些语句，完整断言、日志收集器关联、环境和清理见 [案例导出](#cases)。\n\n```sql\n-- set_timeout\nSET transaction_timeout = '300ms';\n-- backend_pid\nSELECT pg_backend_pid();\n-- begin\nBEGIN;\n-- probe\nSELECT 1;\n```\n\n上述片段的 SQLSTATE、诊断、状态和修复断言来自共享语句清单（registry）（SHA-256 `d05a26e56716c5c8c178f741843e6b14be87423ec9d1eb1a026ff67a57ce4658`）；[结构化证据](#sources)。\n\n作者证据 ID：`identity`、`timeout-path`、`runtime`、`runtime.version-boundary`。选定基础运行记录：`runtime.25P04-batch2c-latest-20260909.latest`。单独的边界记录：`runtime.25P04-boundary-pg16-20260909.pg16` 和 `runtime.25P04-boundary-pg17-20260909.pg17`。\n\n单独的边界对照已经记录了可用性结果：PG16 返回 `42704`，PG17 继续并实际产生 FATAL `25P04`。这个边界块是分支说明，不能整块一次性粘贴执行。在 PG16 上先执行 `SHOW transaction_timeout`；得到预期的 `42704` 后，如需证明连接仍健康，应在同一连接执行 `SELECT 1`，然后停止，跳过 `SET transaction_timeout`、`BEGIN` 和等待超时。在 PG17 或更高版本上，只有 `SHOW` 成功后才在目标连接执行 `SET transaction_timeout`、记录 PID 并执行 `BEGIN`；随后停止发送查询，由观察连接或日志收集器等待旧连接出现 FATAL 并关闭，最后只在新连接上执行探测。这些边界记录用于诊断对照，不增加选定基础案例数量。\n\n```sql\n-- availability_probe\nSHOW transaction_timeout;\n-- set_timeout\nSET transaction_timeout = '300ms';\n-- backend_pid\nSELECT pg_backend_pid();\n-- begin\nBEGIN;\n-- probe\nSELECT 1;\n```\n\n## 版本与边界 {#versions}\n\n锁定目录首次观察到 `transaction_timeout` 为 17.0。选定的 18.6 案例以 CSV/JSON 日志收集证据和新连接探测通过。单独的 PG17.11 边界案例实际记录了 FATAL `25P04`，PG16.15 则记录设置不可用的 `42704`；两者都不替代选定基础运行。PG10 是真实的 `not_applicable` 最低版本预检跳过：handler 不会发送或探测未知设置，因此这不构成更早版本边界证据。\n\n## 相关 {#related}\n\n[25P03 事务中空闲超时](/wiki/sqlstate/25P03/)、[40001 可串行化失败](/wiki/sqlstate/40001/)、[57014 查询取消](/wiki/sqlstate/57014/)。\n\n## 来源 {#sources}\n\n- [`src.errcodes.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt) (SHA-256 `6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba`)\n- `src.calls.REL_18_6` — `raw/calls/REL_18_6.jsonl` (SHA-256 `9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf`)\n- [`src.postgres.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3473-L3501) (SHA-256 `9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061`)\n- [`src.config.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10252-L10347) (SHA-256 `ffca322c15315ba670733d6b320f23cbba7374db0d18937298ffc07b58799ef6`) · [official documentation](/docs/18/runtime-config-client.html)\n- [`doc.monitoring.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/monitoring.sgml#L706-L875) (SHA-256 `06b147f8d966fe46821871703ffcee8a3449cc3f7de5b64b9177f48569fe96f6`) · [官方监控文档](/docs/18/monitoring-stats.html)\n- [`src.system_views.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/system_views.sql#L604-L605) (SHA-256 `418f4ae7472fe0742e6fbdc7a055581602c5131e082aa6f17e2c7269bf711972`) · [官方 `pg_settings` 文档](/docs/18/view-pg-settings.html)\n- [`doc.protocol.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/protocol.sgml#L61-L65) (SHA-256 `745339e07ebbc2bb67d98b258e25772ada644ef26011e3cd6b3fcbb435235f89`) · [官方协议文档](/docs/18/protocol.html)\n","description":"PostgreSQL SQLSTATE 25P04：显式或隐式事务超过 transaction_timeout 后终止会话。","is_stale":false,"name":"事务超时","sections":[{"anchor":"","heading":"","html":"\u0026lt;h1\u0026gt;25P04 — 事务超时（transaction_timeout）\u0026lt;/h1\u0026gt;"},{"anchor":"at-a-glance","heading":"速览","html":"\u003cp\u003e\u003ccode\u003e25P04\u003c/code\u003e 是 \u003ccode\u003etransaction_timeout\u003c/code\u003e 触发的 FATAL 条件，覆盖显式 \u003ccode\u003eBEGIN\u003c/code\u003e 事务和由单条语句隐式启动的事务。选定的 18.6 案例使用 300 ms；PG10 因设置不可用而在源码/版本预检阶段跳过，不会探测未知设置。另有 PG16.15/PG17.11 的版本边界对照：PG16 返回设置不可用的 \u003ccode\u003e42704\u003c/code\u003e，PG17 实际产生 FATAL \u003ccode\u003e25P04\u003c/code\u003e；该对照独立于选定基础案例。\u003c/p\u003e"},{"anchor":"meaning","heading":"含义","html":"\u003cp\u003e\u003ccode\u003etransaction_timeout\u003c/code\u003e 限制显式或隐式事务的存活时间，包括事务打开期间执行或等待的时间。触发后 PostgreSQL 发出 \u003ccode\u003eterminating connection due to transaction timeout\u003c/code\u003e 并终止会话。它不同于只中止一条语句的 \u003ccode\u003estatement_timeout\u003c/code\u003e，也不同于只覆盖客户端在开放事务中空闲时间的 \u003ccode\u003eidle_in_transaction_session_timeout\u003c/code\u003e。若 \u003ccode\u003etransaction_timeout\u003c/code\u003e 小于或等于其中任一设置，较长的超时会被忽略；预备事务不受此设置约束。\u003c/p\u003e"},{"anchor":"diagnosis","heading":"诊断","html":"\u003cp\u003e在支持该设置的服务器上，先在目标会话自身检查有效的 \u003ccode\u003eSHOW transaction_timeout\u003c/code\u003e、\u003ccode\u003eSHOW statement_timeout\u003c/code\u003e 和 \u003ccode\u003eSHOW idle_in_transaction_session_timeout\u003c/code\u003e。控制连接上的 \u003ccode\u003eSHOW\u003c/code\u003e 或 \u003ccode\u003epg_settings\u003c/code\u003e 反映的是观察者后端，不能用来确认另一个会话实际通过 \u003ccode\u003eSET\u003c/code\u003e 得到的值。再从控制连接查看 \u003ccode\u003epg_stat_activity\u003c/code\u003e 的 \u003ccode\u003epid\u003c/code\u003e、\u003ccode\u003eapplication_name\u003c/code\u003e、\u003ccode\u003estate\u003c/code\u003e、\u003ccode\u003exact_start\u003c/code\u003e、\u003ccode\u003estate_change\u003c/code\u003e、\u003ccode\u003equery_start\u003c/code\u003e、\u003ccode\u003equery\u003c/code\u003e 等字段，定位所属应用或连接池，并判断事务是在执行还是空闲。按 backend PID、SQLSTATE 25P04、\u003ccode\u003eerror_severity = FATAL\u003c/code\u003e 和精确报文匹配日志收集器记录。选定的 18.6 运行中驱动也暴露了 25P04，原连接已关闭；新的连接成功执行 \u003ccode\u003eSELECT 1\u003c/code\u003e。PG10 在发送 \u003ccode\u003eSET transaction_timeout\u003c/code\u003e 之前就由最低版本预检跳过。\u003c/p\u003e"},{"anchor":"response","heading":"处理","html":"\u003cp\u003e丢弃已终止的会话并重连。对合法的长事务，可缩短工作、拆分工作单元或提高有效超时以控制在预算内；不要为了掩盖错误而降低超时。只有部署明确接受取消该保护时才设为 \u003ccode\u003e0\u003c/code\u003e。服务器关闭终止的会话时会在退出前回滚开放且尚未完成的事务；死亡连接不能再接收 \u003ccode\u003eROLLBACK\u003c/code\u003e。已知尚未在该会话上提交的事务，不能通过该连接恢复。若另一种网络故障使客户端无法确定 \u003ccode\u003eCOMMIT\u003c/code\u003e 是否到达服务器，应从新连接对账业务结果再重试；选定案例没有发送提交，不能据此声称存在这种不确定性。本批 PG10 没有兼容设置。\u003c/p\u003e"},{"anchor":"messages","heading":"FATAL 报文","html":"\u003cp\u003e服务器源码固定报出 \u003ccode\u003eterminating connection due to transaction timeout\u003c/code\u003e，严重级别为 \u003ccode\u003eFATAL\u003c/code\u003e；原连接会被终止。\u003c/p\u003e"},{"anchor":"observed","heading":"实测诊断","html":"\u003cp\u003e\u003ccode\u003e18.6 (Homebrew) / latest\u003c/code\u003e：FATAL SQLSTATE \u003ccode\u003e25P04\u003c/code\u003e；主报文 \u003ccode\u003eterminating connection due to transaction timeout\u003c/code\u003e；backend PID \u003ccode\u003e30576\u003c/code\u003e；原连接已关闭 \u003ccode\u003eTrue\u003c/code\u003e；CSV 日志 \u003ccode\u003e25P04\u003c/code\u003e；JSON 日志 \u003ccode\u003e25P04\u003c/code\u003e；新连接探测 \u003ccode\u003e1\u003c/code\u003e。\n\u003ccode\u003e10.21 (Debian 10.21-1.pgdg90+1) / pg10\u003c/code\u003e：案例 \u003ccode\u003enot_applicable\u003c/code\u003e（最低版本预检；未探测该目标不支持的设置）。\u003c/p\u003e\n\u003cp\u003e单独的边界对照：\u003ccode\u003e16.15 / pg16\u003c/code\u003e 因设置不可用返回 \u003ccode\u003e42704\u003c/code\u003e 并保持 \u003ccode\u003eIDLE\u003c/code\u003e，因此不计作 25P04 覆盖；\u003ccode\u003e17.11 / pg17\u003c/code\u003e 在 300 ms 后由 PID \u003ccode\u003e73\u003c/code\u003e 产生 FATAL \u003ccode\u003e25P04\u003c/code\u003e，CSV 与 JSON 都记录 FATAL \u003ccode\u003e25P04\u003c/code\u003e，原连接关闭，新连接为 \u003ccode\u003eIDLE\u003c/code\u003e。这些记录不计入选定基础案例。\u003c/p\u003e"},{"anchor":"case","heading":"代表案例","html":"\u003cp\u003e下列 SQL 片段不是一次性粘贴脚本：在测试连接上执行设置、PID 和 \u003ccode\u003eBEGIN\u003c/code\u003e 后停止发送查询，由独立观察连接或日志收集器等待 FATAL；原连接终止后，另开新连接执行最后的探测。运行器从共享语句清单（registry）读取这些语句，完整断言、日志收集器关联、环境和清理见 \u003ca href=\"#cases\"\u003e案例导出\u003c/a\u003e。\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"language-sql\"\u003e-- set_timeout\nSET transaction_timeout = '300ms';\n-- backend_pid\nSELECT pg_backend_pid();\n-- begin\nBEGIN;\n-- probe\nSELECT 1;\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e上述片段的 SQLSTATE、诊断、状态和修复断言来自共享语句清单（registry）（SHA-256 \u003ccode\u003ed05a26e56716c5c8c178f741843e6b14be87423ec9d1eb1a026ff67a57ce4658\u003c/code\u003e）；\u003ca href=\"#sources\"\u003e结构化证据\u003c/a\u003e。\u003c/p\u003e\n\u003cp\u003e作者证据 ID：\u003ccode\u003eidentity\u003c/code\u003e、\u003ccode\u003etimeout-path\u003c/code\u003e、\u003ccode\u003eruntime\u003c/code\u003e、\u003ccode\u003eruntime.version-boundary\u003c/code\u003e。选定基础运行记录：\u003ccode\u003eruntime.25P04-batch2c-latest-20260909.latest\u003c/code\u003e。单独的边界记录：\u003ccode\u003eruntime.25P04-boundary-pg16-20260909.pg16\u003c/code\u003e 和 \u003ccode\u003eruntime.25P04-boundary-pg17-20260909.pg17\u003c/code\u003e。\u003c/p\u003e\n\u003cp\u003e单独的边界对照已经记录了可用性结果：PG16 返回 \u003ccode\u003e42704\u003c/code\u003e，PG17 继续并实际产生 FATAL \u003ccode\u003e25P04\u003c/code\u003e。这个边界块是分支说明，不能整块一次性粘贴执行。在 PG16 上先执行 \u003ccode\u003eSHOW transaction_timeout\u003c/code\u003e；得到预期的 \u003ccode\u003e42704\u003c/code\u003e 后，如需证明连接仍健康，应在同一连接执行 \u003ccode\u003eSELECT 1\u003c/code\u003e，然后停止，跳过 \u003ccode\u003eSET transaction_timeout\u003c/code\u003e、\u003ccode\u003eBEGIN\u003c/code\u003e 和等待超时。在 PG17 或更高版本上，只有 \u003ccode\u003eSHOW\u003c/code\u003e 成功后才在目标连接执行 \u003ccode\u003eSET transaction_timeout\u003c/code\u003e、记录 PID 并执行 \u003ccode\u003eBEGIN\u003c/code\u003e；随后停止发送查询，由观察连接或日志收集器等待旧连接出现 FATAL 并关闭，最后只在新连接上执行探测。这些边界记录用于诊断对照，不增加选定基础案例数量。\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"language-sql\"\u003e-- availability_probe\nSHOW transaction_timeout;\n-- set_timeout\nSET transaction_timeout = '300ms';\n-- backend_pid\nSELECT pg_backend_pid();\n-- begin\nBEGIN;\n-- probe\nSELECT 1;\n\u003c/code\u003e\u003c/pre\u003e"},{"anchor":"versions","heading":"版本与边界","html":"\u003cp\u003e锁定目录首次观察到 \u003ccode\u003etransaction_timeout\u003c/code\u003e 为 17.0。选定的 18.6 案例以 CSV/JSON 日志收集证据和新连接探测通过。单独的 PG17.11 边界案例实际记录了 FATAL \u003ccode\u003e25P04\u003c/code\u003e，PG16.15 则记录设置不可用的 \u003ccode\u003e42704\u003c/code\u003e；两者都不替代选定基础运行。PG10 是真实的 \u003ccode\u003enot_applicable\u003c/code\u003e 最低版本预检跳过：handler 不会发送或探测未知设置，因此这不构成更早版本边界证据。\u003c/p\u003e"},{"anchor":"related","heading":"相关","html":"\u003cp\u003e\u003ca href=\"/wiki/sqlstate/25P03/\"\u003e25P03 事务中空闲超时\u003c/a\u003e、\u003ca href=\"/wiki/sqlstate/40001/\"\u003e40001 可串行化失败\u003c/a\u003e、\u003ca href=\"/wiki/sqlstate/57014/\"\u003e57014 查询取消\u003c/a\u003e。\u003c/p\u003e"},{"anchor":"sources","heading":"来源","html":"\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt\"\u003e\u003ccode\u003esrc.errcodes.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003esrc.calls.REL_18_6\u003c/code\u003e — \u003ccode\u003eraw/calls/REL_18_6.jsonl\u003c/code\u003e (SHA-256 \u003ccode\u003e9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3473-L3501\"\u003e\u003ccode\u003esrc.postgres.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061\u003c/code\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10252-L10347\"\u003e\u003ccode\u003esrc.config.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003effca322c15315ba670733d6b320f23cbba7374db0d18937298ffc07b58799ef6\u003c/code\u003e) · \u003ca href=\"/docs/18/runtime-config-client.html\"\u003eofficial documentation\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/monitoring.sgml#L706-L875\"\u003e\u003ccode\u003edoc.monitoring.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e06b147f8d966fe46821871703ffcee8a3449cc3f7de5b64b9177f48569fe96f6\u003c/code\u003e) · \u003ca href=\"/docs/18/monitoring-stats.html\"\u003e官方监控文档\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/system_views.sql#L604-L605\"\u003e\u003ccode\u003esrc.system_views.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e418f4ae7472fe0742e6fbdc7a055581602c5131e082aa6f17e2c7269bf711972\u003c/code\u003e) · \u003ca href=\"/docs/18/view-pg-settings.html\"\u003e官方 \u003ccode\u003epg_settings\u003c/code\u003e 文档\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/protocol.sgml#L61-L65\"\u003e\u003ccode\u003edoc.protocol.18.6\u003c/code\u003e\u003c/a\u003e (SHA-256 \u003ccode\u003e745339e07ebbc2bb67d98b258e25772ada644ef26011e3cd6b3fcbb435235f89\u003c/code\u003e) · \u003ca href=\"/docs/18/protocol.html\"\u003e官方协议文档\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e"}],"summary":"事务运行超过 transaction_timeout 被终止。","title":"25P04 — 事务超时（transaction_timeout）","translation_source_rev":"049f333bc37c02c37a782fdd88275bfb3ad73fd5449a35c81db7dee5b4565fe3"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":{"aliases":[],"catalogue_notes":{"earliest_observed":"17.0","formal_scope":"9.0.0..18.6","latest_observed":"18.6","matrix_scope":["9.0.23","9.1.24","9.2.24","9.3.25","9.4.26","9.5.25","9.6.24","10.23","11.22","12.22","13.23","14.24","15.19","16.15","17.11","18.6"],"pre9_scope":{"formal_tag_count":191,"maximum_release":"8.4.22","minimum_release":"7.0.0","source_definition_count":153,"source_doc_count":153,"source_file_count":306,"source_scope":"7.4..8.4 definition files; 7.0..7.3 candidate-path source gap probes","source_tag_count":153},"pre9_status":"not_observed","preview_scope":["19beta3"]},"class":"25","class_name":"Invalid Transaction State","condition_name":"transaction_timeout","condition_names":["transaction_timeout"],"definition_changes":[],"english_manuals":{"17":{"aliases":[],"class_name":"Invalid Transaction State","condition_name":"transaction_timeout","doc":{"anchor":"ERRCODES-APPENDIX","file":"errcodes-appendix.html","lang":"en","sha256":"868135520af87351e3ea1ba42656111cbd2d157d98e1fef05ea158ac5729d8b1","slug":"17"},"lang":"en","sqlstate":"25P04"},"18":{"aliases":[],"class_name":"Invalid Transaction State","condition_name":"transaction_timeout","doc":{"anchor":"ERRCODES-APPENDIX","file":"errcodes-appendix.html","lang":"en","sha256":"56dacf78e618ff0fd8c533e05db597b80d7ebbad7f8e512a888217d0640aa328","slug":"18"},"lang":"en","sqlstate":"25P04"},"19":{"aliases":[],"class_name":"Invalid Transaction State","condition_name":"transaction_timeout","doc":{"anchor":"ERRCODES-APPENDIX","file":"errcodes-appendix.html","lang":"en","sha256":"63fb8d1aa9f494eeab9d0f8542a2b673f7746ee41ae2689d19403cb3cc425a5c","slug":"19"},"lang":"en","sqlstate":"25P04"},"20":{"aliases":[],"class_name":"Invalid Transaction State","condition_name":"transaction_timeout","doc":{"anchor":"ERRCODES-APPENDIX","file":"errcodes-appendix.html","lang":"en","sha256":"0d3f602127cd137cf343b32d5fa78f175eeb6cdcb6353b1f6f998ede6cb7b911","slug":"devel"},"lang":"en","sqlstate":"25P04"}},"history_boundary":{"earliest_observed":"17.0","formal_tag_count":351,"gaps":[{"after":"18.6","before":"18.4","reason":"Non-adjacent release tags or a source gap; no removal is inferred."}],"latest_observed":"18.6","pre_range":{"first_observed":null,"known_lower_bound":null,"last_observed":null,"notes":"No occurrence was observed in the locked 7.4..8.4 definition files. Source gaps for 7.0..7.3 prevent a claim that the code was absent before 7.4.","scanned_formal_release_count":153,"scanned_source_scope":"7.4..8.4 definition files; 7.0..7.3 candidate-path source gap probes","source_gap_majors":["7.0","7.1","7.2","7.3"],"status":"partially_scanned"},"preview_snapshots":["19beta3"],"scanned_from":"9.0.0","scanned_to":"18.6"},"introduced":null,"known_present_by":"17.0","macros":["ERRCODE_TRANSACTION_TIMEOUT"],"manual_presence":["17","18","19","20"],"pre9_first_observed":null,"pre9_introduction_boundary":null,"pre9_last_observed":null,"pre9_presence_intervals":[],"pre9_status":"not_observed","presence_intervals":[{"end":"17.11","end_major":"17","end_tag":"REL_17_11","evidence_count":12,"position":0,"start":"17.0","start_major":"17","start_tag":"REL_17_0"},{"end":"18.4","end_major":"18","end_tag":"REL_18_4","evidence_count":5,"position":1,"start":"18.0","start_major":"18","start_tag":"REL_18_0"},{"end":"18.6","end_major":"18","end_tag":"REL_18_6","evidence_count":1,"position":2,"start":"18.6","start_major":"18","start_tag":"REL_18_6"}],"present_in_snapshots":["17.11","18.6","19beta3"],"preview_in_snapshots":["19beta3"],"primary_macro":"ERRCODE_TRANSACTION_TIMEOUT","removed":null,"schema_version":2,"severity_classes":["E"],"sources":[{"blob_id":"sha256:bb53279934510355eb4135a807c90d989f07650bd90f87026a4441f11d3296b1","channel":"formal","code_count":260,"commit":"d7ec59a63d745ba74fba0e280bbf85dc6d1caa3e","id":"postgresql:REL_17_0:src/backend/utils/errcodes.txt","major":"17","parsed_path":"raw/definitions/REL_17_0.parsed.json","path":"src/backend/utils/errcodes.txt","raw_path":"raw/definitions/REL_17_0.txt","raw_url":"https://raw.githubusercontent.com/postgres/postgres/d7ec59a63d745ba74fba0e280bbf85dc6d1caa3e/src/backend/utils/errcodes.txt","record_count":266,"release":"17.0","release_date":null,"repository":"https://github.com/postgres/postgres.git","sha256":"bb53279934510355eb4135a807c90d989f07650bd90f87026a4441f11d3296b1","size":33392,"source_format":"errcodes.txt","source_role":"primary_definition","tag":"REL_17_0","url":"https://github.com/postgres/postgres/blob/d7ec59a63d745ba74fba0e280bbf85dc6d1caa3e/src/backend/utils/errcodes.txt","version":"17.0"},{"blob_id":"sha256:6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba","channel":"formal","code_count":262,"commit":"3d6a828938a5fa0444275d3d2f67b64ec3199eb7","id":"postgresql:REL_18_0:src/backend/utils/errcodes.txt","major":"18","parsed_path":"raw/definitions/REL_18_0.parsed.json","path":"src/backend/utils/errcodes.txt","raw_path":"raw/definitions/REL_18_0.txt","raw_url":"https://raw.githubusercontent.com/postgres/postgres/3d6a828938a5fa0444275d3d2f67b64ec3199eb7/src/backend/utils/errcodes.txt","record_count":268,"release":"18.0","release_date":null,"repository":"https://github.com/postgres/postgres.git","sha256":"6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba","size":33739,"source_format":"errcodes.txt","source_role":"primary_definition","tag":"REL_18_0","url":"https://github.com/postgres/postgres/blob/3d6a828938a5fa0444275d3d2f67b64ec3199eb7/src/backend/utils/errcodes.txt","version":"18.0"},{"blob_id":"sha256:cadb9e83cde9a8699a7e74448891ca623af8579ccc8e11c7e533fb47cbc42f89","channel":"preview","code_count":262,"commit":"3638289fb57bdabec00deda98ee9624a35f5d66a","id":"postgresql:REL_19_BETA3:src/backend/utils/errcodes.txt","major":"19","parsed_path":"raw/definitions/REL_19_BETA3.parsed.json","path":"src/backend/utils/errcodes.txt","raw_path":"raw/definitions/REL_19_BETA3.txt","raw_url":"https://raw.githubusercontent.com/postgres/postgres/3638289fb57bdabec00deda98ee9624a35f5d66a/src/backend/utils/errcodes.txt","record_count":268,"release":"19beta3","release_date":"2026-08-13","repository":"https://github.com/postgres/postgres.git","sha256":"cadb9e83cde9a8699a7e74448891ca623af8579ccc8e11c7e533fb47cbc42f89","size":33739,"source_format":"errcodes.txt","source_role":"primary_definition","tag":"REL_19_BETA3","url":"https://github.com/postgres/postgres/blob/3638289fb57bdabec00deda98ee9624a35f5d66a/src/backend/utils/errcodes.txt","version":"19beta3"}],"sqlstate":"25P04","status":"active","usage_evidence":[{"evidence_ids":["postgresql:REL_17_0:src/backend/utils/errcodes.txt","postgresql:REL_17_10:src/backend/utils/errcodes.txt","postgresql:REL_17_11:src/backend/utils/errcodes.txt","postgresql:REL_17_1:src/backend/utils/errcodes.txt","postgresql:REL_17_2:src/backend/utils/errcodes.txt","postgresql:REL_17_3:src/backend/utils/errcodes.txt","postgresql:REL_17_4:src/backend/utils/errcodes.txt","postgresql:REL_17_5:src/backend/utils/errcodes.txt","postgresql:REL_17_6:src/backend/utils/errcodes.txt","postgresql:REL_17_7:src/backend/utils/errcodes.txt","postgresql:REL_17_8:src/backend/utils/errcodes.txt","postgresql:REL_17_9:src/backend/utils/errcodes.txt","postgresql:REL_18_0:src/backend/utils/errcodes.txt","postgresql:REL_18_1:src/backend/utils/errcodes.txt","postgresql:REL_18_2:src/backend/utils/errcodes.txt","postgresql:REL_18_3:src/backend/utils/errcodes.txt","postgresql:REL_18_4:src/backend/utils/errcodes.txt","postgresql:REL_18_6:src/backend/utils/errcodes.txt","postgresql:REL_19_BETA3:src/backend/utils/errcodes.txt"],"notes":"Presence in a PostgreSQL release definition file is established; runtime throw/use scanning is maintained separately.","scope":"release-definition-catalogue","status":"definition_only"},{"evidence_ids":[],"notes":"No occurrence was found in the locked 7.4..8.4 definition files; 7.0..7.3 source gaps remain explicit.","scope":"pre9-definition-history","status":"unknown"}]},"Evidence":[{"Kind":"cases","Ordinal":0,"ID":"transaction_timeout","ServerVersion":null,"Status":null,"Payload":{"assertions":["The original session is terminated by the timeout when supported","The collector records FATAL 25P04 for the matching backend PID","A fresh connection can execute SELECT 1","PG10 is explicitly not applicable"],"case_id":"transaction_timeout","cleanup":"Drop the case schema with an owner connection.","has_snippet":true,"position":0,"preconditions":["A runner-owned disposable target is provisioned."],"repair":"Use the state-specific recovery documented on the page; do not reuse a terminated connection.","trigger":"On a server supporting transaction_timeout, set it, BEGIN, wait, and probe the terminated session.","versions":["18"]}},{"Kind":"cases","Ordinal":1,"ID":"transaction_timeout_version_boundary","ServerVersion":null,"Status":null,"Payload":{"assertions":["PG16 records the actual unsupported-setting diagnostic and recovers","PG17 records exact FATAL 25P04 collector fields and a registry-based fresh connection probe"],"case_id":"transaction_timeout_version_boundary","cleanup":"Drop the case schema with an owner connection.","has_snippet":true,"position":1,"preconditions":["A disposable PostgreSQL 16 or 17 target"],"repair":"Treat PG16 as unsupported for this setting; for PG17 use a fresh connection after the FATAL and determine unfinished work from the application transaction boundary.","trigger":"Probe transaction_timeout on PG16; on PG17 set it, BEGIN, wait, and probe the terminated session.","versions":["16","17"]}},{"Kind":"claims","Ordinal":0,"ID":"identity","ServerVersion":null,"Status":null,"Payload":{"claim_id":"identity","limits":"The locked catalogue first observes this condition in PostgreSQL 17.0; no earlier runtime claim is made.","method":"Read the fixed condition row and macro.","position":0,"runtime":[],"sources":["src.errcodes.18.6"],"statement":"25P04 is transaction_timeout in Class 25."}},{"Kind":"claims","Ordinal":1,"ID":"timeout-path","ServerVersion":null,"Status":null,"Payload":{"claim_id":"timeout-path","limits":"The selected PG10 target lacks this setting and is explicitly not applicable; the session is terminated when the path fires.","method":"Trace the timeout interrupt and the fixed configuration documentation.","position":1,"runtime":[],"sources":["src.postgres.18.6","src.config.18.6","src.calls.REL_18_6"],"statement":"ProcessInterrupts emits FATAL 25P04 when an explicit or implicitly started transaction exceeds transaction_timeout."}},{"Kind":"claims","Ordinal":2,"ID":"runtime","ServerVersion":null,"Status":null,"Payload":{"claim_id":"runtime","limits":"This verifies 18.6 and the PG10 applicability boundary only; it does not claim all intermediate releases without an adjacent source check.","method":"Match collector records by PID, SQLSTATE, and message, then probe a fresh connection.","position":2,"runtime":[],"sources":["runtime","runtime.25P04-batch2c-latest-20260909.latest","runtime.25P04-batch2c-pg10-20260909.pg10"],"statement":"The selected PostgreSQL 18.6 case received FATAL 25P04 for the exact backend PID and recovered only by opening a fresh connection; the PG10 case is not applicable."}},{"Kind":"claims","Ordinal":3,"ID":"diagnosis-observer-boundary","ServerVersion":null,"Status":null,"Payload":{"claim_id":"diagnosis-observer-boundary","limits":"Visibility of pg_stat_activity fields depends on observer privileges; the selected runtime records establish PID/log correlation, not universal monitoring permissions.","method":"Read the fixed monitoring view documentation and system-view definition before writing the observer/session diagnostic split.","position":3,"runtime":[],"sources":["doc.monitoring.18.6","src.system_views.18.6"],"statement":"The fixed monitoring documentation defines pg_stat_activity as one row per server process with current activity, including xact_start and state_change; pg_settings is defined over pg_show_all_settings for the current backend. Capture timeout settings on the timed session itself, because SHOW or pg_settings on an observer connection cannot establish another backend's effective SET value."}},{"Kind":"claims","Ordinal":4,"ID":"termination-rollback","ServerVersion":null,"Status":null,"Payload":{"claim_id":"termination-rollback","limits":"This establishes server-side rollback on forced connection close; it does not resolve a separate network failure after a client may have sent COMMIT.","method":"Read the fixed protocol session-termination rule and align the recovery prose with the FATAL path.","position":4,"runtime":[],"sources":["doc.protocol.18.6"],"statement":"The fixed protocol documentation states that when the backend closes a connection it rolls back any open incomplete transaction before exiting; the driver cannot send a later ROLLBACK on that closed session."}},{"Kind":"claims","Ordinal":5,"ID":"runtime.version-boundary","ServerVersion":null,"Status":null,"Payload":{"claim_id":"runtime.version-boundary","limits":"This is a bounded PG16.15/PG17.11 comparison for transaction_timeout. PG16 42704 is not 25P04 coverage; the records do not replace the selected 18.6 run or establish every intermediate minor release.","method":"Compare the fixed PG16 availability probe and PG17 timeout summaries, including driver diagnostics, both collector severities, PID correlation, termination, and fresh-connection recovery.","position":5,"runtime":[],"sources":["src.config.18.6","doc.protocol.18.6","runtime.25P04-boundary-pg16-20260909.pg16","runtime.25P04-boundary-pg17-20260909.pg17"],"statement":"On the fixed availability-boundary registry case, PostgreSQL 16.15 rejects SHOW transaction_timeout with 42704 and remains IDLE, while PostgreSQL 17.11 receives FATAL 25P04 after a 300 ms timeout in an idle-in-transaction session; the original session closes and a fresh connection is IDLE."}},{"Kind":"messages","Ordinal":0,"ID":"fatal","ServerVersion":null,"Status":null,"Payload":{"limits":"This is a static FATAL message; the driver may expose or omit SQLSTATE depending on client stack.","message_id":"fatal","path":"","position":0,"raw":{"id":"fatal","limits":"This is a static FATAL message; the driver may expose or omit SQLSTATE depending on client stack.","primary_template":"terminating connection due to transaction timeout","severity_source":"FATAL","sources":["src.postgres.18.6"],"sqlstate":"25P04"},"severity":"FATAL","sources":["src.postgres.18.6"],"templates":[{"kind":"primary","literal":"terminating connection due to transaction timeout","position":0,"role":"","template":"terminating connection due to transaction timeout"}]}},{"Kind":"runtimes","Ordinal":0,"ID":"runtime.25P04-batch2c-latest-20260909.latest","ServerVersion":"18.6 (Homebrew)","Status":"passed","Payload":{"cases":["transaction_timeout"],"limits":"","position":0,"raw":{"case_manifest":{"path":"verify/cases/25P04/cases.json","sha256":"7ec049ed04b847e80c6770278f3dca1b3ef5357d27bada2a2f3e1a98e955e950"},"case_status":"passed","cases":["transaction_timeout"],"id":"runtime.25P04-batch2c-latest-20260909.latest","observed":{"backend_pid":30576,"collector_csv_error_severity":"FATAL","collector_csv_sqlstate":"25P04","collector_json_error_severity":"FATAL","collector_json_sqlstate":"25P04","fresh_connection_probe":1,"fresh_connection_status":"IDLE","original_connection_closed":true,"primary":"terminating connection due to transaction timeout","recovery_requires_new_connection":true,"severity":"FATAL","sqlstate":"25P04","status_before_timeout":"INTRANS"},"raw":"verify/results/25P04-batch2c-latest-20260909/latest/raw.jsonl","raw_sha256":"604f0195a1736b0e1cc25d5dc27daaa39647ecaf6dd4815284abe34c98cc3c1e","run_id":"25P04-batch2c-latest-20260909","server_version":"18.6 (Homebrew)","server_version_num":180006,"snippet_registry":{"path":"verify/cases/25P04/snippets.json","sha256":"d05a26e56716c5c8c178f741843e6b14be87423ec9d1eb1a026ff67a57ce4658"},"status":"passed","summary":"verify/results/25P04-batch2c-latest-20260909/latest/summary.json","summary_sha256":"a01d53576c6c15395d88f85039e10d792fbfc72042fd355c14aea06e779fc20f","target":"latest","target_status":"passed"},"run_id":"25P04-batch2c-latest-20260909","runtime_id":"runtime.25P04-batch2c-latest-20260909.latest","server_version":"18.6 (Homebrew)","status":"passed","target":"latest"}},{"Kind":"runtimes","Ordinal":1,"ID":"runtime.25P04-batch2c-pg10-20260909.pg10","ServerVersion":"10.21 (Debian 10.21-1.pgdg90+1)","Status":"not_applicable","Payload":{"cases":["transaction_timeout"],"limits":"","position":1,"raw":{"case_manifest":{"path":"verify/cases/25P04/cases.json","sha256":"7ec049ed04b847e80c6770278f3dca1b3ef5357d27bada2a2f3e1a98e955e950"},"case_status":"not_applicable","cases":["transaction_timeout"],"id":"runtime.25P04-batch2c-pg10-20260909.pg10","observed":{"case_status":"not_applicable","minimum_version":170000,"preflight":"minimum_version","server_version_num":100021,"setting":"transaction_timeout","setting_probe_skipped":true},"raw":"verify/results/25P04-batch2c-pg10-20260909/pg10/raw.jsonl","raw_sha256":"30249f5670f41a2381d3934a9ab40c9e4317e5831c5d3a1941e0a725d5454260","run_id":"25P04-batch2c-pg10-20260909","server_version":"10.21 (Debian 10.21-1.pgdg90+1)","server_version_num":100021,"snippet_registry":{"path":"verify/cases/25P04/snippets.json","sha256":"d05a26e56716c5c8c178f741843e6b14be87423ec9d1eb1a026ff67a57ce4658"},"status":"not_applicable","summary":"verify/results/25P04-batch2c-pg10-20260909/pg10/summary.json","summary_sha256":"2031245d82e9963d70c7f1b969ebf7a3fc5fd308c646501e9e158a6723dafc05","target":"pg10","target_status":"passed"},"run_id":"25P04-batch2c-pg10-20260909","runtime_id":"runtime.25P04-batch2c-pg10-20260909.pg10","server_version":"10.21 (Debian 10.21-1.pgdg90+1)","status":"not_applicable","target":"pg10"}},{"Kind":"runtimes","Ordinal":2,"ID":"runtime.25P04-boundary-pg16-20260909.pg16","ServerVersion":"16.15 (Debian 16.15-1.pgdg13+2)","Status":"not_applicable","Payload":{"cases":["transaction_timeout_version_boundary"],"limits":"The case passed its availability assertions, but this target does not have the setting. The 42704 probe is retained as a version comparison and is not counted as a 25P04 runtime.","position":2,"raw":{"case_manifest":{"path":"verify/cases/25P04/cases.json","sha256":"84064c260277d4051404d55d1e912d6f6ebafcea2ef681382cf854a0e79ec7ed"},"case_status":"passed","cases":["transaction_timeout_version_boundary"],"id":"runtime.25P04-boundary-pg16-20260909.pg16","limits":"The case passed its availability assertions, but this target does not have the setting. The 42704 probe is retained as a version comparison and is not counted as a 25P04 runtime.","observed":{"availability_primary":"unrecognized configuration parameter \"transaction_timeout\"","availability_severity":"ERROR","availability_sqlstate":"42704","fresh_connection_probe":1,"natural_25P04_observed":false,"setting":"transaction_timeout","status_after_probe":"IDLE"},"raw":"verify/results/25P04-boundary-pg16-20260909/pg16/raw.jsonl","raw_sha256":"80fbaa2148e40c6c9239c68a44d4659f485e18aa8dfcdf4451a2496a609a4ff0","run_id":"25P04-boundary-pg16-20260909","selection_status":"selected_boundary_comparison","server_version":"16.15 (Debian 16.15-1.pgdg13+2)","server_version_num":160015,"snippet_registry":{"path":"verify/cases/25P04/snippets.json","sha256":"b25b99aa679f058e02229dd8d4ecd1ae4af41d11b19f80199f013da118ef3112"},"status":"not_applicable","summary":"verify/results/25P04-boundary-pg16-20260909/pg16/summary.json","summary_sha256":"96faef46bcf544732c797ef975add02a6b06684821a4df7e99448aa2355e08d1","target":"pg16","target_status":"passed"},"run_id":"25P04-boundary-pg16-20260909","runtime_id":"runtime.25P04-boundary-pg16-20260909.pg16","server_version":"16.15 (Debian 16.15-1.pgdg13+2)","status":"not_applicable","target":"pg16"}},{"Kind":"runtimes","Ordinal":3,"ID":"runtime.25P04-boundary-pg17-20260909.pg17","ServerVersion":"17.11 (Debian 17.11-1.pgdg13+2)","Status":"passed","Payload":{"cases":["transaction_timeout_version_boundary"],"limits":"This separate PG17.11 boundary case demonstrates the natural FATAL path and fresh-session recovery; it does not replace or inflate the selected base 18.6 case.","position":3,"raw":{"case_manifest":{"path":"verify/cases/25P04/cases.json","sha256":"84064c260277d4051404d55d1e912d6f6ebafcea2ef681382cf854a0e79ec7ed"},"case_status":"passed","cases":["transaction_timeout_version_boundary"],"id":"runtime.25P04-boundary-pg17-20260909.pg17","limits":"This separate PG17.11 boundary case demonstrates the natural FATAL path and fresh-session recovery; it does not replace or inflate the selected base 18.6 case.","observed":{"backend_pid":73,"collector_csv_severity":"FATAL","collector_csv_sqlstate":"25P04","collector_json_severity":"FATAL","collector_json_sqlstate":"25P04","driver_severity":"FATAL","fresh_connection_probe":1,"fresh_connection_status":"IDLE","natural_25P04_observed":true,"original_connection_closed":true,"primary":"terminating connection due to transaction timeout","setting":"transaction_timeout","sqlstate":"25P04","status_before_timeout":"INTRANS","timeout_ms":300},"raw":"verify/results/25P04-boundary-pg17-20260909/pg17/raw.jsonl","raw_sha256":"61e5e0ff62adc6d1744c61a36167ca6e4f754ebbefd905ab1002bf10c2e4cb8f","run_id":"25P04-boundary-pg17-20260909","selection_status":"selected_boundary_comparison","server_version":"17.11 (Debian 17.11-1.pgdg13+2)","server_version_num":170011,"snippet_registry":{"path":"verify/cases/25P04/snippets.json","sha256":"b25b99aa679f058e02229dd8d4ecd1ae4af41d11b19f80199f013da118ef3112"},"status":"passed","summary":"verify/results/25P04-boundary-pg17-20260909/pg17/summary.json","summary_sha256":"3342eea9eb7a3ed2dc24f56a321bd648444e074f45f08ec5bc9adc3b2c2dd1f7","target":"pg17","target_status":"passed"},"run_id":"25P04-boundary-pg17-20260909","runtime_id":"runtime.25P04-boundary-pg17-20260909.pg17","server_version":"17.11 (Debian 17.11-1.pgdg13+2)","status":"passed","target":"pg17"}},{"Kind":"sources","Ordinal":0,"ID":"src.errcodes.18.6","ServerVersion":null,"Status":null,"Payload":{"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"}},{"Kind":"sources","Ordinal":1,"ID":"src.calls.REL_18_6","ServerVersion":null,"Status":null,"Payload":{"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":""}},{"Kind":"sources","Ordinal":2,"ID":"src.postgres.18.6","ServerVersion":null,"Status":null,"Payload":{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","docs_url":"","kind":"upstream_source","location":"","path":"src/backend/tcop/postgres.c","position":2,"sha256":"9fb62275b1badf94d01ab351337b60410cd9b3ab1fe63fa9f23d6d2185a21061","source_id":"src.postgres.18.6","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/tcop/postgres.c#L3473-L3501"}},{"Kind":"sources","Ordinal":3,"ID":"src.config.18.6","ServerVersion":null,"Status":null,"Payload":{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","docs_url":"https://www.postgresql.org/docs/18/runtime-config-client.html","kind":"upstream_source","location":"","path":"doc/src/sgml/config.sgml","position":3,"sha256":"ffca322c15315ba670733d6b320f23cbba7374db0d18937298ffc07b58799ef6","source_id":"src.config.18.6","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10252-L10347"}},{"Kind":"sources","Ordinal":4,"ID":"doc.monitoring.18.6","ServerVersion":null,"Status":null,"Payload":{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","docs_url":"https://www.postgresql.org/docs/18/monitoring-stats.html","kind":"upstream_source","location":"","path":"doc/src/sgml/monitoring.sgml","position":4,"sha256":"06b147f8d966fe46821871703ffcee8a3449cc3f7de5b64b9177f48569fe96f6","source_id":"doc.monitoring.18.6","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/monitoring.sgml#L706-L875"}},{"Kind":"sources","Ordinal":5,"ID":"src.system_views.18.6","ServerVersion":null,"Status":null,"Payload":{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","docs_url":"https://www.postgresql.org/docs/18/view-pg-settings.html","kind":"upstream_source","location":"","path":"src/backend/catalog/system_views.sql","position":5,"sha256":"418f4ae7472fe0742e6fbdc7a055581602c5131e082aa6f17e2c7269bf711972","source_id":"src.system_views.18.6","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/system_views.sql#L604-L605"}},{"Kind":"sources","Ordinal":6,"ID":"doc.protocol.18.6","ServerVersion":null,"Status":null,"Payload":{"commit":"724edf9bde9d356724ad384a2e196edc3c9f80f7","docs_url":"https://www.postgresql.org/docs/18/protocol.html","kind":"upstream_source","location":"","path":"doc/src/sgml/protocol.sgml","position":6,"sha256":"745339e07ebbc2bb67d98b258e25772ada644ef26011e3cd6b3fcbb435235f89","source_id":"doc.protocol.18.6","tag":"REL_18_6","url":"https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/protocol.sgml#L61-L65"}}]}
