Re: error context for vacuum to include block number

Justin Pryzby <pryzby@telsasoft.com>

From: Justin Pryzby <pryzby@telsasoft.com>
To: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>, Alvaro Herrera <alvherre@2ndquadrant.com>, pgsql-hackers@postgresql.org
Date: 2020-01-27T05:38:13Z
Lists: pgsql-hackers

Attachments

On Sun, Jan 26, 2020 at 12:29:38PM -0800, Andres Freund wrote:
> > postgres=# SET client_min_messages=debug;SET statement_timeout=99; VACUUM (VERBOSE, PARALLEL 0) t;
> > INFO:  vacuuming "public.t"
> > DEBUG:  "t_a_idx": vacuuming index
> > 2020-01-20 15:47:36.338 CST [20139] ERROR:  canceling statement due to statement timeout
> > 2020-01-20 15:47:36.338 CST [20139] CONTEXT:  while vacuuming relation "public.t_a_idx"
> > 2020-01-20 15:47:36.338 CST [20139] STATEMENT:  VACUUM (VERBOSE, PARALLEL 0) t;
> > ERROR:  canceling statement due to statement timeout
> > CONTEXT:  while vacuuming relation "public.t_a_idx"
> 
> It'd be a bit nicer if it said index "public.t_a_idx" for relation "public.t".

I think that tips the scale in favour of making vacrelstats a global.
I added that as a 1st patch, and squished the callback patches into one.

Also, it seems to me we shouldn't repeat the namespace of the index *and* its
table.  I tried looking for consistency here:

grep -r '\\"%s.%s\\"' --incl='*.c' |grep '\\"%s\\"'
src/backend/commands/cluster.c:                         (errmsg("clustering \"%s.%s\" using index scan on \"%s\"",
src/backend/access/heap/vacuumlazy.c:           errcontext(_("while vacuuming index \"%s\" on table \"%s.%s\""),

grep -r 'index \\".* table \\"' --incl='*.c'
src/backend/catalog/index.c:                            (errmsg("building index \"%s\" on table \"%s\" serially",
src/backend/catalog/index.c:                            (errmsg_plural("building index \"%s\" on table \"%s\" with request for %d parallel worker",
src/backend/catalog/index.c:                                                       "building index \"%s\" on table \"%s\" with request for %d parallel workers",
src/backend/catalog/catalog.c:                           errmsg("index \"%s\" does not belong to table \"%s\"",
src/backend/commands/indexcmds.c:                               (errmsg("%s %s will create implicit index \"%s\" for table \"%s\"",
src/backend/commands/tablecmds.c:                                errmsg("index \"%s\" for table \"%s\" does not exist",
src/backend/commands/tablecmds.c:                                errmsg("index \"%s\" for table \"%s\" does not exist",
src/backend/commands/tablecmds.c:                                                errdetail("The index \"%s\" belongs to a constraint in table \"%s\" but no constraint exists for index \"%s\".",
src/backend/commands/cluster.c:                                          errmsg("index \"%s\" for table \"%s\" does not exist",
src/backend/parser/parse_utilcmd.c:                                      errmsg("index \"%s\" does not belong to table \"%s\"",

Commits

  1. Avoid calls to RelationGetRelationName() and RelationGetNamespace() in

  2. Introduce vacuum errcontext to display additional information.

  3. Fix mesurement of elapsed time during truncating heap in VACUUM.

  4. Allow vacuum command to process indexes in parallel.

  5. Refactor code dedicated to index vacuuming in vacuumlazy.c

  6. Remove duplicated progress reporting during heap scan of VACUUM