Re: BUG #5011: Standby recovery unable to follow timeline change - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5011: Standby recovery unable to follow timeline change
Date
Msg-id 12968.1251297766@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #5011: Standby recovery unable to follow timeline change  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #5011: Standby recovery unable to follow timeline change  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-bugs
I wrote:
> ... but this solution is astonishingly ugly.  I think we should move up
> the LocalSetXLogInsertAllowed call, instead.

Specifically, I propose this patch instead.  I'm not set up to try the
test case though, can you do that?

            regards, tom lane

Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v
retrieving revision 1.348
diff -c -r1.348 xlog.c
*** src/backend/access/transam/xlog.c    12 Aug 2009 20:53:30 -0000    1.348
--- src/backend/access/transam/xlog.c    26 Aug 2009 14:40:28 -0000
***************
*** 6445,6450 ****
--- 6445,6461 ----
      }

      /*
+      * 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,6586 ****
      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);
--- 6578,6583 ----

pgsql-bugs by date:

Previous
From: james bardin
Date:
Subject: Re: BUG #5011: Standby recovery unable to follow timeline change
Next
From: "Gergely Czuczy"
Date:
Subject: BUG #5012: mailing list VERP addresses not sender-verifiable