Skip to content

Commit 1a11d46

Browse files
committed
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.
1 parent 345fb82 commit 1a11d46

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/backend/access/transam/xlog.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,12 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr endptr)
29012901
errmsg("could not open transaction log directory \"%s\": %m",
29022902
XLOGDIR)));
29032903

2904-
XLogFileName(lastoff, ThisTimeLineID, segno);
2904+
/*
2905+
* Construct a filename of the last segment to be kept. The timeline ID
2906+
* doesn't matter, we ignore that in the comparison. (During recovery,
2907+
* ThisTimeLineID isn't set, so we can't use that.)
2908+
*/
2909+
XLogFileName(lastoff, 0, segno);
29052910

29062911
elog(DEBUG2, "attempting to remove WAL segments older than log file %s",
29072912
lastoff);

src/backend/postmaster/bgwriter.c

-6
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,6 @@ BackgroundWriterMain(void)
224224
*/
225225
PG_SETMASK(&UnBlockSig);
226226

227-
/*
228-
* Use the recovery target timeline ID during recovery
229-
*/
230-
if (RecoveryInProgress())
231-
ThisTimeLineID = GetRecoveryTargetTLI();
232-
233227
/*
234228
* Reset hibernation state after any error.
235229
*/

src/backend/postmaster/checkpointer.c

-6
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,6 @@ CheckpointerMain(void)
346346
*/
347347
PG_SETMASK(&UnBlockSig);
348348

349-
/*
350-
* Use the recovery target timeline ID during recovery
351-
*/
352-
if (RecoveryInProgress())
353-
ThisTimeLineID = GetRecoveryTargetTLI();
354-
355349
/*
356350
* Ensure all shared memory values are set correctly for the config. Doing
357351
* this here ensures no race conditions from other concurrent updaters.

0 commit comments

Comments
 (0)