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

Commit b5b4c0f

Browse files
committed
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
1 parent 25fe5ac commit b5b4c0f

File tree

1 file changed

+9
-6
lines changed
  • src/backend/access/transam

1 file changed

+9
-6
lines changed

src/backend/access/transam/xlog.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9523,13 +9523,13 @@ GetWALAvailability(XLogRecPtr targetLSN)
95239523
if (XLogRecPtrIsInvalid(targetLSN))
95249524
return WALAVAIL_INVALID_LSN;
95259525

9526-
currpos = GetXLogWriteRecPtr();
9527-
95289526
/*
9529-
* calculate the oldest segment currently reserved by all slots,
9530-
* considering wal_keep_segments and max_slot_wal_keep_size
9527+
* Calculate the oldest segment currently reserved by all slots,
9528+
* considering wal_keep_segments and max_slot_wal_keep_size. Initialize
9529+
* oldestSlotSeg to the current segment.
95319530
*/
9532-
XLByteToSeg(targetLSN, targetSeg, wal_segment_size);
9531+
currpos = GetXLogWriteRecPtr();
9532+
XLByteToSeg(currpos, oldestSlotSeg, wal_segment_size);
95339533
KeepLogSeg(currpos, &oldestSlotSeg);
95349534

95359535
/*
@@ -9548,6 +9548,9 @@ GetWALAvailability(XLogRecPtr targetLSN)
95489548
else
95499549
oldestSegMaxWalSize = 1;
95509550

9551+
/* the segment we care about */
9552+
XLByteToSeg(targetLSN, targetSeg, wal_segment_size);
9553+
95519554
/*
95529555
* No point in returning reserved or extended status values if the
95539556
* targetSeg is known to be lost.
@@ -9624,7 +9627,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
96249627
}
96259628

96269629
/* don't delete WAL segments newer than the calculated segment */
9627-
if (XLogRecPtrIsInvalid(*logSegNo) || segno < *logSegNo)
9630+
if (segno < *logSegNo)
96289631
*logSegNo = segno;
96299632
}
96309633

0 commit comments

Comments
 (0)