pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@postgresql.org
Subject: Re: error context for vacuum to include block number
Date: Tue, 24 Mar 2020 23:46:51 -0500
Message-ID: <20200325044651.GO21443@telsasoft.com> (raw)
In-Reply-To: <CA+fd4k5e1q4t9k4pLQah1qx8GZKy2wb1EUp_YsNOGfgOxX+GHg@mail.gmail.com>
References: <CAA4eK1KaWto3+4+EsLPRFL6HKs8=_42V2ivAFEPBU-o_o6AYXw@mail.gmail.com>
	<20200324041616.GA21443@telsasoft.com>
	<CAA4eK1J4wNO425WjKj2Yd58Ag=LovSkxoHTuBJphFma+9jLAJA@mail.gmail.com>
	<CA+fd4k5TFS87WXsgne17dbYGUq79bvx-WnumfF22eqkjCHtXkA@mail.gmail.com>
	<CAA4eK1+vjO-M4OaHUjjDpTkR+g47BC+mSr64qniZac6Qks_w_w@mail.gmail.com>
	<CA+fd4k4ayy53qhn=rDNvazM8-rNOQ5wsAuZP05ekvvwsaed4Wg@mail.gmail.com>
	<CAA4eK1+O8q9_e10DTOnAbX6Mf9C1bSDBZFmhCLSihb-ZgBXsGQ@mail.gmail.com>
	<CA+fd4k4LfJwv=JaLFG4pZKvwwimO6MHFZ7YfMFqubdKXjiRDVw@mail.gmail.com>
	<CAA4eK1+v7nKwX8oNwfTur3EKW8QDWbgFYzyjsHtRQWDqazq2zA@mail.gmail.com>
	<CA+fd4k5e1q4t9k4pLQah1qx8GZKy2wb1EUp_YsNOGfgOxX+GHg@mail.gmail.com>

On Wed, Mar 25, 2020 at 01:34:43PM +0900, Masahiko Sawada wrote:
> I meant that with the patch, suppose that the table has 100 blocks and
> we're truncating it to 50 blocks in RelationTruncate(), the error
> context message will be "while truncating relation "aaa.bbb" to 100
> blocks", which is not correct.

> I think it should be "while truncating
> relation "aaa.bbb" to 50 blocks". We can know the relation can be
> truncated to 50 blocks by the result of count_nondeletable_pages(). So
> if we update the arguments before it we will use the number of blocks
> of relation before truncation.

Hm, yea, at that point it's:
|new_rel_pages = RelationGetNumberOfBlocks(onerel);
..so we can do better.

> My suggestion is either that we change the error message to, for
> example, "while truncating relation "aaa.bbb" having 100 blocks", or
> that we change the patch so that we can use "50 blocks" in the error
> context message.

We could do:

        update_vacuum_error_cbarg(vacrelstats,
				  VACUUM_ERRCB_PHASE_TRUNCATE,
				  InvalidBlockNumber, NULL, false);

        new_rel_pages = count_nondeletable_pages(onerel, vacrelstats);
        vacrelstats->blkno = new_rel_pages;

...

        case VACUUM_ERRCB_PHASE_TRUNCATE:
            if (BlockNumberIsValid(cbarg->blkno))
                errcontext("while truncating relation \"%s.%s\" to %u blocks",
                           cbarg->relnamespace, cbarg->relname, cbarg->blkno);
            else
                /* Error happened before/during count_nondeletable_pages() */
                errcontext("while truncating relation \"%s.%s\"",
                           cbarg->relnamespace, cbarg->relname);
            break;

-- 
Justin





view thread (139+ messages)  latest in thread

Message-ID: <20200325044651.GO21443@telsasoft.com>
Permalink:  ../20200325044651.GO21443@telsasoft.com/
Also on:    postgresql.org/message-id/20200325044651.GO21443@telsasoft.com

 · 

reply

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: pryzby@telsasoft.com, masahiko.sawada@2ndquadrant.com, amit.kapila16@gmail.com, alvherre@2ndquadrant.com, andres@anarazel.de, michael@paquier.xyz
  Subject: Re: error context for vacuum to include block number
  In-Reply-To: <20200325044651.GO21443@telsasoft.com>

* 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