Re: Option to not use ringbuffer in VACUUM, using it in failsafe mode

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Melanie Plageman <melanieplageman(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Option to not use ringbuffer in VACUUM, using it in failsafe mode
Date: 2023-04-05 04:36:55
Message-ID: CAH2-WzmvcL=fnZB1WJ2wDxGfTVfqSMoFE4awz_1cucvLui9Ptg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 4, 2023 at 8:14 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> 14. Not related to this patch, but why do we have half the vacuum
> related GUCs in vacuum.c and the other half in globals.c? I see
> vacuum_freeze_table_age is defined in vacuum.c but is also needed in
> autovacuum.c, so that rules out the globals.c ones being for vacuum.c
> and autovacuum.c. It seems a bit messy. I'm not really sure where
> VacuumBufferUsageLimit should go now.

vacuum_freeze_table_age is an abomination, even compared to the rest
of these GUCs. It was added around the time the visibility map first
went in, and so is quite a bit more recent than
autovacuum_freeze_max_age.

Before the introduction of the visibility map, we only had
autovacuum_freeze_max_age, and it was used to schedule antiwraparound
autovacuums -- there was no such thing as aggressive VACUUMs (just
antiwraparound autovacuums), and no need for autovacuum_freeze_max_age
at all. So autovacuum_freeze_max_age was just for autovacuum.c code.
There was only one type of VACUUM, and they always advanced
relfrozenxid to the same degree.

With the introduction of the visibility map, we needed to have
autovacuum_freeze_max_age in vacuum.c for the first time, to deal with
interpreting the then-new vacuum_freeze_table_age GUC correctly. We
silently truncate the vacuum_freeze_table_age setting so that it never
exceeds 95% of autovacuum_freeze_max_age (the
105%-of-autovacuum_freeze_max_age vacuum_failsafe_age thing that
you're discussing is symmetric). So after 2009
autovacuum_freeze_max_age actually plays an important role in VACUUM,
the command, and not just autovacuum.

This is related to the problem of the autovacuum_freeze_max_age
reloption being completely broken [1]. If autovacuum_freeze_max_age
was still purely just an autovacuum.c scheduling thing, then there
would be no problem with having a separate reloption of the same name.
There are big problems precisely because vacuum.c doesn't do anything
with the autovacuum_freeze_max_age reloption. Though it does okay with
the autovacuum_freeze_table_age reloption, which gets passed in. (Yes,
it's called autovacuum_freeze_table_age in reloption form -- not
vacuum_freeze_table_age, like the GUC).

Note that the decision to ignore the reloption version of
autovacuum_freeze_max_age in the failsafe's
105%-of-autovacuum_freeze_max_age thing was a deliberate one. The
autovacuum_freeze_max_age GUC is authoritative in the sense that it
cannot be overridden locally, except in the direction of making
aggressive VACUUMs happen more frequently for a given table (so they
can't be less frequent via reloption configuration). I suppose you'd
have to untangle that mess if you wanted to fix the
autovacuum_freeze_max_age reloption issue I go into in [1].

[1] https://postgr.es/m/CAH2-Wz=DJAokY_GhKJchgpa8k9t_H_OVOvfPEn97jGNr9W=deg@mail.gmail.com
--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2023-04-05 04:43:16 Re: proposal: psql: show current user in prompt
Previous Message Imseih (AWS), Sami 2023-04-05 04:07:21 Re: [BUG] pg_stat_statements and extended query protocol