{"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"}],"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"],"short_desc":"Terminate any session that spans longer than the specified amount of time in a transaction.","short_desc_zh":"","source_rev":"english-manuals:ed0c2a40fb132cebb6180d400a40beed66393e6a09d82d3e440e12d26096dd41","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"transaction_timeout","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"transaction_timeout","SourceRevision":"english-manuals:ed0c2a40fb132cebb6180d400a40beed66393e6a09d82d3e440e12d26096dd41","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.","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","unit":"ms","vartype":"integer"},"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":"english-manuals:ed0c2a40fb132cebb6180d400a40beed66393e6a09d82d3e440e12d26096dd41","ContentHash":"6505954583fa763ff3160845c4319b5c19e57d31d53b66e14f92e4beb07dba90","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":"zh-Hans","Fallback":true,"Versions":["17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
