On 2021-Nov-24, Kyotaro Horiguchi wrote: > At Tue, 23 Nov 2021 11:21:05 -0300, Alvaro Herrera <alvhe...@alvh.no-ip.org> > wrote in
> > I wonder why did we make it round down rather than up. Does this mean > > that if you have max_slot_wal_keep_size=8MB and wal segments of 16 MB, > > the slot gets invalidated with more than zero reserved segments? > > That rounding behavior is the way we are generally doing on similar > variables. It is based on the behavior of ConvertToXSegs(). So > max_wal_size for example is rounded-up the same way. After thinking on it some more, I think rounding down is correct. If somebody sets max_slot_wal_keep_size=40MB, then by keeping the limit at 32 MB (round down) we're honoring that request better than if we made it 48 MB (round up). But in any case, I think it doesn't matter much: users need a *rough* size limit, not a super-precise one. After all, this is only verified at checkpoint time. We're probably dealing with a few hundreds of megabytes at least, so 16 MB one way or the other don't change things much. Here's a proposed patch. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "Las mujeres son como hondas: mientras más resistencia tienen, más lejos puedes llegar con ellas" (Jonas Nightingale, Leap of Faith)
>From bfbc099a1ea5a4eec57d5d25c0dbb616e8724182 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Thu, 25 Nov 2021 11:29:41 -0300 Subject: [PATCH] Document units for max_slot_wal_keep_size --- doc/src/sgml/config.sgml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 3f806740d5..918d7ebd01 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -4175,6 +4175,11 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows to continue replication due to removal of required WAL files. You can see the WAL availability of replication slots in <link linkend="view-pg-replication-slots">pg_replication_slots</link>. + The value is rounded down to an integer number of WAL files + according to <varname>wal_segment_size</varname>. + If this value is specified without units, it is taken as megabytes. + This parameter can only be set in the + <filename>postgresql.conf</filename> file or on the server command line. </para> </listitem> </varlistentry> -- 2.30.2