Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PostgreSQLFlexDatabaseXacts — Remaining transactions

Per-database transaction-ID (XID) and multixact-ID (MXID) consumption. The key signal for transaction-ID wraparound prevention — Postgres will force the cluster into read-only mode if XIDs are exhausted.

Kusto query

let server = "my-pg-prd-1";
AzureDiagnostics
| where Category == "PostgreSQLFlexDatabaseXacts" and LogicalServerName_s == server
| project DatabaseName_s, Datdba_d, DatConnLimit_d,
          DatFrozenxid_d, DatMinmxid_d, Age_DatFrozenxid_d, Age_DatMinmxid_d,
          Autovacuum_freeze_max_age_d, Autovacuum_multixact_freeze_max_age_d,
          Vacuum_freeze_min_age_d, Vacuum_multixact_freeze_min_age_d,
          Remaining_xids_till_emergency_autovacuum_d, Remaining_xids_till_wraparound_d,
          Remaining_mxids_till_emergency_autovacuum_d, Remaining_mxids_till_wraparound_d,
          Total_remaining_xids_d, Total_remaining_mxids_d

Fields

Database identity

  • DatabaseName_s (string) — database name.
  • Datdba_d (number) — OID of the database owner.
  • DatConnLimit_d (number) — per-database connection limit (-1 = no limit).

Frozen-ID watermarks

  • DatFrozenxid_d (number) — oldest unfrozen XID in the database.
  • DatMinmxid_d (number) — oldest multixact ID in the database.
  • Age_DatFrozenxid_d (number) — age (XIDs elapsed) since datfrozenxid.
  • Age_DatMinmxid_d (number) — age since datminmxid.

Vacuum thresholds (effective settings)

  • Autovacuum_freeze_max_age_d (number) — XID age that forces an anti-wraparound autovacuum.
  • Autovacuum_multixact_freeze_max_age_d (number) — MXID age that forces it.
  • Vacuum_freeze_min_age_d (number) — min XID age before tuples get frozen.
  • Vacuum_multixact_freeze_min_age_d (number) — min MXID age before freezing.

Remaining headroom (alerting signals)

  • Remaining_xids_till_emergency_autovacuum_d (number) — XIDs left before emergency autovacuum kicks in.
  • Remaining_xids_till_wraparound_d (number) — XIDs left before wraparound / shutdown.
  • Remaining_mxids_till_emergency_autovacuum_d (number) — MXIDs left before emergency autovacuum.
  • Remaining_mxids_till_wraparound_d (number) — MXIDs left before MXID wraparound.
  • Total_remaining_xids_d / Total_remaining_mxids_d (number) — total XID/MXID budget remaining.

Use cases — troubleshooting

  • Transaction-ID wraparound prevention — alert when Remaining_xids_till_wraparound_d / Remaining_mxids_till_wraparound_d drop dangerously low (risk of forced read-only shutdown).
  • Emergency-autovacuum prediction — watch Remaining_xids_till_emergency_autovacuum_d to anticipate aggressive anti-wraparound vacuums (and the I/O they cause).
  • Find the worst database — rank databases by Age_DatFrozenxid_d / Age_DatMinmxid_d to see which one drives the cluster's XID age.
  • MultiXact exhaustion — track Age_DatMinmxid_d / remaining MXIDs for heavy SELECT ... FOR SHARE/FK-locking workloads.
  • Vacuum-policy validation — confirm Autovacuum_freeze_max_age_d and related thresholds are set sensibly for the consumption rate.