diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 1a870422235..63ab0ab6c2e 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -893,8 +893,8 @@ static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr); static void XLogFileClose(void); static void PreallocXlogFiles(XLogRecPtr endptr); static void RemoveTempXlogFiles(void); -static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr); -static void RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr); +static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr); +static void RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr); static void UpdateLastRemovedPtr(char *filename); static void ValidateXLOGDirectoryStructure(void); static void CleanupBackupHistory(void); @@ -2299,7 +2299,7 @@ assign_checkpoint_completion_target(double newval, void *extra) * XLOG segments? Returns the highest segment that should be preallocated. */ static XLogSegNo -XLOGfileslop(XLogRecPtr RedoRecPtr) +XLOGfileslop(XLogRecPtr lastredoptr) { XLogSegNo minSegNo; XLogSegNo maxSegNo; @@ -2311,9 +2311,9 @@ XLOGfileslop(XLogRecPtr RedoRecPtr) * correspond to. Always recycle enough segments to meet the minimum, and * remove enough segments to stay below the maximum. */ - minSegNo = RedoRecPtr / wal_segment_size + + minSegNo = lastredoptr / wal_segment_size + ConvertToXSegs(min_wal_size_mb, wal_segment_size) - 1; - maxSegNo = RedoRecPtr / wal_segment_size + + maxSegNo = lastredoptr / wal_segment_size + ConvertToXSegs(max_wal_size_mb, wal_segment_size) - 1; /* @@ -2328,7 +2328,7 @@ XLOGfileslop(XLogRecPtr RedoRecPtr) /* add 10% for good measure. */ distance *= 1.10; - recycleSegNo = (XLogSegNo) ceil(((double) RedoRecPtr + distance) / + recycleSegNo = (XLogSegNo) ceil(((double) lastredoptr + distance) / wal_segment_size); if (recycleSegNo < minSegNo) @@ -3935,12 +3935,12 @@ RemoveTempXlogFiles(void) /* * Recycle or remove all log files older or equal to passed segno. * - * endptr is current (or recent) end of xlog, and RedoRecPtr is the + * endptr is current (or recent) end of xlog, and lastredoptr is the * redo pointer of the last checkpoint. These are used to determine * whether we want to recycle rather than delete no-longer-wanted log files. */ static void -RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) +RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr) { DIR *xldir; struct dirent *xlde; @@ -3983,7 +3983,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) /* Update the last removed location in shared memory first */ UpdateLastRemovedPtr(xlde->d_name); - RemoveXlogFile(xlde->d_name, RedoRecPtr, endptr); + RemoveXlogFile(xlde->d_name, lastredoptr, endptr); } } } @@ -4057,14 +4057,14 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI) /* * Recycle or remove a log file that's no longer needed. * - * endptr is current (or recent) end of xlog, and RedoRecPtr is the + * endptr is current (or recent) end of xlog, and lastredoptr is the * redo pointer of the last checkpoint. These are used to determine * whether we want to recycle rather than delete no-longer-wanted log files. - * If RedoRecPtr is not known, pass invalid, and the function will recycle, + * If lastredoptr is not known, pass invalid, and the function will recycle, * somewhat arbitrarily, 10 future segments. */ static void -RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) +RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr) { char path[MAXPGPATH]; #ifdef WIN32 @@ -4080,10 +4080,10 @@ RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) * Initialize info about where to try to recycle to. */ XLByteToSeg(endptr, endlogSegNo, wal_segment_size); - if (RedoRecPtr == InvalidXLogRecPtr) + if (lastredoptr == InvalidXLogRecPtr) recycleSegNo = endlogSegNo + 10; else - recycleSegNo = XLOGfileslop(RedoRecPtr); + recycleSegNo = XLOGfileslop(lastredoptr); } else recycleSegNo = 0; /* keep compiler quiet */