postgres.git / summary / log / commit / refs

commit    973c011639e1aecf7256de07e2aa8520f9b49035
Author:   Simon Riggs <simon@2ndQuadrant.com>
Date:     Sun Dec 02 15:01:44 2012 +0000

    XidEpoch++ if wraparound during checkpoint.
    If wal_level = hot_standby we update the checkpoint nextxid,
    though in the case where a wraparound occurred half-way through
    a checkpoint we would neglect updating the epoch also. Updating
    the nextxid is arguably the wrong thing to do, but changing that
    may introduce subtle bugs into hot standby startup, while updating
    the value doesn't cause any known bugs yet. Minimal fix now to
    HEAD and backbranches, wider fix later in HEAD.
    
    Bug reported in #6291 by Daniel Farina and slightly differently in
    
    Cause analysis and recommended fixes from Tom Lane and Andres Freund.
    
    Applied patch is minimal version of Andres Freund's work.


src/backend/access/transam/xlog.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index b7319a5fc95..4d9721bae8f 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7849,10 +7849,17 @@ CreateCheckPoint(int flags) * If we are shutting down, or Startup process is completing crash * recovery we don't need to write running xact data. * - * Update checkPoint.nextXid since we have a later value + * Update checkPoint.nextXid since we may have a later value. If we + * do update the value, and we have wrapped, increment epoch also. */ if (!shutdown && XLogStandbyInfoActive()) + { + TransactionId prevXid = checkPoint.nextXid; + LogStandbySnapshot(&checkPoint.nextXid); + if (checkPoint.nextXid < prevXid) + checkPoint.nextXidEpoch++; + } START_CRIT_SECTION(); [parent: a7c53092d88b]