Re: Berserk Autovacuum (let's save next Mandrill)
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Andres Freund <andres@anarazel.de>, Masahiko Sawada <masahiko.sawada@2ndquadrant.com>, David Rowley <dgrowleyml@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, Amit Kapila <amit.kapila16@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>, Darafei Komяpa Praliaskouski <me@komzpa.net>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>, Alvaro Herrera <alvherre@2ndquadrant.com>, Michael Banck <mbanck@gmx.net>
Date: 2020-03-17T15:24:09Z
Lists: pgsql-hackers
On Tue, Mar 17, 2020 at 01:14:02AM +0100, Laurenz Albe wrote:
> lazy_check_needs_freeze() is only called for an aggressive vacuum, which
> this isn't.
> --- a/src/backend/access/heap/vacuumlazy.c
> +++ b/src/backend/access/heap/vacuumlazy.c
> @@ -1388,17 +1388,26 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
> else
> {
> bool tuple_totally_frozen;
> + bool freeze_all;
>
> num_tuples += 1;
> hastup = true;
>
> + /*
> + * If any tuple was already frozen in the block and this is
> + * an insert-only vacuum, we might as well freeze all other
> + * tuples in that block.
> + */
> + freeze_all = params->is_insert_only && has_dead_tuples;
> +
You're checking if any (previously-scanned) tuple was *dead*, but I think you
need to check nfrozen>=0.
Also, this will fail to freeze tuples on a page which *could* be
oppotunistically-frozen, but *follow* the first tuple which *needs* to be
frozen.
I think Andres was thinking this would maybe be an optimization independent of
is_insert_only (?)
> /*
> * Each non-removable tuple must be checked to see if it needs
> * freezing. Note we already have exclusive buffer lock.
> */
> if (heap_prepare_freeze_tuple(tuple.t_data,
> relfrozenxid, relminmxid,
> - FreezeLimit, MultiXactCutoff,
> + freeze_all ? 0 : FreezeLimit,
> + freeze_all ? 0 : MultiXactCutoff,
> &frozen[nfrozen],
> &tuple_totally_frozen))
> + /* normal autovacuum shouldn't freeze aggressively */
> + *insert_only = false;
Aggressively is a bad choice of words. In the context of vacuum, it usually
means "visit all pages, even those which are allvisible".
--
Justin
Commits
-
Further improve stability fix for partition_aggregate test.
- 18d85e9b8a2b 13.0 landed
-
Improve stability fix for partition_aggregate test.
- 7cb0a423f914 13.0 landed
-
Attempt to stabilize partitionwise_aggregate test
- cefb82d49e21 13.0 landed
-
Fix race condition in statext_store().
- fe3036527a1f 13.0 landed
- 6c426cd43790 12.3 landed
-
Attempt to fix unstable regression tests, take 2
- 24566b359d09 13.0 landed
-
Attempt to fix unstable regression tests
- 2dc16efedc76 13.0 landed
-
Trigger autovacuum based on number of INSERTs
- b07642dbcd8d 13.0 landed
-
Fix upper limit for vacuum_cleanup_index_scale_factor
- 4d54543efa5e 11.0 cited