Skip to content

transaction_timeout

transaction_timeout is the PostgreSQL setting that defines the maximum allowed duration of any transaction within a session (not a prepared transaction).
Note

Fact — official short description: “Sets the maximum allowed duration of any transaction within a session (not a prepared transaction).”

Identity

Type , Valueinteger
Upstream pg_settings type
Context , Valueuser
Settable by an ordinary user
Unit , Valuems
Raw unit
Range , Value02147483647
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueClient Connection Defaults / Statement Behavior
Upstream classification
Latest boot value , Value0
0 ms

Lifecycle

Fact Value
First observed PG17
Present in PG17–19 Beta 3
Removed in No
Introduction commit 51efe38cb92f — Introduce transaction_timeout
Commit date 2024-02-15
Discussion thread 1

Default history

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG17–19 Beta 3 0 ms 0 ms

How it works

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.

Tuning advice

Tip

Advice. These are workload-specific starting points and must be validated with measurements.

Workload Guidance
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.
OLAP Analytical work usually needs a larger or job-specific transaction_timeout; preserve a finite guardrail for abandoned work without killing legitimate long scans.
Small nodes Use a conservative finite transaction_timeout only when the client or operating system handles termination correctly; verify that maintenance still has a dedicated exception.

Pigsty

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

Template Effective value Versus upstream boot Source expression
OLTP Unmodified
OLAP Unmodified
CRIT Unmodified
TINY Unmodified
Caution

Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG17–19 Beta 3 unmodified; OLAP: PG17–19 Beta 3 unmodified; CRIT: PG17–19 Beta 3 unmodified; TINY: PG17–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

Common 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.

statement_timeout · lock_timeout · idle_in_transaction_session_timeout · idle_session_timeout · deadlock_timeout

References