Skip to content

Commit 35c0152

Browse files
committed
Remove shadow variables linked to RedoRecPtr in xlog.c
This changes the routines in charge of recycling WAL segments past the last redo LSN to not use anymore "RedoRecPtr" as a local variable, which is also available in the context of the session as a static declaration, replacing it with "lastredoptr". This confusion has been introduced by d9fadbf, so backpatch down to v11 like the other commit. Thanks to Tom Lane, Robert Haas, Alvaro Herrera, Mark Dilger and Kyotaro Horiguchi for the input provided. Author: Ranier Vilela Discussion: https://postgr.es/m/MN2PR18MB2927F7B5F690065E1194B258E35D0@MN2PR18MB2927.namprd18.prod.outlook.com Backpatch-through: 11
1 parent 97ba30f commit 35c0152

File tree

1 file changed

+14
-14
lines changed
  • src/backend/access/transam

1 file changed

+14
-14
lines changed

src/backend/access/transam/xlog.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,8 @@ static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
893893
static void XLogFileClose(void);
894894
static void PreallocXlogFiles(XLogRecPtr endptr);
895895
static void RemoveTempXlogFiles(void);
896-
static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr);
897-
static void RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr);
896+
static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr);
897+
static void RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr);
898898
static void UpdateLastRemovedPtr(char *filename);
899899
static void ValidateXLOGDirectoryStructure(void);
900900
static void CleanupBackupHistory(void);
@@ -2299,7 +2299,7 @@ assign_checkpoint_completion_target(double newval, void *extra)
22992299
* XLOG segments? Returns the highest segment that should be preallocated.
23002300
*/
23012301
static XLogSegNo
2302-
XLOGfileslop(XLogRecPtr RedoRecPtr)
2302+
XLOGfileslop(XLogRecPtr lastredoptr)
23032303
{
23042304
XLogSegNo minSegNo;
23052305
XLogSegNo maxSegNo;
@@ -2311,9 +2311,9 @@ XLOGfileslop(XLogRecPtr RedoRecPtr)
23112311
* correspond to. Always recycle enough segments to meet the minimum, and
23122312
* remove enough segments to stay below the maximum.
23132313
*/
2314-
minSegNo = RedoRecPtr / wal_segment_size +
2314+
minSegNo = lastredoptr / wal_segment_size +
23152315
ConvertToXSegs(min_wal_size_mb, wal_segment_size) - 1;
2316-
maxSegNo = RedoRecPtr / wal_segment_size +
2316+
maxSegNo = lastredoptr / wal_segment_size +
23172317
ConvertToXSegs(max_wal_size_mb, wal_segment_size) - 1;
23182318

23192319
/*
@@ -2328,7 +2328,7 @@ XLOGfileslop(XLogRecPtr RedoRecPtr)
23282328
/* add 10% for good measure. */
23292329
distance *= 1.10;
23302330

2331-
recycleSegNo = (XLogSegNo) ceil(((double) RedoRecPtr + distance) /
2331+
recycleSegNo = (XLogSegNo) ceil(((double) lastredoptr + distance) /
23322332
wal_segment_size);
23332333

23342334
if (recycleSegNo < minSegNo)
@@ -3935,12 +3935,12 @@ RemoveTempXlogFiles(void)
39353935
/*
39363936
* Recycle or remove all log files older or equal to passed segno.
39373937
*
3938-
* endptr is current (or recent) end of xlog, and RedoRecPtr is the
3938+
* endptr is current (or recent) end of xlog, and lastredoptr is the
39393939
* redo pointer of the last checkpoint. These are used to determine
39403940
* whether we want to recycle rather than delete no-longer-wanted log files.
39413941
*/
39423942
static void
3943-
RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
3943+
RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr)
39443944
{
39453945
DIR *xldir;
39463946
struct dirent *xlde;
@@ -3983,7 +3983,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
39833983
/* Update the last removed location in shared memory first */
39843984
UpdateLastRemovedPtr(xlde->d_name);
39853985

3986-
RemoveXlogFile(xlde->d_name, RedoRecPtr, endptr);
3986+
RemoveXlogFile(xlde->d_name, lastredoptr, endptr);
39873987
}
39883988
}
39893989
}
@@ -4057,14 +4057,14 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
40574057
/*
40584058
* Recycle or remove a log file that's no longer needed.
40594059
*
4060-
* endptr is current (or recent) end of xlog, and RedoRecPtr is the
4060+
* endptr is current (or recent) end of xlog, and lastredoptr is the
40614061
* redo pointer of the last checkpoint. These are used to determine
40624062
* whether we want to recycle rather than delete no-longer-wanted log files.
4063-
* If RedoRecPtr is not known, pass invalid, and the function will recycle,
4063+
* If lastredoptr is not known, pass invalid, and the function will recycle,
40644064
* somewhat arbitrarily, 10 future segments.
40654065
*/
40664066
static void
4067-
RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
4067+
RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr)
40684068
{
40694069
char path[MAXPGPATH];
40704070
#ifdef WIN32
@@ -4080,10 +4080,10 @@ RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
40804080
* Initialize info about where to try to recycle to.
40814081
*/
40824082
XLByteToSeg(endptr, endlogSegNo, wal_segment_size);
4083-
if (RedoRecPtr == InvalidXLogRecPtr)
4083+
if (lastredoptr == InvalidXLogRecPtr)
40844084
recycleSegNo = endlogSegNo + 10;
40854085
else
4086-
recycleSegNo = XLOGfileslop(RedoRecPtr);
4086+
recycleSegNo = XLOGfileslop(lastredoptr);
40874087
}
40884088
else
40894089
recycleSegNo = 0; /* keep compiler quiet */

0 commit comments

Comments
 (0)