From: Andres Freund Date: Wed, 29 Jan 2014 12:56:55 +0000 (+0100) Subject: More robust KeepLogSeg() coding X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=1ca4996ed46e2fc7b5edc5098dec9f9851504d6c;p=users%2Frhaas%2Fpostgres.git More robust KeepLogSeg() coding --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a77ff5fe5e..ee1c0a3113 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9000,7 +9000,7 @@ CreateRestartPoint(int flags) static void KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo) { - XLogSegNo segno, slotSegNo; + XLogSegNo segno; XLogRecPtr keep; XLByteToSeg(recptr, segno); @@ -9019,9 +9019,13 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo) /* then check whether slots limit removal further */ if (max_replication_slots > 0 && keep != InvalidXLogRecPtr) { - XLByteToPrevSeg(keep, slotSegNo); + XLogRecPtr slotSegNo; + + XLByteToSeg(keep, slotSegNo); - if (slotSegNo < segno) + if (slotSegNo <= 0) + segno = 1; + else if (slotSegNo < segno) segno = slotSegNo; }