From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: error context for vacuum to include block number
Date: Mon, 16 Mar 2020 11:17:33 -0300
Message-ID: <20200316141733.GA14437@alvherre.pgsql> (raw)
In-Reply-To: <CAA4eK1JBU9ZtvwUL2VgGB+XBWZQEq+k+XJhCpnstjJ=v7744DA@mail.gmail.com>
On 2020-Mar-16, Amit Kapila wrote:
> 2.
> + /* Setup error traceback support for ereport() */
> + update_vacuum_error_cbarg(vacrelstats, VACUUM_ERRCB_PHASE_SCAN_HEAP,
> + InvalidBlockNumber, NULL);
> + errcallback.callback = vacuum_error_callback;
> + errcallback.arg = vacrelstats;
> + errcallback.previous = error_context_stack;
> + error_context_stack = &errcallback;
> ..
> ..
> + /* Init vacrelstats for use as error callback by parallel worker: */
> + vacrelstats.relnamespace = get_namespace_name(RelationGetNamespace(onerel));
> + vacrelstats.relname = pstrdup(RelationGetRelationName(onerel));
> + vacrelstats.indname = NULL;
> + vacrelstats.phase = VACUUM_ERRCB_PHASE_UNKNOWN; /* Not yet processing */
> +
> + /* Setup error traceback support for ereport() */
> + errcallback.callback = vacuum_error_callback;
> + errcallback.arg = &vacrelstats;
> + errcallback.previous = error_context_stack;
> + error_context_stack = &errcallback;
> +
>
> I think the code can be bit simplified if we have a function
> setup_vacuum_error_ctx which takes necessary parameters and fill the
> required vacrelstats params, setup errcallback. Then we can use
> update_vacuum_error_cbarg at required places.
Heh, he had that and I took it away -- it looked unnatural. I thought
changing error_context_stack inside such a function, then resetting it
back to "previous" outside the function, was too leaky an abstraction.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, amit.kapila16@gmail.com, pryzby@telsasoft.com, masahiko.sawada@2ndquadrant.com, andres@anarazel.de, michael@paquier.xyz
Subject: Re: error context for vacuum to include block number
In-Reply-To: <20200316141733.GA14437@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox