diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-08-27 07:18:04 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-08-27 07:18:04 +0000 |
commit | 593810f3cd7d4a5b502712daceb6a4ef6178c3c0 (patch) | |
tree | a5a87a49cc74b4ab46f5588a6eca6ed56fe6241e /src | |
parent | 95ac06c85b65e7b4eeb72e0cf9b60efe98131555 (diff) | |
download | postgresql-593810f3cd7d4a5b502712daceb6a4ef6178c3c0.tar.gz postgresql-593810f3cd7d4a5b502712daceb6a4ef6178c3c0.zip |
In the checkpoint written at the end of archive recovery, the WAL page header
was incorrectly initialized with timeline ID 0. That rendered the WAL page
unrecoverable, making a subsequent archive recovery stop at that point.
ThisTimeLineID needs to be initialized before calling AdvanceXLInsertBuffer().
This fixes bug #5011 reported by James Bardin. Backpatch to 8.4, as the bug
was introduced by the changes to use of bgwriter for writing the
end-of-archive-recovery checkpoint. Patch by Tom Lane.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/xlog.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 618ad2281e9..022c1b20acd 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.345.2.2 2009/08/08 16:39:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.345.2.3 2009/08/27 07:18:04 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -6435,6 +6435,17 @@ CreateCheckPoint(int flags) } /* + * An end-of-recovery checkpoint is created before anyone is allowed to + * write WAL. To allow us to write the checkpoint record, temporarily + * enable XLogInsertAllowed. (This also ensures ThisTimeLineID is + * initialized, which we need here and in AdvanceXLInsertBuffer.) + */ + if (flags & CHECKPOINT_END_OF_RECOVERY) + LocalSetXLogInsertAllowed(); + + checkPoint.ThisTimeLineID = ThisTimeLineID; + + /* * Compute new REDO record ptr = location of next XLOG record. * * NB: this is NOT necessarily where the checkpoint record itself will be, @@ -6557,20 +6568,6 @@ CreateCheckPoint(int flags) START_CRIT_SECTION(); /* - * An end-of-recovery checkpoint is created before anyone is allowed to - * write WAL. To allow us to write the checkpoint record, temporarily - * enable XLogInsertAllowed. - */ - if (flags & CHECKPOINT_END_OF_RECOVERY) - LocalSetXLogInsertAllowed(); - - /* - * This needs to be done after LocalSetXLogInsertAllowed(), else - * ThisTimeLineID might still be uninitialized. - */ - checkPoint.ThisTimeLineID = ThisTimeLineID; - - /* * Now insert the checkpoint record into XLOG. */ rdata.data = (char *) (&checkPoint); |