mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-09 03:09:35 +02:00
Fix uninitialized value in segno calculation
Remove previous hack in KeepLogSeg that added a case to deal with a (badly represented) invalid segment number. This was added for the sake of GetWALAvailability. But it's not needed if in that function we initialize the segment number to be retreated to the currently being written segment, so do that instead. Per valgrind-running buildfarm member skink, and some sparc64 animals. Discussion: https://postgr.es/m/1724648.1594230917@sss.pgh.pa.us
This commit is contained in:
parent
8e6f134a9a
commit
794e8e32bb
@ -9521,13 +9521,13 @@ GetWALAvailability(XLogRecPtr targetLSN)
|
|||||||
if (XLogRecPtrIsInvalid(targetLSN))
|
if (XLogRecPtrIsInvalid(targetLSN))
|
||||||
return WALAVAIL_INVALID_LSN;
|
return WALAVAIL_INVALID_LSN;
|
||||||
|
|
||||||
currpos = GetXLogWriteRecPtr();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calculate the oldest segment currently reserved by all slots,
|
* Calculate the oldest segment currently reserved by all slots,
|
||||||
* considering wal_keep_segments and max_slot_wal_keep_size
|
* considering wal_keep_segments and max_slot_wal_keep_size. Initialize
|
||||||
|
* oldestSlotSeg to the current segment.
|
||||||
*/
|
*/
|
||||||
XLByteToSeg(targetLSN, targetSeg, wal_segment_size);
|
currpos = GetXLogWriteRecPtr();
|
||||||
|
XLByteToSeg(currpos, oldestSlotSeg, wal_segment_size);
|
||||||
KeepLogSeg(currpos, &oldestSlotSeg);
|
KeepLogSeg(currpos, &oldestSlotSeg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -9546,6 +9546,9 @@ GetWALAvailability(XLogRecPtr targetLSN)
|
|||||||
else
|
else
|
||||||
oldestSegMaxWalSize = 1;
|
oldestSegMaxWalSize = 1;
|
||||||
|
|
||||||
|
/* the segment we care about */
|
||||||
|
XLByteToSeg(targetLSN, targetSeg, wal_segment_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No point in returning reserved or extended status values if the
|
* No point in returning reserved or extended status values if the
|
||||||
* targetSeg is known to be lost.
|
* targetSeg is known to be lost.
|
||||||
@ -9622,7 +9625,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* don't delete WAL segments newer than the calculated segment */
|
/* don't delete WAL segments newer than the calculated segment */
|
||||||
if (XLogRecPtrIsInvalid(*logSegNo) || segno < *logSegNo)
|
if (segno < *logSegNo)
|
||||||
*logSegNo = segno;
|
*logSegNo = segno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user