Thank you for the comment. At Fri, 3 Mar 2017 14:47:20 -0500, Peter Eisentraut <peter.eisentr...@2ndquadrant.com> wrote in <ac510b45-7805-7ccc-734c-1b38a6645...@2ndquadrant.com> > On 3/1/17 19:54, Kyotaro HORIGUCHI wrote: > >> Please measure it in size, not in number of segments. > > It was difficult to dicide which is reaaonable but I named it > > after wal_keep_segments because it has the similar effect. > > > > In bytes(or LSN) > > max_wal_size > > min_wal_size > > wal_write_flush_after > > > > In segments > > wal_keep_segments > > We have been moving away from measuring in segments. For example, > checkpoint_segments was replaced by max_wal_size. > > Also, with the proposed patch that allows changing the segment size more > easily, this will become more important. (I wonder if that will require > wal_keep_segments to change somehow.)
Agreed. It is 'max_slot_wal_keep_size' in the new version. wal_keep_segments might should be removed someday. regards, -- Kyotaro Horiguchi NTT Open Source Software Center
>From a646db76ac71ba1bff1105d55b8042fb451022bf Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi <horiguchi.kyot...@lab.ntt.co.jp> Date: Tue, 28 Feb 2017 11:39:48 +0900 Subject: [PATCH] Add WAL releaf vent for replication slots Adds a capability to limit the number of segments kept by replication slots by a GUC variable. --- src/backend/access/transam/xlog.c | 12 ++++++++++++ src/backend/utils/misc/guc.c | 11 +++++++++++ src/backend/utils/misc/postgresql.conf.sample | 1 + src/include/access/xlog.h | 1 + 4 files changed, 25 insertions(+) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8973583..cb23fbc 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -104,6 +104,7 @@ int wal_level = WAL_LEVEL_MINIMAL; int CommitDelay = 0; /* precommit delay in microseconds */ int CommitSiblings = 5; /* # concurrent xacts needed to sleep */ int wal_retrieve_retry_interval = 5000; +int max_slot_wal_keep_size = 0; #ifdef WAL_DEBUG bool XLOG_DEBUG = false; @@ -9267,6 +9268,17 @@ KeepLogSeg(XLogRecPtr recptr, XLogSegNo *logSegNo) XLByteToSeg(keep, slotSegNo); + /* emergency vent */ + if (max_slot_wal_keep_size > 0 && + segno - slotSegNo > max_slot_wal_keep_size) + { + ereport(WARNING, + (errmsg ("restart LSN of replication slots is ignored by checkpoint"), + errdetail("Some replication slots lose required WAL segnents to continue."))); + /* slotSegNo cannot be negative here */ + slotSegNo = segno - max_slot_wal_keep_size; + } + if (slotSegNo <= 0) segno = 1; else if (slotSegNo < segno) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 0707f66..20fe29a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2335,6 +2335,17 @@ static struct config_int ConfigureNamesInt[] = }, { + {"max_slot_wal_keep_size", PGC_SIGHUP, REPLICATION_SENDING, + gettext_noop("Sets the maximum size of extra WALs kept by replication slots."), + NULL, + GUC_UNIT_XSEGS + }, + &max_slot_wal_keep_size, + 0, 0, INT_MAX, + NULL, NULL, NULL + }, + + { {"wal_sender_timeout", PGC_SIGHUP, REPLICATION_SENDING, gettext_noop("Sets the maximum time to wait for WAL replication."), NULL, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 157d775..93e2f13 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -233,6 +233,7 @@ #max_wal_senders = 10 # max number of walsender processes # (change requires restart) #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables +#max_slot_wal_keep_size = 0 # measured in bytes; 0 disables #wal_sender_timeout = 60s # in milliseconds; 0 disables #max_replication_slots = 10 # max number of replication slots diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 9f036c7..93ee819 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -97,6 +97,7 @@ extern bool reachedConsistency; extern int min_wal_size; extern int max_wal_size; extern int wal_keep_segments; +extern int max_slot_wal_keep_size; extern int XLOGbuffers; extern int XLogArchiveTimeout; extern int wal_retrieve_retry_interval; -- 2.9.2
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers