Postgres wraparound problems

4k views Asked by At

I have facing one problem with my Production PostgreSQL and which is related to Wraparound Problem basically for over limit of XID range.

This PostgreSQL Production is running more than 1 year with loads of transaction and bulk insertion.

I searched lot in google but confuse and very scare about this critical error. Right now I am getting this error during any vacuum or auto-vacuum stuff. I have around 250 GB of Postgres Production Database and I have also set auto-vacuum for all tables.

Error and Warning are:

WARNING:  oldest xmin is far in the past
HINT:  Close open transactions soon to avoid wraparound problems.

I have also checked current open transaction but there is no any long running transaction in Postgres session.

Current database age of XID :
  Database       Age
"template1";  153163876
"template0";  153163876
"postgres";   153163876
"dispatcher"; 153163876
"qate";       195568300

above result I got using below query :

SELECT datname, age(datfrozenxid) FROM pg_database;

please provide your inputs as soon as possible because very soon, this will really create problem for my production database.

1

There are 1 answers

1
Erwin Brandstetter On

If you can afford to forcibly close open transactions:

SELECT pg_terminate_backend(procpid)
FROM   pg_stat_activity
WHERE  datname = 'mydb';

Then autovacuum can freeze rows, or you can run VACUUM manually. You may have to prevent new transactions temporarily. Here are detailed instructions:

.. except you don't DROP the db. Just VACUUM it.

Or Postgres will force a shutdown to prevent data loss. Detailed explanation in the manual.