From df86e52cace2c4134db51de6665682fb985f3195 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 2 Oct 2019 15:53:07 +0900 Subject: Remove temporary WAL and history files at the end of archive recovery cbc55da has reworked the order of some actions at the end of archive recovery. Unfortunately this overlooked the fact that the startup process needs to remove RECOVERYXLOG (for temporary WAL segment newly recovered from archives) and RECOVERYHISTORY (for temporary history file) at this step, leaving the files around even after recovery ended. Backpatch to 9.5, like the previous commit. Author: Sawada Masahiko Reviewed-by: Fujii Masao, Michael Paquier Discussion: https://postgr.es/m/CAD21AoBO_eDQub6zojFnWtnmutRBWvYf7=cW4Hsqj+U_R26w3Q@mail.gmail.com Backpatch-through: 9.5 --- src/backend/access/transam/xlog.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 61ba6b852e6..790e2c8714d 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5461,7 +5461,6 @@ validateRecoveryParameters(void) static void exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog) { - char recoveryPath[MAXPGPATH]; char xlogfname[MAXFNAMELEN]; XLogSegNo endLogSegNo; XLogSegNo startLogSegNo; @@ -5541,17 +5540,6 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog) XLogFileName(xlogfname, ThisTimeLineID, startLogSegNo, wal_segment_size); XLogArchiveCleanup(xlogfname); - /* - * Since there might be a partial WAL segment named RECOVERYXLOG, get rid - * of it. - */ - snprintf(recoveryPath, MAXPGPATH, XLOGDIR "/RECOVERYXLOG"); - unlink(recoveryPath); /* ignore any error */ - - /* Get rid of any remaining recovered timeline-history file, too */ - snprintf(recoveryPath, MAXPGPATH, XLOGDIR "/RECOVERYHISTORY"); - unlink(recoveryPath); /* ignore any error */ - /* * Remove the signal files out of the way, so that we don't accidentally * re-enter archive recovery mode in a subsequent crash. @@ -7433,6 +7421,7 @@ StartupXLOG(void) if (ArchiveRecoveryRequested) { char reason[200]; + char recoveryPath[MAXPGPATH]; Assert(InArchiveRecovery); @@ -7489,6 +7478,17 @@ StartupXLOG(void) */ writeTimeLineHistory(ThisTimeLineID, recoveryTargetTLI, EndRecPtr, reason); + + /* + * Since there might be a partial WAL segment named RECOVERYXLOG, get + * rid of it. + */ + snprintf(recoveryPath, MAXPGPATH, XLOGDIR "/RECOVERYXLOG"); + unlink(recoveryPath); /* ignore any error */ + + /* Get rid of any remaining recovered timeline-history file, too */ + snprintf(recoveryPath, MAXPGPATH, XLOGDIR "/RECOVERYHISTORY"); + unlink(recoveryPath); /* ignore any error */ } /* Save the selected TimeLineID in shared memory, too */ -- cgit v1.2.3