Skip to content

Commit 1370030

Browse files
Prevent underflow in KeepLogSeg().
The call to XLogGetReplicationSlotMinimumLSN() might return a greater LSN than the one given to the function. Subsequent segment number calculations might then underflow, which could result in unexpected behavior when removing or recyling WAL files. This was introduced with max_slot_wal_keep_size in c655077. To fix, skip the block of code for replication slots if the LSN is greater. Reported-by: Xu Xingwang Author: Kyotaro Horiguchi Reviewed-by: Junwang Zhao Discussion: https://postgr.es/m/17903-4288d439dee856c6%40postgresql.org Backpatch-through: 13
1 parent c74f88c commit 1370030

File tree

1 file changed

+1
-1
lines changed
  • src/backend/access/transam

1 file changed

+1
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10037,7 +10037,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
1003710037
* max_slot_wal_keep_size.
1003810038
*/
1003910039
keep = XLogGetReplicationSlotMinimumLSN();
10040-
if (keep != InvalidXLogRecPtr)
10040+
if (keep != InvalidXLogRecPtr && keep < recptr)
1004110041
{
1004210042
XLByteToSeg(keep, segno, wal_segment_size);
1004310043

0 commit comments

Comments
 (0)