Don't set ThisTimeLineID in checkpointer & bgwriter during recovery.

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.
This commit is contained in:
Heikki Linnakangas 2012-12-20 14:01:50 +02:00
parent 345fb82f16
commit 1a11d4609e
3 changed files with 6 additions and 13 deletions

View 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);

View 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.
*/

View 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.