From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgbf@twiska.com, Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: masao.fujii@oss.nttdata.com
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: min_safe_lsn column in pg_replication_slots view
Date: Mon, 13 Jul 2020 13:23:56 -0400
Message-ID: <20200713172356.GA446@alvherre.pgsql> (raw)
In-Reply-To: <20200711212630.GA6825@alvherre.pgsql>
A much more sensible answer is to initialize the segno to the segment
currently being written, as in the attached.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:v3-0001-Fix-uninitialized-value-in-segno-calculation.patch (text/x-diff, 2.1K) download
From 699e3a25e0673353fcb10fa92577f7534e594227 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Mon, 13 Jul 2020 13:22:40 -0400
Subject: [PATCH v3] Fix uninitialized value in segno calculation
Remove previous hack in KeepLogSeg that added a case to deal with a
(badly represented) invalid segment number; to replace it, initialize
the segment number to be retreated to the currently being written
segment.
Per valgrind-running buildfarm member skink, and some sparc64 animals.
Discussion: https://postgr.es/m/1724648.1594230917@sss.pgh.pa.us
---
src/backend/access/transam/xlog.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.cindex 28daf72a50..0a97b1d37f 100644--- a/src/backend/access/transam/xlog.c+++ b/src/backend/access/transam/xlog.c@@ -9523,13 +9523,13 @@ GetWALAvailability(XLogRecPtr targetLSN)
if (XLogRecPtrIsInvalid(targetLSN))
return WALAVAIL_INVALID_LSN;
- currpos = GetXLogWriteRecPtr();-
/*
- * calculate the oldest segment currently reserved by all slots,- * considering wal_keep_segments and max_slot_wal_keep_size+ * Calculate the oldest segment currently reserved by all slots,+ * considering wal_keep_segments and max_slot_wal_keep_size. Initialize+ * oldestSlotSeg to the current segment.
*/
- XLByteToSeg(targetLSN, targetSeg, wal_segment_size);+ currpos = GetXLogWriteRecPtr();+ XLByteToSeg(currpos, oldestSlotSeg, wal_segment_size);
KeepLogSeg(currpos, &oldestSlotSeg);
/*
@@ -9548,6 +9548,9 @@ GetWALAvailability(XLogRecPtr targetLSN)
else
oldestSegMaxWalSize = 1;
+ /* the segment we care about */+ XLByteToSeg(targetLSN, targetSeg, wal_segment_size);+
/*
* No point in returning reserved or extended status values if the
* targetSeg is known to be lost.
@@ -9624,7 +9627,7 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
}
/* don't delete WAL segments newer than the calculated segment */
- if (XLogRecPtrIsInvalid(*logSegNo) || segno < *logSegNo)+ if (segno < *logSegNo)
*logSegNo = segno;
}
--
2.20.1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us, horikyota.ntt@gmail.com, masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org
Subject: Re: min_safe_lsn column in pg_replication_slots view
In-Reply-To: <20200713172356.GA446@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox