Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3gmJ-0007Wt-SI for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Aug 2020 14:21:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k3gln-0002vz-9J for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Aug 2020 14:21:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3glm-0002vr-Tl for pgsql-hackers@lists.postgresql.org; Thu, 06 Aug 2020 14:21:23 +0000 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k3glj-0001Ug-VS for pgsql-hackers@postgresql.org; Thu, 06 Aug 2020 14:21:21 +0000 Received: by mail-io1-xd41.google.com with SMTP id g14so12261647iom.0 for ; Thu, 06 Aug 2020 07:21:19 -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=foSU7boJAcsn+W1C5CgcX+loiYf6BfqCyzJUUSFW+7w=; b=dLCL5fO5XrGzaSprda+E3ND9ZWVP/kItWZQ1Teeh/qYAhILopuOu0DqXeoSyNqSW9x YYfAEXFIm8gNMI0cwizqQ23V1YcXZdeqxw2HmS5RhwaaQENSLiO2j84HecRkPHdglyl2 g1XXKFyV1zEo7g4q8KFA/dsTyENOveCc3JVDVmzE5s2c3ed3ph0KKOYfwwONWpSF+WP3 OoEoOnvi9KC6RXRBswXM2a5PJkDxfkrIa0AQJgFeewU1eRM6Ag23o+Csr4MYHulqy6Pq w0lJRxCwPdz+BTstQfrNwHrfRsuBHWmW8QSwptG5Yy50SbEMnCAetkGCE4mXeUdMsFPK 47Ag== 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=foSU7boJAcsn+W1C5CgcX+loiYf6BfqCyzJUUSFW+7w=; b=gdAwCqPqCtV9vMdSe2pAqToSSTKmequnj1QXbwwm0ElmUqMb3m/8UXALX3+qx+F8zm 0G2Z9qoakwvJLejlJ2/ICJLhj8Kw8063qNRDPJH8JU1cxdcFThmd5/f7H/gI5XFhguMs d/13cCDM/aEKSjlBvpLHQSvYViv+cglYJYgcNtMMD8EQqWzAHhcSUliykUxn7pwWmXHP VUUp30m8ec/AD4WbATIt86H2+tlAZbJq2imcJgtXxltwSEQ+ootzCJSzyTGtrRSjPc32 AJoM87YCb85n0viLbrVX+Wm3L/rxXsLr5oZbuWzA7VPtapWB5gP1ptm434prXlTvocd9 5Now== X-Gm-Message-State: AOAM533DBM15EtCHmbA69AtI9HXcs9WtOYhsBLuHsJzx5PW4RIcH90wi 2TjlbXf8OkYJovQwzLFBwoqQFQ== X-Google-Smtp-Source: ABdhPJy/FQ0bkbRakiZ10DhApYBY4dWrs169174bkPEZWkoXyQZtr038aR1Wv5lhJGf17gCTj9A1FA== X-Received: by 2002:a6b:b513:: with SMTP id e19mr10316442iof.167.1596723679020; Thu, 06 Aug 2020 07:21:19 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id t5sm3986019ilp.15.2020.08.06.07.21.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2020 07:21:18 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 121DC80015E; Thu, 6 Aug 2020 09:21:17 -0500 (CDT) Date: Thu, 6 Aug 2020 09:21:16 -0500 From: Justin Pryzby To: Amit Kapila Cc: Mahendra Singh Thalor , pgsql-hackers Subject: Re: display offset along with block number in vacuum errors Message-ID: <20200806142116.GL28072@telsasoft.com> References: <20200727111352.GN4286@telsasoft.com> <20200728193919.GK20393@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 Thu, Aug 06, 2020 at 07:39:21PM +0530, Amit Kapila wrote: > On Wed, Jul 29, 2020 at 1:09 AM Justin Pryzby wrote: > > > > On Wed, Jul 29, 2020 at 12:35:17AM +0530, Mahendra Singh Thalor wrote: > > > Apart from these, I fixed comments given by Sawada and Michael in the > > > latest patch. Attaching v2 patch for review. > > > > Thanks. > > > > lazy_check_needs_freeze iterates over blocks and this patch changes it to > > update vacrelstats. I think it should do what > > lazy_{vacuum/cleanup}_heap/page/index do and call update_vacuum_error_info() at > > its beginning (even though only the offset is changed), and then > > restore_vacuum_error_info() at its end (to "revert back" to the item number it > > started with). > > > > I see that Mahendra has changed patch as per this suggestion but I am > not convinced that it is a good idea to sprinkle > update_vacuum_error_info()/restore_vacuum_error_info() at places more > than required. I see that it might look a bit clean from the > perspective that if tomorrow we use the function > lazy_check_needs_freeze() for a different purpose then we don't need > to worry about the wrong phase information. If we are worried about > that then we should have an assert in that function to ensure that the > current phase is VACUUM_ERRCB_PHASE_SCAN_HEAP. The motivation was to restore the offnum, which is set to Invalid at the start of lazy_scan_heap(), and then set valid within lazy_check_needs_freeze, but should be restored or re-set to Invalid when returns to lazy_scan_heap(). If you think it's important, we could just set vacrelstats->offnum = Invalid before returning, but that's what the restore function was built for. We do direct assignment in 2 places to avoid a function call within a loop. lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, Relation *Irel, int nindexes, bool aggressive) ... for (blkno = 0; blkno < nblocks; blkno++) { ... update_vacuum_error_info(vacrelstats, NULL, VACUUM_ERRCB_PHASE_SCAN_HEAP, blkno, InvalidOffsetNumber); if (!ConditionalLockBufferForCleanup(buf)) { ... if (!lazy_check_needs_freeze(buf, &hastup, vacrelstats)) { ... for (offnum = FirstOffsetNumber; offnum <= maxoff; offnum = OffsetNumberNext(offnum)) -- Justin