]> granicus.if.org Git - postgresql/commitdiff
Fix calculation of how many segments to retain for wal_keep_segments.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 8 Apr 2013 13:26:52 +0000 (16:26 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 8 Apr 2013 13:29:56 +0000 (16:29 +0300)
KeepLogSeg function was broken when we switched to use a 64-bit int for the
segment number.

Per report from Jeff Janes.

src/backend/access/transam/xlog.c

index 25b2ff9d03b2b640809e99dd43f8ea12c5e350cc..3cb866f53069b12406eb1a8199fb0b4b2bc3a7da 100644 (file)
@@ -7523,9 +7523,9 @@ CreateRestartPoint(int flags)
 }
 
 /*
- * Calculate the last segment that we need to retain because of
- * wal_keep_segments, by subtracting wal_keep_segments from
- * the given xlog location, recptr.
+ * Retreat *logSegNo to the last segment that we need to retain because of
+ * wal_keep_segments. This is calculated by subtracting wal_keep_segments
+ * from the given xlog location, recptr.
  */
 static void
 KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
@@ -7541,7 +7541,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
        if (segno <= wal_keep_segments)
                segno = 1;
        else
-               segno = *logSegNo - wal_keep_segments;
+               segno = segno - wal_keep_segments;
 
        /* don't delete WAL segments newer than the calculated segment */
        if (segno < *logSegNo)