Re: Add SKIP LOCKED to VACUUM and ANALYZE

Nathan Bossart <bossartn@amazon.com>

From: "Bossart, Nathan" <bossartn@amazon.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, "Andres Freund" <andres@anarazel.de>, Masahiko Sawada <sawada.mshk@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, Lyes Ameddah <lyes.amd@gmail.com>
Date: 2018-07-29T22:56:24Z
Lists: pgsql-hackers
On 7/24/18, 8:07 PM, "Michael Paquier" <michael@paquier.xyz> wrote:
> Hm...  I have not imagined this part but adding a new layer is sort of
> ugly, and an extra one would be needed for CLUSTER as well, in which
> case adding cluster-related logs into vacuum.c introduces a circular
> dependency with cluster.c.  What about just skipping this refactoring
> and move to the point where CLUSTER also gains its log queries directly
> in cluster_rel?  VACUUM FULL is also not going to run for autovacuum, so
> that's less confusion with IsAutoVacuumWorkerProcess().

Since vacuum_rel() already obtains an AccessExclusiveLock on the
relation for VACUUM FULL, we might be able to skip altering
cluster_rel().  I think we will need to alter it if we are going to
add SKIP LOCKED to CLUSTER, though.

Nathan

Commits

  1. Add option SKIP_LOCKED to VACUUM and ANALYZE

  2. Refactor relation opening for VACUUM and ANALYZE

  3. Refactor cluster_rel() to handle more options

  4. Add assertion in expand_vacuum_rel() for non-autovacuum path