VACUUM FULL/CLUSTER doesn't update pg_class's pg_class.relfrozenxid - Mailing list pgsql-hackers

From Andres Freund
Subject VACUUM FULL/CLUSTER doesn't update pg_class's pg_class.relfrozenxid
Date
Msg-id 20140227180639.GB18320@alap3.anarazel.de
Whole thread Raw
Responses Re: VACUUM FULL/CLUSTER doesn't update pg_class's pg_class.relfrozenxid  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Hi,

As Robert previously complained a database wide VACUUM FULL now (as of
3cff1879f8d03) reliably increases the relfrozenxid for all tables but
pg_class itself. That's a bit sad because it means doing a VACUUM FULL
won't help in a anti-wraparound scenario.

The reason for that is explained by the following comment:
    /*
     * Update the tuples in pg_class --- unless the target relation of the
     * swap is pg_class itself.  In that case, there is zero point in making
     * changes because we'd be updating the old data that we're about to throw
     * away.  Because the real work being done here for a mapped relation is
     * just to change the relation map settings, it's all right to not update
     * the pg_class rows in this case.
     */

I think the easiest fix for that is to update pg_class' relfrozenxid in
finish_heap_swap() after the indexes have been rebuilt, that's just a
couple of lines. There's more complex solutions that'd avoid the need
for that special case, but I it's sufficient. A patch doing that is
attached.

Note that VACUUM FULL will still require more xids than a plain VACUUM,
but it scales linearly with the number of relations, so I have a hard
time seing that as problematic.

Greetings,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: pgbench help message fix
Next
From: Josh Berkus
Date:
Subject: Re: jsonb and nested hstore