mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-08 14:19:20 +02:00
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
This commit is contained in:
parent
fc449abc3d
commit
668365014d
@ -887,8 +887,8 @@ static bool WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||||||
static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
|
static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
|
||||||
static void XLogFileClose(void);
|
static void XLogFileClose(void);
|
||||||
static void PreallocXlogFiles(XLogRecPtr endptr);
|
static void PreallocXlogFiles(XLogRecPtr endptr);
|
||||||
static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr);
|
static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr);
|
||||||
static void RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr);
|
static void RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr);
|
||||||
static void UpdateLastRemovedPtr(char *filename);
|
static void UpdateLastRemovedPtr(char *filename);
|
||||||
static void ValidateXLOGDirectoryStructure(void);
|
static void ValidateXLOGDirectoryStructure(void);
|
||||||
static void CleanupBackupHistory(void);
|
static void CleanupBackupHistory(void);
|
||||||
@ -2293,7 +2293,7 @@ assign_checkpoint_completion_target(double newval, void *extra)
|
|||||||
* XLOG segments? Returns the highest segment that should be preallocated.
|
* XLOG segments? Returns the highest segment that should be preallocated.
|
||||||
*/
|
*/
|
||||||
static XLogSegNo
|
static XLogSegNo
|
||||||
XLOGfileslop(XLogRecPtr RedoRecPtr)
|
XLOGfileslop(XLogRecPtr lastredoptr)
|
||||||
{
|
{
|
||||||
XLogSegNo minSegNo;
|
XLogSegNo minSegNo;
|
||||||
XLogSegNo maxSegNo;
|
XLogSegNo maxSegNo;
|
||||||
@ -2305,9 +2305,9 @@ XLOGfileslop(XLogRecPtr RedoRecPtr)
|
|||||||
* correspond to. Always recycle enough segments to meet the minimum, and
|
* correspond to. Always recycle enough segments to meet the minimum, and
|
||||||
* remove enough segments to stay below the maximum.
|
* 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;
|
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;
|
ConvertToXSegs(max_wal_size_mb, wal_segment_size) - 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2322,7 +2322,7 @@ XLOGfileslop(XLogRecPtr RedoRecPtr)
|
|||||||
/* add 10% for good measure. */
|
/* add 10% for good measure. */
|
||||||
distance *= 1.10;
|
distance *= 1.10;
|
||||||
|
|
||||||
recycleSegNo = (XLogSegNo) ceil(((double) RedoRecPtr + distance) /
|
recycleSegNo = (XLogSegNo) ceil(((double) lastredoptr + distance) /
|
||||||
wal_segment_size);
|
wal_segment_size);
|
||||||
|
|
||||||
if (recycleSegNo < minSegNo)
|
if (recycleSegNo < minSegNo)
|
||||||
@ -3887,12 +3887,12 @@ UpdateLastRemovedPtr(char *filename)
|
|||||||
/*
|
/*
|
||||||
* Recycle or remove all log files older or equal to passed segno.
|
* 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
|
* redo pointer of the last checkpoint. These are used to determine
|
||||||
* whether we want to recycle rather than delete no-longer-wanted log files.
|
* whether we want to recycle rather than delete no-longer-wanted log files.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
|
RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastredoptr, XLogRecPtr endptr)
|
||||||
{
|
{
|
||||||
DIR *xldir;
|
DIR *xldir;
|
||||||
struct dirent *xlde;
|
struct dirent *xlde;
|
||||||
@ -3935,7 +3935,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
|
|||||||
/* Update the last removed location in shared memory first */
|
/* Update the last removed location in shared memory first */
|
||||||
UpdateLastRemovedPtr(xlde->d_name);
|
UpdateLastRemovedPtr(xlde->d_name);
|
||||||
|
|
||||||
RemoveXlogFile(xlde->d_name, RedoRecPtr, endptr);
|
RemoveXlogFile(xlde->d_name, lastredoptr, endptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4009,14 +4009,14 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI)
|
|||||||
/*
|
/*
|
||||||
* Recycle or remove a log file that's no longer needed.
|
* 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
|
* redo pointer of the last checkpoint. These are used to determine
|
||||||
* whether we want to recycle rather than delete no-longer-wanted log files.
|
* 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.
|
* somewhat arbitrarily, 10 future segments.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
|
RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr)
|
||||||
{
|
{
|
||||||
char path[MAXPGPATH];
|
char path[MAXPGPATH];
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -4030,10 +4030,10 @@ RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr)
|
|||||||
* Initialize info about where to try to recycle to.
|
* Initialize info about where to try to recycle to.
|
||||||
*/
|
*/
|
||||||
XLByteToSeg(endptr, endlogSegNo, wal_segment_size);
|
XLByteToSeg(endptr, endlogSegNo, wal_segment_size);
|
||||||
if (RedoRecPtr == InvalidXLogRecPtr)
|
if (lastredoptr == InvalidXLogRecPtr)
|
||||||
recycleSegNo = endlogSegNo + 10;
|
recycleSegNo = endlogSegNo + 10;
|
||||||
else
|
else
|
||||||
recycleSegNo = XLOGfileslop(RedoRecPtr);
|
recycleSegNo = XLOGfileslop(lastredoptr);
|
||||||
|
|
||||||
snprintf(path, MAXPGPATH, XLOGDIR "/%s", segname);
|
snprintf(path, MAXPGPATH, XLOGDIR "/%s", segname);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user