From: Tom Lane <tgl@sss.pgh.pa.us>
To: tarvip@gmail.com
Cc: pgsql-bugs@postgresql.org
Cc: Simon Riggs <simon@2ndquadrant.com>
Subject: Re: BUG #7710: Xid epoch is not updated properly during checkpoint
Date: Sat, 01 Dec 2012 17:56:33 -0500
Message-ID: <24367.1354402593@sss.pgh.pa.us> (raw)
In-Reply-To: <E1TdRCT-00008s-Tc@wrigleys.postgresql.org>
References: <E1TdRCT-00008s-Tc@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
tarvip@gmail.com writes:
> [ txid_current can show a bogus value near XID wraparound ]
> This happens only if wal_level=hot_standby.
I believe what is happening here is
(1) CreateCheckPoint sets up checkPoint.nextXid and
checkPoint.nextXidEpoch, near xlog.c line 7070 in HEAD. At this point,
nextXid is still a bit less than the wrap point.
(2) After performing the checkpoint, at line 7113, CreateCheckPoint
calls LogStandbySnapshot() which "helpfully" updates checkPoint.nextXid
to the latest value. Which by now has wrapped around. But it doesn't
fix checkPoint.nextXidEpoch, so the checkpoint that gets written out has
effectively lost the epoch bump that should have happened.
While we could add some more logic to try to correct the epoch value
in this scenario, I think it's a much better idea to just stop having
LogStandbySnapshot update the nextXid. That seems to me to be useless
complication. I also quite dislike the fact that we're effectively
redefining the checkpoint nextXid from being taken before the main
body of the checkpoint to being taken afterwards, but *only* in
XLogStandbyInfoActive mode. If that inconsistency isn't already causing
bugs (besides this one) today, it'll probably cause them in the future.
So barring objections, I'm going to remove LogStandbySnapshot's behavior
of returning the updated nextXid.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, tarvip@gmail.com, simon@2ndquadrant.com
Subject: Re: BUG #7710: Xid epoch is not updated properly during checkpoint
In-Reply-To: <24367.1354402593@sss.pgh.pa.us>
References: <E1TdRCT-00008s-Tc@wrigleys.postgresql.org> <24367.1354402593@sss.pgh.pa.us>
* 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