Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7011649

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 2acab05 commit 7011649

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
@@ -891,8 +891,8 @@ static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
891891
static void XLogFileClose(void);
892892
static void PreallocXlogFiles(XLogRecPtr endptr);
893893
static void RemoveTempXlogFiles(void);
894-
static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr);
895-
static void RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr);
894+
static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr);
895+
static void RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr);
896896
static void UpdateLastRemovedPtr(char *filename);
897897
static void ValidateXLOGDirectoryStructure(void);
898898
static void CleanupBackupHistory(void);
@@ -2298,7 +2298,7 @@ assign_checkpoint_completion_target(double newval, void *extra)
22982298
* XLOG segments? Returns the highest segment that should be preallocated.
22992299
*/
23002300
static XLogSegNo
2301-
XLOGfileslop(XLogRecPtr RedoRecPtr)
2301+
XLOGfileslop(XLogRecPtr lastredoptr)
23022302
{
23032303
XLogSegNo minSegNo;
23042304
XLogSegNo maxSegNo;
@@ -2310,9 +2310,9 @@ XLOGfileslop(XLogRecPtr RedoRecPtr)
23102310
* correspond to. Always recycle enough segments to meet the minimum, and
23112311
* remove enough segments to stay below the maximum.
23122312
*/
2313-
minSegNo = RedoRecPtr / wal_segment_size +
2313+
minSegNo = lastredoptr / wal_segment_size +
23142314
ConvertToXSegs(min_wal_size_mb, wal_segment_size) - 1;
2315-
maxSegNo = RedoRecPtr / wal_segment_size +
2315+
maxSegNo = lastredoptr / wal_segment_size +
23162316
ConvertToXSegs(max_wal_size_mb, wal_segment_size) - 1;
23172317

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

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

23332333
if (recycleSegNo < minSegNo)
@@ -3948,12 +3948,12 @@ RemoveTempXlogFiles(void)
39483948
/*
39493949
* Recycle or remove all log files older or equal to passed segno.
39503950
*
3951-
* endptr is current (or recent) end of xlog, and RedoRecPtr is the
3951+
* endptr is current (or recent) end of xlog, and lastredoptr is the
39523952
* redo pointer of the last checkpoint. These are used to determine
39533953
* whether we want to recycle rather than delete no-longer-wanted log files.
39543954
*/
39553955
static void
3956-
RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
3956+
RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr)
39573957
{
39583958
DIR *xldir;
39593959
struct dirent *xlde;
@@ -3996,7 +3996,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
39963996
/* Update the last removed location in shared memory first */
39973997
UpdateLastRemovedPtr(xlde->d_name);
39983998

3999-
RemoveXlogFile(xlde->d_name, RedoRecPtr, endptr);
3999+
RemoveXlogFile(xlde->d_name, lastredoptr, endptr);
40004000
}
40014001
}
40024002
}
@@ -4070,14 +4070,14 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
40704070
/*
40714071
* Recycle or remove a log file that's no longer needed.
40724072
*
4073-
* endptr is current (or recent) end of xlog, and RedoRecPtr is the
4073+
* endptr is current (or recent) end of xlog, and lastredoptr is the
40744074
* redo pointer of the last checkpoint. These are used to determine
40754075
* whether we want to recycle rather than delete no-longer-wanted log files.
4076-
* If RedoRecPtr is not known, pass invalid, and the function will recycle,
4076+
* If lastredoptr is not known, pass invalid, and the function will recycle,
40774077
* somewhat arbitrarily, 10 future segments.
40784078
*/
40794079
static void
4080-
RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
4080+
RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr)
40814081
{
40824082
char path[MAXPGPATH];
40834083
#ifdef WIN32
@@ -4093,10 +4093,10 @@ RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
40934093
* Initialize info about where to try to recycle to.
40944094
*/
40954095
XLByteToSeg(endptr, endlogSegNo, wal_segment_size);
4096-
if (RedoRecPtr == InvalidXLogRecPtr)
4096+
if (lastredoptr == InvalidXLogRecPtr)
40974097
recycleSegNo = endlogSegNo + 10;
40984098
else
4099-
recycleSegNo = XLOGfileslop(RedoRecPtr);
4099+
recycleSegNo = XLOGfileslop(lastredoptr);
41004100
}
41014101
else
41024102
recycleSegNo = 0; /* keep compiler quiet */

0 commit comments

Comments
 (0)