aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2023-04-27 13:43:48 -0700
committerNathan Bossart <nathan@postgresql.org>2023-04-27 14:31:33 -0700
commitc98b06e2f8655818e83a5a26ef93cc31c357614c (patch)
treeaae6524acfc2c0e8a265904a95fb33f262ec8675 /src
parent85ec8bcce2608b8e29a1a0742282d39b29b78dda (diff)
downloadpostgresql-c98b06e2f8655818e83a5a26ef93cc31c357614c.tar.gz
postgresql-c98b06e2f8655818e83a5a26ef93cc31c357614c.zip
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 c655077639. 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
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlog.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 32c6bb5d288..691b9622dad 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7298,7 +7298,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
* max_slot_wal_keep_size.
*/
keep = XLogGetReplicationSlotMinimumLSN();
- if (keep != InvalidXLogRecPtr)
+ if (keep != InvalidXLogRecPtr && keep < recptr)
{
XLByteToSeg(keep, segno, wal_segment_size);