{"Entry":{"collection":"guc","key":"transaction_timeout","name":"transaction_timeout","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Client Connection Defaults / Statement Behavior","category_zh":"","changed_in":["18"],"changes":[{"documentation_changed":false,"fields":{},"from":"16","status":"added","to":"17"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"A value of 0 turns off the timeout.","to":"0 disables the timeout."}},"from":"17","status":"changed","to":"18"}],"content_hash":"4cad8b7f1eb374b33cd9c3cdbf9f905d0b3e682cf7183c20452ddab9675679a3","context":"","default_changed_in":[],"default_history":[{"from":"17","to":"19","value":"0 ms"}],"derived_content_hash":"11f1081b4d6f4b0e12ce36a660568b37133019bdda4cbc7ff24cb8fd9383c982","editorial":{"advice":{"olap":"Analytical work usually needs a larger or job-specific transaction_timeout; preserve a finite guardrail for abandoned work without killing legitimate long scans.","oltp":"Set transaction_timeout from the service latency and failure budget, preferably per role or application. Test retries and cancellation paths before enforcing a cluster-wide value.","small":"Use a conservative finite transaction_timeout only when the client or operating system handles termination correctly; verify that maintenance still has a dedicated exception."},"mechanism":["transaction_timeout sets the maximum allowed duration of any transaction within a session (not a prepared transaction). 0 disables the timeout. It terminates the session rather than merely canceling one statement, excludes prepared transactions, and makes longer idle-in-transaction or statement timeouts ineffective when set lower.","transaction_timeout is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.","Timeouts overlap: the first applicable deadline wins, while client, pooler, TCP, and server cancellation behavior determines whether work is retried, canceled, or the session is closed."],"pitfalls":["Changing transaction_timeout in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Forgetting that zero usually disables the timeout or delegates behavior to the operating system.","Setting overlapping deadlines without deciding which layer owns retries, cancellation, and connection disposal.","Expecting it to resolve prepared transactions, which are explicitly excluded."],"references":[{"title":"PostgreSQL 19 Beta 4: transaction_timeout","url":"https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-TRANSACTION-TIMEOUT"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["statement_timeout","lock_timeout","idle_in_transaction_session_timeout","idle_session_timeout","deadlock_timeout"],"summary":"transaction_timeout is the PostgreSQL setting that defines the maximum allowed duration of any transaction within a session (not a prepared transaction)."},"enumvals":[],"first_version":"17","group":"Client Connection Defaults","group_slug":"client","imported_at":"2026-09-27T17:57:32.237212+08:00","intro_commit":{"authored_at":"2024-02-15T23:34:11+02:00","discussion":["https://postgr.es/m/CAAhFRxiQsRs2Eq5kCo9nXE3HTugsAAJdSQSmxncivebAxdmBjQ%40mail.gmail.com"],"hash":"51efe38cb92f4b15b68811bcce9ab878fbc71ea5","subject":"Introduce transaction_timeout","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=51efe38cb92f4b15b68811bcce9ab878fbc71ea5"},"key":"transaction_timeout","last_version":"20","max_val":"","min_val":"","name":"transaction_timeout","position":437,"present_in":["17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:ed0c2a40fb132cebb6180d400a40beed66393e6a09d82d3e440e12d26096dd41","receipt_sha256":"e484f745b9e41dc0a3eae5a385ffa9e39250af09009bf784ce79b79cc4e936eb","repair":"wiki-repair-20261023"},"short_desc":"Terminate any session that spans longer than the specified amount of time in a transaction.","short_desc_zh":"","source_rev":"wiki-repair-20261023:f18533ee9f443b35950ff00c6d2138b900d5a8c3783b487ba09c80da33958b25","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"transaction_timeout","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"transaction_timeout","SourceRevision":"wiki-repair-20261023:f18533ee9f443b35950ff00c6d2138b900d5a8c3783b487ba09c80da33958b25","Facts":{"boot_val":"0","category":"Client Connection Defaults / Statement Behavior","context":"user","description":"Terminate any session that spans longer than the specified amount of time in a transaction. The limit applies both to explicit transactions (started with BEGIN) and to an implicitly started transaction corresponding to a single statement. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout. If transaction_timeout is shorter or equal to idle_in_transaction_session_timeout or statement_timeout then the longer timeout is ignored. Setting transaction_timeout in postgresql.conf is not recommended because it would affect all sessions. Note Prepared transactions are not subject to this timeout.","description_zh":"终止任何在一个事务中运行时间超过指定时长的会话。该限制既适用于显式事务（以 BEGIN 开始），也适用于与单条语句对应的隐式事务。如果指定值时没有单位，则以毫秒为单位。零值（默认值）将禁用该超时。 如果 transaction_timeout 短于或等于 idle_in_transaction_session_timeout 或 statement_timeout，则较长的超时将被忽略。 不建议在 postgresql.conf 中设置 transaction_timeout，因为它会影响所有会话。 注意 预备事务不受该超时影响。","description_zh_html":"\u003cp\u003e\n\t        终止任何在一个事务中运行时间超过指定时长的会话。该限制既适用于显式事务（以 \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e 开始），也适用于与单条语句对应的隐式事务。如果指定值时没有单位，则以毫秒为单位。零值（默认值）将禁用该超时。\n\t       \u003c/p\u003e\u003cp\u003e\n\t        如果 \u003ccode class=\"varname\"\u003etransaction_timeout\u003c/code\u003e 短于或等于 \u003ccode class=\"varname\"\u003eidle_in_transaction_session_timeout\u003c/code\u003e 或 \u003ccode class=\"varname\"\u003estatement_timeout\u003c/code\u003e，则较长的超时将被忽略。\n\t       \u003c/p\u003e\u003cp\u003e\n\t        不建议在 \u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e 中设置 \u003ccode class=\"varname\"\u003etransaction_timeout\u003c/code\u003e，因为它会影响所有会话。\n\t       \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n\t         预备事务不受该超时影响。\n\t        \u003c/p\u003e\u003c/div\u003e","doc":{"anchor":"GUC-TRANSACTION-TIMEOUT","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"0 disables the timeout.","lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"0","name":"transaction_timeout","short_desc":"Sets the maximum allowed duration of any transaction within a session (not a prepared transaction).","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-client.html","sha256":"1882f8fd5576909c4fcc44af53077378871e05f5be67723f20fe300273024767"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":"ms","vartype":"integer","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-TRANSACTION-TIMEOUT","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"transaction_timeout","SourceDatabase":"center","Version":"18","Locale":"en","Title":"transaction_timeout","Summary":"Terminate any session that spans longer than the specified amount of time in a transaction. The limit applies both to explicit transactions (started with BEGIN) and to an implicitly started transaction corresponding to a single statement. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout. If transaction_timeout is shorter or equal to idle_in_transaction_session_timeout or statement_timeout then the longer timeout is ignored. Setting transaction_timeout in postgresql.conf is not recommended because it would affect all sessions. Note Prepared transactions are not subject to this timeout.","BodyHTML":"\u003cp\u003eTerminate any session that spans longer than the specified amount of time in a transaction. The limit applies both to explicit transactions (started with BEGIN) and to an implicitly started transaction corresponding to a single statement. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout. If transaction_timeout is shorter or equal to idle_in_transaction_session_timeout or statement_timeout then the longer timeout is ignored. Setting transaction_timeout in postgresql.conf is not recommended because it would affect all sessions. Note Prepared transactions are not subject to this timeout.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:f18533ee9f443b35950ff00c6d2138b900d5a8c3783b487ba09c80da33958b25","ContentHash":"b6fe668bca0582a71b74b1a300efc7cff9c92345446ccca868aa700e37d4f078","Payload":{"description":"Terminate any session that spans longer than the specified amount of time in a transaction. The limit applies both to explicit transactions (started with BEGIN) and to an implicitly started transaction corresponding to a single statement. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout. If transaction_timeout is shorter or equal to idle_in_transaction_session_timeout or statement_timeout then the longer timeout is ignored. Setting transaction_timeout in postgresql.conf is not recommended because it would affect all sessions. Note Prepared transactions are not subject to this timeout."}},"RequestedLocale":"en","Fallback":false,"Versions":["17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
