Terminate any session that spans longer than the specified amount of time in a transaction.
At a glance
| Property | Value |
|---|---|
| Parameter | transaction_timeout |
| Category | Client Connection Defaults |
| Default | 0 |
| Value type | integer |
| Change scope | Per-session (SET) |
| Available in | PostgreSQL 17, 18, 19 (added in 17) |
What it does
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.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.
Inspect the current value and source with SHOW transaction_timeout; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'transaction_timeout';.
Tuning guidance
Set a ceiling (per role/database) to abort any transaction — idle or running — that exceeds it, bounding lock-hold and bloat from runaway transactions. Combine with statement_timeout and idle_in_transaction_session_timeout.