diff options
author | Heikki Linnakangas | 2009-08-27 07:15:41 +0000 |
---|---|---|
committer | Heikki Linnakangas | 2009-08-27 07:15:41 +0000 |
commit | cd2504faf6234276412d87e67d3b0088e57d59e9 (patch) | |
tree | 625deb51758b8c4b621b5e340ba55267c3791bf4 | |
parent | 1d06de7d405784779b78fbc1cc65b470d92abf53 (diff) |
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.
-rw-r--r-- | src/backend/access/transam/xlog.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index cc6be167ef..8f9a0ae639 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6445,6 +6445,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, @@ -6567,20 +6578,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); |