Skip to content

deadlock_timeout

deadlock_timeout — Sets the time to wait on a lock before checking for deadlock. Observed in PG9.0–19 Beta 3; its last measured boot default is 1 s in PG19 Beta 3, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
Note

Fact — official short description: “Sets the time to wait on a lock before checking for deadlock.”

Identity

Type , Valueinteger
Upstream pg_settings type
Context , Valuesuperuser
Settable at runtime by a superuser
Unit , Valuems
Raw unit
Range , Value12147483647
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueLock Management
Upstream classification
Latest boot value , Value1000
1 s

Lifecycle

Fact Value
First observed PG9.0 (research boundary)
Present in PG9.0–19 Beta 3
Removed in No
Introduction commit Not asserted: predates the PG9.0 research boundary
Commit date
Discussion

Default history

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

How it works

Sets the time to wait on a lock before checking for deadlock. A superuser or a role granted SET privilege can change it for the relevant session or configuration scope.

PostgreSQL waits this long before running the comparatively expensive deadlock detector. The same interval controls lock-wait logging when log_lock_waits is enabled, so lowering it improves diagnostics and deadlock response at the cost of more checks during ordinary contention.

Monitor and change deadlock_timeout together with log_lock_waits, lock_timeout, max_locks_per_transaction. Validate on the relevant server role and real workload, then use its superuser context to choose session change, reload, or restart; a historical boot default is not the current effective value.

Tuning advice

Tip

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

Workload Guidance
OLTP Calibrate deadlock_timeout from lock-wait logs, objects touched, and the concurrency bound. Fix long transactions and access ordering before adding shared memory or changing detection granularity.
OLAP Partitioned queries, bulk DDL, and SERIALIZABLE reports may touch many objects; test the worst plan, not only an average transaction.
Small nodes Defaults are usually sufficient. If raising a startup lock-table setting, account for max_connections, prepared transactions, and standby consistency together.

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 50ms different 50ms
OLAP 50ms different 50ms
CRIT 50ms different 50ms
TINY 50ms different 50ms
Caution

Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 50ms (dcs); OLAP: PG9.0–19 Beta 3 = 50ms (dcs); CRIT: PG9.0–19 Beta 3 = 50ms (dcs); TINY: PG9.0–19 Beta 3 = 50ms (dcs). Advice, pending human review — Editorial interpretation, pending human maintainer review: the override appears intended to detect true deadlocks and emit lock-wait diagnostics faster than upstream; confirm it against the current Pigsty templates, hardware fixture, and operational guarantees before publication.

Common pitfalls

  • Reading an average shared-memory sizing value as a hard per-transaction limit.
  • Raising it without the multiplier from connections and prepared transactions.
  • Expanding lock memory instead of fixing long transactions, access order, or partition explosion.
  • Ignoring compatible startup lock capacity on standbys.

log_lock_waits · lock_timeout · max_locks_per_transaction · max_pred_locks_per_transaction · max_pred_locks_per_page · max_pred_locks_per_relation

References