From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: Bogus pg_class.relminmxid value for pg_database
Date: Fri, 27 Jun 2014 11:58:18 -0400
Message-ID: <20140627155818.GN7340@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <52401AEA.9000608@vmware.com>
References: <52401AEA.9000608@vmware.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Heikki Linnakangas wrote:
> Right after a fresh initdb on a 9.3 or master database:
>
> postgres=# select oid,relname,relminmxid from pg_class where
> relname='pg_database';
> oid | relname | relminmxid
> ------+-------------+------------
> 1262 | pg_database | 4244967297
> (1 row)
>
> That bogus value seems to appear already some time during initdb.
> The relminmxid for all other tables is 1, which is correct.
I finally figured the source of this issue: it's caused by VACUUM FULL
(executed by initdb while copying template1 into template0): we're
missing a protection that relminmxid doesn't go backwards when swapping
heaps. We already have such a check for xids.
This is mostly innocuous, but I'm about to push the attached fix all the
same, backpatched to 9.3. (The extra context lines make the patch very
clear.)
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugsAttachments:backwards-mxid.patch (text/x-diff, 904B) downloaddiff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.cindex 6f87170..46b41c1 100644--- a/src/backend/commands/cluster.c+++ b/src/backend/commands/cluster.c@@ -869,14 +869,20 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
/*
* FreezeXid will become the table's new relfrozenxid, and that mustn't go
* backwards, so take the max.
*/
if (TransactionIdPrecedes(FreezeXid, OldHeap->rd_rel->relfrozenxid))
FreezeXid = OldHeap->rd_rel->relfrozenxid;
+ /*+ * MultiXactCutoff, similarly, shouldn't go backwards either.+ */+ if (MultiXactIdPrecedes(MultiXactCutoff, OldHeap->rd_rel->relminmxid))+ MultiXactCutoff = OldHeap->rd_rel->relminmxid;+
/* return selected values to caller */
*pFreezeXid = FreezeXid;
*pCutoffMulti = MultiXactCutoff;
/* Remember if it's a system catalog */
is_system_catalog = IsSystemRelation(OldHeap);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: alvherre@2ndquadrant.com, hlinnakangas@vmware.com
Subject: Re: Bogus pg_class.relminmxid value for pg_database
In-Reply-To: <20140627155818.GN7340@eldon.alvh.no-ip.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox