Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jH5MF-0003Mt-Kc for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2020 12:42:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jH5MD-0001Hz-6v for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2020 12:42:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jH5MC-0001HA-PX for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2020 12:42:04 +0000 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jH5M8-0000Zs-Jp for pgsql-hackers@postgresql.org; Wed, 25 Mar 2020 12:42:04 +0000 Received: by mail-qv1-xf36.google.com with SMTP id g4so892723qvo.12 for ; Wed, 25 Mar 2020 05:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yKRRZv5ocaicT69WFqcESKLh+T6saGBJm7sKobLllyE=; b=dN+cZPSW3ipEkfjyUu9tjgue9Mt4srPCS4ds6MlcK9Xja6e4Q4wIkw1Jt+MyOMQsF+ A+h7vu/sAulMzK2wYH0m5RUyvEEbn8nWdmB3l4BzeA2YL65AH+E31PzHsyC43hlAYE7V AaWXDRplsjRTEMSkl/YBEnL+xHzMiwE808MPkzhAcZ649djkgEoyUwbFPfCqy9nLP5l7 mQYYA+ajFatGy7oLsIRsIYfSc64GWe4R93M301wsMG3hw9MhbD+lhpjkBV0jHJjiny4H f5jM8LW0XNow0AVZFm403pdzP+d6XQxV4jxrnyOUK7SSsua3cKueTWXTWyCw0V2ziAc7 78ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yKRRZv5ocaicT69WFqcESKLh+T6saGBJm7sKobLllyE=; b=MgjEJY1i38CU4DKawcbOxnPqzppIYOBaSABcyjLPAKFJ20g237MR5+r+volbQkOnnF z7aOgaQ1gStGaUB99LTkcEVU0U1cMyGlOn5UsVaSoHLL2RA1LvDcH8Ey9Mz76RcZRpro Z55HZazOER5+MkTxYb2fWu3TVQuXKzi5cPi2gEvlEHkOUJ0flHM4FeDTceODltAM9lEP A8u5FBePwpOVMLbvy9N4lZdMqvajAcyTAh1s0jh2Ogpjn3iu5U4w27AsjvSrO/AVuEay Q5mIssF9O5eNRvpCpdmCaeMMQG6dMPrWKvQZZUpLXMb71YbdkCj7tZnHpJIrtUJiCDka KkFw== X-Gm-Message-State: ANhLgQ1jNlldDw8xQxMLHxupYQOBCUrSaKf6CCPTJcpWx0E1NKtwL0Yx 4T7RehpKaNhMAThDU/tGVtd8DQ== X-Google-Smtp-Source: ADFU+vsdDMExGvcZ3TdRlCi6TDk6lcZFChrWzk17qvBgmetnOqzywjkINW9YBirnYi8tko7x1KZDFA== X-Received: by 2002:ad4:4388:: with SMTP id s8mr2948148qvr.2.1585140118120; Wed, 25 Mar 2020 05:41:58 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id r40sm17353234qtc.39.2020.03.25.05.41.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Mar 2020 05:41:57 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 8DF34800C28; Wed, 25 Mar 2020 07:41:55 -0500 (CDT) Date: Wed, 25 Mar 2020 07:41:55 -0500 From: Justin Pryzby To: Masahiko Sawada Cc: Amit Kapila , Alvaro Herrera , Andres Freund , Michael Paquier , pgsql-hackers Subject: Re: error context for vacuum to include block number Message-ID: <20200325124155.GU21443@telsasoft.com> References: <20200325101229.GR21443@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Mar 25, 2020 at 09:27:44PM +0900, Masahiko Sawada wrote: > On Wed, 25 Mar 2020 at 20:24, Amit Kapila wrote: > > > > On Wed, Mar 25, 2020 at 3:42 PM Justin Pryzby wrote: > > > > > > Attached patch addressing these. > > > > > > > Thanks, you forgot to remove the below declaration which I have > > removed in attached. > > > > @@ -724,20 +758,20 @@ lazy_scan_heap(Relation onerel, VacuumParams > > *params, LVRelStats *vacrelstats, > > PROGRESS_VACUUM_MAX_DEAD_TUPLES > > }; > > int64 initprog_val[3]; > > + ErrorContextCallback errcallback; > > > > Apart from this, I have ran pgindent and now I think it is in good > > shape. Do you have any other comments? Sawada-San, can you also > > check the attached patch and let me know if you have any additional > > comments. > > > > Thank you for updating the patch! I have a question about the following code: > > + /* Update error traceback information */ > + olderrcbarg = *vacrelstats; > + update_vacuum_error_cbarg(vacrelstats, VACUUM_ERRCB_PHASE_TRUNCATE, > + vacrelstats->nonempty_pages, NULL, false); > + > /* > * Scan backwards from the end to verify that the end pages actually > * contain no tuples. This is *necessary*, not optional, because > * other backends could have added tuples to these pages whilst we > * were vacuuming. > */ > new_rel_pages = count_nondeletable_pages(onerel, vacrelstats); > + vacrelstats->blkno = new_rel_pages; > > if (new_rel_pages >= old_rel_pages) > { > /* can't do anything after all */ > UnlockRelation(onerel, AccessExclusiveLock); > return; > } > > /* > * Okay to truncate. > */ > RelationTruncate(onerel, new_rel_pages); > > + /* Revert back to the old phase information for error traceback */ > + update_vacuum_error_cbarg(vacrelstats, > + olderrcbarg.phase, > + olderrcbarg.blkno, > + olderrcbarg.indname, > + true); > > vacrelstats->nonempty_pages is the last non-empty block while > new_rel_pages, the result of count_nondeletable_pages(), is the number > of blocks that we can truncate to in this attempt. Therefore > vacrelstats->nonempty_pages <= new_rel_pages. This means that we set a > lower block number to arguments and then set a higher block number > after count_nondeletable_pages, and then revert it back to > VACUUM_ERRCB_PHASE_SCAN_HEAP phase and the number of blocks of > relation before truncation, after RelationTruncate(). It can be > repeated until no more truncating can be done. Why do we need to > revert back to the scan heap phase? If we can use > vacrelstats->nonempty_pages in the error context message as the > remaining blocks after truncation I think we can update callback > arguments once at the beginning of lazy_truncate_heap() and don't > revert to the previous phase, and pop the error context after exiting. Perhaps. We need to "revert back" for the vacuum phases, which can be called multiple times, but we don't need to do that here. In the future, if we decided to add something for final cleanup phase (say), it's fine (and maybe better) to exit truncate_heap() without resetting the argument, and we'd immediately set it to CLEANUP. I think the same thing applies to lazy_cleanup_index, too. It can be called from a parallel worker, but we never "go back" to a heap scan. -- Justin