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

Commit 794e8e3

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 8e6f134 commit 794e8e3

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
@@ -9521,13 +9521,13 @@ GetWALAvailability(XLogRecPtr targetLSN)
95219521
if (XLogRecPtrIsInvalid(targetLSN))
95229522
return WALAVAIL_INVALID_LSN;
95239523

9524-
currpos = GetXLogWriteRecPtr();
9525-
95269524
/*
9527-
* calculate the oldest segment currently reserved by all slots,
9528-
* considering wal_keep_segments and max_slot_wal_keep_size
9525+
* Calculate the oldest segment currently reserved by all slots,
9526+
* considering wal_keep_segments and max_slot_wal_keep_size. Initialize
9527+
* oldestSlotSeg to the current segment.
95299528
*/
9530-
XLByteToSeg(targetLSN, targetSeg, wal_segment_size);
9529+
currpos = GetXLogWriteRecPtr();
9530+
XLByteToSeg(currpos, oldestSlotSeg, wal_segment_size);
95319531
KeepLogSeg(currpos, &oldestSlotSeg);
95329532

95339533
/*
@@ -9546,6 +9546,9 @@ GetWALAvailability(XLogRecPtr targetLSN)
95469546
else
95479547
oldestSegMaxWalSize = 1;
95489548

9549+
/* the segment we care about */
9550+
XLByteToSeg(targetLSN, targetSeg, wal_segment_size);
9551+
95499552
/*
95509553
* No point in returning reserved or extended status values if the
95519554
* targetSeg is known to be lost.
@@ -9622,7 +9625,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
96229625
}
96239626

96249627
/* don't delete WAL segments newer than the calculated segment */
9625-
if (XLogRecPtrIsInvalid(*logSegNo) || segno < *logSegNo)
9628+
if (segno < *logSegNo)
96269629
*logSegNo = segno;
96279630
}
96289631

0 commit comments

Comments
 (0)