pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Subject: [PATCH] Fix incorrect calculation regarding max_slot_wal_keep_size
Date: Thu, 20 Apr 2023 11:51:10 +0900

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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

inline patch 1: src/backend/access/transam/xlog.c (+5/-2 lines) download inline-1.patchdiff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 63481d826f..7bdd4d86b1 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7463,8 +7463,11 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo) { XLByteToSeg(keep, segno, wal_segment_size); - /* Cap by max_slot_wal_keep_size ... */ - if (max_slot_wal_keep_size_mb >= 0) + /* + * Cap by max_slot_wal_keep_size. However this is not required if the + * slots alredy won't protect any segments. + */ + if (max_slot_wal_keep_size_mb >= 0 && segno < currSegNo) { uint64 slot_keep_segs; -- 2.31.1
----Next_Part(Thu_Apr_20_12_04_17_2023_839)----

Message-ID: <no-message-id-27250@localhost>
Permalink:  ../no-message-id-27250@localhost/
Also on:    postgresql.org/message-id/no-message-id-27250@localhost

 ·  · 

reply

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-bugs@postgresql.org
  Cc: horikyota.ntt@gmail.com
  Subject: Re: [PATCH] Fix incorrect calculation regarding max_slot_wal_keep_size
  In-Reply-To: <no-message-id-27250@localhost>

* 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