PostgreSQL

Transaction ID wraparound risk causes database shutdown

critical
availabilityUpdated Nov 13, 2025

PostgreSQL's 32-bit transaction ID counter approaches exhaustion (2 billion limit), risking forced database shutdown. Tables with age(relfrozenxid) approaching autovacuum_freeze_max_age require aggressive freezing VACUUMs to prevent wraparound.

How to detect:

Table's transaction ID age approaches wraparound threshold (above 50% of 2 billion XID limit, or age exceeds 150 million). PostgreSQL stops accepting writes entirely at 200 million to prevent data corruption

Recommended action:

Query pg_class to check age(relfrozenxid) for all tables. If any table shows pct_to_wraparound above 50% or xid_age above 150 million, immediately run VACUUM (FREEZE, VERBOSE) on affected tables. Tune autovacuum to prevent recurrence: lower autovacuum_vacuum_scale_factor to 0.02, increase autovacuum_max_workers to 5-8, reduce autovacuum_naptime to 15-30s.