Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TewCe-0003ms-4r for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Dec 2012 23:10:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TewCd-0002c9-9d for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Dec 2012 23:10:31 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TewCc-0002c3-FY for pgsql-bugs@postgresql.org; Sat, 01 Dec 2012 23:10:30 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TewCa-0000D4-Gy for pgsql-bugs@postgresql.org; Sat, 01 Dec 2012 23:10:30 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 73318480003; Sun, 2 Dec 2012 00:10:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-4.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC5823.dip.t-dialin.net [93.220.88.35]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 5A5E945000C; Sun, 2 Dec 2012 00:10:23 +0100 (CET) Received: by anarazel.de (Postfix, from userid 1000) id 97DF21C0173; Sun, 2 Dec 2012 00:10:22 +0100 (CET) Date: Sun, 2 Dec 2012 00:10:22 +0100 From: Andres Freund To: Tom Lane Cc: tarvip@gmail.com, pgsql-bugs@postgresql.org, Simon Riggs Subject: Re: BUG #7710: Xid epoch is not updated properly during checkpoint Message-ID: <20121201231022.GB25134@awork2.anarazel.de> References: <24367.1354402593@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24367.1354402593@sss.pgh.pa.us> X-Pg-Spam-Score: -3.0 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2012-12-01 17:56:33 -0500, Tom Lane wrote: > 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 Hrmpf. You had to report the fix for that three minutes before me. ;) > (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. Same conclusion here. > 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. I don't see any reason why it would be bad to remove this. I think the current behaviour could actually even delay getting to an active state slightly in the presence of prepared transactions because its used to create to initialize the KnownAssignedXid machinery in xlog_redo. If the prepared xacts are suboverflown its a *good* thing to have an old ->nextXid. Greetings, Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs