Re: Add pg_stat_autovacuum_priority - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: Add pg_stat_autovacuum_priority
Date
Msg-id CAA5RZ0tUq7SEHvAPkYpCw7Y4XOoWLPpsfxO2ZQ5AzQRcQMMAgg@mail.gmail.com
Whole thread Raw
In response to Re: Add pg_stat_autovacuum_priority  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Add pg_stat_autovacuum_priority
List pgsql-hackers
> diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
> index bd626a16363..6d4a34257fb 100644
> --- a/src/backend/postmaster/autovacuum.c
> +++ b/src/backend/postmaster/autovacuum.c
> @@ -3327,7 +3327,15 @@ relation_needs_vacanalyze(Oid relid,
>               anltuples, anlthresh, scores->anl,
>               scores->xid, scores->mxid);
>
> -    pfree(tabentry);
> +    /*
> +     * Avoid leaking pgstat entries until the end of autovacuum.  Elsewhere,
> +     * we let the commit/abort machinery take care of freeing it.  While
> +     * autovacuum workers set stats_fetch_consistency to "none", it might be
> +     * set to a different value in other processes, so we can't safely free it
> +     * here for them.
> +     */
> +    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.

--
Sami



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Add pg_stat_autovacuum_priority
Next
From: Nathan Bossart
Date:
Subject: Re: Add pg_stat_autovacuum_priority