Re: could not truncate directory "pg_subtrans": apparent wraparound - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: could not truncate directory "pg_subtrans": apparent wraparound
Date
Msg-id 20150606012555.GB133018@postgresql.org
Whole thread Raw
In response to Re: could not truncate directory "pg_subtrans": apparent wraparound  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: could not truncate directory "pg_subtrans": apparent wraparound  (Thomas Munro <thomas.munro@enterprisedb.com>)
List pgsql-hackers
Thomas Munro wrote:

> My idea was that if I could get oldestXact == next XID in
> TruncateSUBSTRANS, then TransactionIdToPage(oldestXact) for a value of
> oldestXact that happens to be immediately after a page boundary (so
> that xid % 2048 == 0) might give page number that is >=
> latest_page_number, causing SimpleLruTruncate to print that message.
> But I can't figure out how to get next XID == oldest XID, because
> vacuumdb --freeze --all consumes xids itself, so in my first attempt
> at this, next XID is always 3 ahead of the oldest XID when a
> checkpoint is run.

vacuumdb starts by querying pg_database, which eats one XID.

Vacuum itself only uses one XID when vac_truncate_clog() is called.
This is called from vac_update_datfrozenxid(), which always happen at
the end of each user-invoked VACUUM (so three times for vacuumdb if you
have three databases); autovacuum does it also at the end of each run.
Maybe you can get autovacuum to quit before doing it.

OTOH, if the values in the pg_database entry do not change,
vac_truncate_clog is not called, and thus vacuum would finish without
consuming an XID.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: deavid
Date:
Subject: Re: Is it possible to have a "fast-write" Index?
Next
From: Amit Kapila
Date:
Subject: Re: Warn about using single user + standby_mode