database_wraparound collector monitors transaction ID wraparound risk by tracking the age of the oldest transaction IDs and multi-transaction IDs.
Status
Default: Disabled Enable with:--collector.database-wraparound
Metrics
pg_database_wraparound_age_datfrozenxid_seconds
Type: GaugeDescription: Age of the oldest transaction ID that has not been frozen Labels:
datname- Database name
pg_database_wraparound_age_datminmxid_seconds
Type: GaugeDescription: Age of the oldest multi-transaction ID that has been replaced with a transaction ID Labels:
datname- Database name
SQL Query
PostgreSQL Versions
Supported: All versionsRequired Permissions
The monitoring user needs:- Access to
pg_catalog.pg_database
Wraparound Protection
Alert Thresholds
- Warning:
age_datfrozenxid> 1,000,000,000 (1 billion) - Critical:
age_datfrozenxid> 1,500,000,000 (1.5 billion) - Emergency:
age_datfrozenxid> 2,000,000,000 (2 billion)
Example Output
Troubleshooting
If wraparound age is high:- Check autovacuum is running:
SELECT * FROM pg_stat_activity WHERE query LIKE 'autovacuum:%' - Run manual
VACUUM FREEZEon affected tables - Increase
autovacuum_freeze_max_agetemporarily if needed - Check for long-running transactions blocking vacuum