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-22T23:17:26Z
Lists: pgsql-hackers
On Mon, Jan 20, 2020 at 11:11:20AM -0800, Andres Freund wrote:
> > @@ -966,8 +986,11 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
> >  			/* Work on all the indexes, then the heap */
> > +			/* Don't use the errcontext handler outside this function */
> > +			error_context_stack = errcallback.previous;
> >  			lazy_vacuum_all_indexes(onerel, Irel, indstats,
> >  									vacrelstats, lps, nindexes);
> > +			error_context_stack = &errcallback;
> 
> Alternatively we could push another context for each index inside
> lazy_vacuum_all_indexes(). There's been plenty bugs in indexes
> triggering problems, so that could be worthwhile.

Is the callback for index vacuum useful without a block number?

FYI, I have another patch which would add DEBUG output before each stage, which
would be just as much information, and without needing to use a callback.
It's 0004 here:

https://www.postgresql.org/message-id/20200121134934.GY26045%40telsasoft.com
@@ -1752,9 +1753,12 @@ lazy_vacuum_all_indexes(Relation onerel, Relation *Irel,
        {
                int                     idx;

-               for (idx = 0; idx < nindexes; idx++)
+               for (idx = 0; idx < nindexes; idx++) {
+                       ereport(DEBUG1, (errmsg("\"%s\": vacuuming index",
+                                                       RelationGetRelationName(Irel[idx]))));
                        lazy_vacuum_index(Irel[idx], &stats[idx], vacrelstats->dead_tuples,




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