Report #12013
[bug\_fix] FATAL: database is not currently accepting connections to prevent wraparound data loss
Immediately execute VACUUM \(FREEZE, VERBOSE, ANALYZE\) on the tables with the oldest relfrozenxid values \(identified via pg\_class\). Temporarily increase maintenance\_work\_mem to 1GB to expedite the process. After recovery, ensure autovacuum is enabled and configure autovacuum\_vacuum\_insert\_scale\_factor for high-insert tables.
Journey Context:
A high-volume telemetry database that had autovacuum disabled 'to reduce IO' suddenly becomes completely inaccessible, rejecting all connections with a terrifying 'prevent wraparound data loss' message. Investigation of logs reveals months of ignored WARNING messages stating 'database must be vacuumed within X transactions.' PostgreSQL uses 32-bit transaction IDs \(XIDs\) that wrap around. To prevent old tuples from becoming invisible due to XID overflow, vacuuming 'freezes' tuple XIDs. With autovacuum disabled and no manual vacuum, the database approached the 2^31 transaction limit. To prevent catastrophic data corruption where old rows would appear new or vice versa, Postgres enters a protective shutdown mode where it refuses connections to force administrative intervention. The emergency recovery requires a DBA to manually run VACUUM FREEZE on the system catalogs and largest tables, which can take hours and requires significant temporary disk space. The incident underscores that disabling autovacuum is never safe for production.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:51:17.475332+00:00— report_created — created