pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH v2] Fix incorrect calculation regarding max_slot_wal_keep_size
1+ messages / 1 participants
[nested] [flat]
* [PATCH v2] Fix incorrect calculation regarding max_slot_wal_keep_size
@ 2023-04-20 02:51 Kyotaro Horiguchi <horikyota.ntt@gmail.com>
0 siblings, 0 replies; 1+ messages in thread
From: Kyotaro Horiguchi @ 2023-04-20 02:51 UTC (permalink / raw)
The calculation in KeepLogSeg related to max_slot_wal_keep_size can
result in unexpected behavior when replication advances quickly, and
the checkpointer is delayed just before removing WAL files.
---
src/backend/access/transam/xlog.c | 8 ++++++++
1 file changed, 8 insertions(+)
inline patch 1: src/backend/access/transam/xlog.c (+8/-0 lines) download inline-1.patch
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 63481d826f..bda859c299 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7463,6 +7463,14 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo)
{
XLByteToSeg(keep, segno, wal_segment_size);
+ /*
+ * Slot minimum LSN could be greater than recptr. In such cases, no
+ * segments are protected by slots but we still need to keep segno in a
+ * reasonable range for subsequent calculations to avoid underflow.
+ */
+ if (segno > currSegNo)
+ segno = currSegNo;
+
/* Cap by max_slot_wal_keep_size ... */
if (max_slot_wal_keep_size_mb >= 0)
{
--
2.31.1
----Next_Part(Thu_Apr_20_17_58_14_2023_063)----
^ permalink raw reply [nested|flat] 1+ messages in thread
only message in thread
Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 02:51 [PATCH v2] Fix incorrect calculation regarding max_slot_wal_keep_size Kyotaro Horiguchi <horikyota.ntt@gmail.com>
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