From: Heikki Linnakangas Date: Thu, 20 Dec 2012 12:01:50 +0000 (+0200) Subject: Don't set ThisTimeLineID in checkpointer & bgwriter during recovery. X-Git-Tag: REL9_3_BETA1~578 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a11d4609efaae39d9b7472fb965bca1c0aeda01;p=postgresql 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. --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5b156f9c70..d7e83a937c 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -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); diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index ff0a9cb560..ee0889ed3e 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -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. */ diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index c8a68a1b22..0f05c7ee58 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -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.