]> granicus.if.org Git - postgresql/commitdiff
Don't set ThisTimeLineID in checkpointer & bgwriter during recovery.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 20 Dec 2012 12:01:50 +0000 (14:01 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 20 Dec 2012 12:39:04 +0000 (14:39 +0200)
We used to set it to the current recovery target timeline, but the recovery
target timeline can change during recovery, leaving ThisTimeLineID at an
old value. That seems worse than always leaving it at zero to begin with.

AFAICS there was no good reason to set it in the first place. ThisTimeLineID
is not needed in checkpointer or bgwriter process, until it's time to write
the end-of-recovery checkpoint, and at that point ThisTimeLineID is updated
anyway.

src/backend/access/transam/xlog.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c

index 5b156f9c70e009b28cf8f1dc7d6fdc5b3997e8e2..d7e83a937c991e154a16438c15df55387e0b5119 100644 (file)
@@ -2901,7 +2901,12 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr endptr)
                                 errmsg("could not open transaction log directory \"%s\": %m",
                                                XLOGDIR)));
 
-       XLogFileName(lastoff, ThisTimeLineID, segno);
+       /*
+        * Construct a filename of the last segment to be kept. The timeline ID
+        * doesn't matter, we ignore that in the comparison. (During recovery,
+        * ThisTimeLineID isn't set, so we can't use that.)
+        */
+       XLogFileName(lastoff, 0, segno);
 
        elog(DEBUG2, "attempting to remove WAL segments older than log file %s",
                 lastoff);
index ff0a9cb560117173b41dec5d0a9e03b9bbafc9bf..ee0889ed3ee99c493891940d36675fa3d86cbc6a 100644 (file)
@@ -224,12 +224,6 @@ BackgroundWriterMain(void)
         */
        PG_SETMASK(&UnBlockSig);
 
-       /*
-        * Use the recovery target timeline ID during recovery
-        */
-       if (RecoveryInProgress())
-               ThisTimeLineID = GetRecoveryTargetTLI();
-
        /*
         * Reset hibernation state after any error.
         */
index c8a68a1b22710aee0c5feaabfd653d9740ee82d8..0f05c7ee58cd17f253360dfb361b12308338e798 100644 (file)
@@ -346,12 +346,6 @@ CheckpointerMain(void)
         */
        PG_SETMASK(&UnBlockSig);
 
-       /*
-        * Use the recovery target timeline ID during recovery
-        */
-       if (RecoveryInProgress())
-               ThisTimeLineID = GetRecoveryTargetTLI();
-
        /*
         * Ensure all shared memory values are set correctly for the config. Doing
         * this here ensures no race conditions from other concurrent updaters.