Re: Add pg_stat_autovacuum_priority

From: Andres Freund <andres(at)anarazel(dot)de>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, satyanarlapuram(at)gmail(dot)com, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, tndrwang(at)gmail(dot)com
Subject: Re: Add pg_stat_autovacuum_priority
Date: 2026-04-08 18:44:30
Message-ID: c4ftgtosizlzwo65kurhsbjhvtvq4qilfsfdbwnwohn6fsqpg6@5t5aspbgkifc
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2026-04-08 13:37:31 -0500, Nathan Bossart wrote:
> On Wed, Apr 08, 2026 at 01:28:06PM -0500, Sami Imseih wrote:
> >> + if (AmAutoVacuumWorkerProcess())
> >> + pfree(tabentry);
> >> }
> >
> > This works too, but v1-0001 is more generalized and we don't have to
> > care about who the caller is when deciding to free or not.
>
> Well, I think if we were building this view from scratch without any
> knowledge of autovacuum, we probably wouldnt bother manually freeing the
> stats entries based on the value of the GUC. We'd probably just let the
> commit/abort code take care of it, which AFAICT is what we do elsewhere.
> Manually freeing the entries is also risky, which commit 02502c1bca touches
> on:
>
> Note: pfree'ing the PgStat_StatTabEntry structs here seems a bit
> risky, because pgstat_fetch_stat_tabentry_ext does not guarantee
> anything about whether its result is long-lived. It appears okay
> so long as autovacuum forces PGSTAT_FETCH_CONSISTENCY_NONE, but
> I think that API could use a re-think.
>
> This seems very much to be an autovacuum-specific hack that we shouldn't be
> propagating elsewhere.

Agreed. There aren't that many callers of pgstat_fetch_entry (even if you
count indirect ones), I think the best path might be to add a bool *may_free
argument where necessary and just deal with the size of change that brings
with it.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-04-08 18:53:20 Re: Add pg_stat_autovacuum_priority
Previous Message Nathan Bossart 2026-04-08 18:37:31 Re: Add pg_stat_autovacuum_priority