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 1j7TE8-000220-Dn for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Feb 2020 00:10:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j7TE5-0001cN-Aa for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Feb 2020 00:09:57 +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 1j7TE4-0001bE-TS for pgsql-hackers@lists.postgresql.org; Fri, 28 Feb 2020 00:09:57 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j7TDv-0001Ql-Hz for pgsql-hackers@postgresql.org; Fri, 28 Feb 2020 00:09:54 +0000 Received: by mail-qk1-x743.google.com with SMTP id 11so1404001qkd.1 for ; Thu, 27 Feb 2020 16:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=szSt9iWXcs7PiAJpxe15jkqNzooPm5IatFAzuDUOWGE=; b=MFx+NhaN1QqDIYMldzNy4fohG6eEdId2RxmDdmwnFJwWlv14Oy56wWML7rfCmGSFBc WENHwStQ5U05h8btd3PzT8wJ4M5Xg4etOSg7FOfWDShmYKZwHyDLuoM3G7ktuksLi+E7 H/Mf9fIiIzZ35I7vmEg8/Wi9h9ZFBvNATeIyITn9SMGYTxV5NP3c+VxyTjRmeRETKUX4 aQqVyFypLkGrwBG6VzN9f+PjZ6QpXAc+T9rAFx4DtSMvMwoGr2WRtHxoAg0y+8l74qZP 7HVeVGEpIRxY/5c9fnmMvlKadXCE8VW6x/W17edqgMXZtBREk81/6ci/37tcgr1L2Lan ol/w== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=szSt9iWXcs7PiAJpxe15jkqNzooPm5IatFAzuDUOWGE=; b=KNFCkrtFoUkClKH2epgAwdsd3XMDeCwwycOq/W4zdRXihApPgoyc66HFcbpYw4EFDL UKZMVuTuMDs9lo2HFov04y+2iLQlPBrlfGtvkowOtl0cafs3SzV9FvhpukegQNJXvgjb UyI4N8905VcYCyncjBR8FZnQqjMqfJo9+RfZiP2IpSbkRoqH8rChZxhgOfxyVPZWwqLK ig/27KeyiZzSRar1LGVX5LYpHHbFGBjSzTwIy2AHvo3/oZZIiXp3YR2FgRrrn8bVQeKD 4nC9OrdNrE76IwJeShxCiRVb0HAcigUX6FESCOlaeXkDruGet+qCIhtcLKdNJxyweeU6 cBLg== X-Gm-Message-State: APjAAAXZep0SN/5ZFitls/N8vl9MYOG4VEcv1t6TZ+VnGOYTqADixfe+ TJc0CU/Qsn74UtQ5ycygOZ9rKQ== X-Google-Smtp-Source: APXvYqwAUbFT1D1kz4DlgxdtHVFHPQBZAuvhkB6pVVM2z1KJakwyRqcWTsdc2R0hrrPNlkC9rhfwvw== X-Received: by 2002:a37:48c4:: with SMTP id v187mr2290034qka.198.1582848585865; Thu, 27 Feb 2020 16:09:45 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([201.186.208.119]) by smtp.gmail.com with ESMTPSA id o16sm4072857qke.35.2020.02.27.16.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 16:09:44 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id E39A0300651; Thu, 27 Feb 2020 21:09:42 -0300 (-03) Date: Thu, 27 Feb 2020 21:09:42 -0300 From: Alvaro Herrera To: Justin Pryzby Cc: Masahiko Sawada , Andres Freund , Michael Paquier , pgsql-hackers@postgresql.org Subject: Re: error context for vacuum to include block number Message-ID: <20200228000942.GA16156@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200227210813.GC29456@telsasoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Feb-27, Justin Pryzby wrote: > Originally, the patch only supported "scanning heap", and set the callback > strictly, to avoid having callback installed when calling other functions (like > vacuuming heap/indexes). > > Then incrementally added callbacks in increasing number of places. We only > need one errcontext. And possibly you're right that the callback could always > be in place (?). But what about things like vacuuming FSM ? I think we'd need > another "phase" for that (or else invent a PHASE_IGNORE to do nothing). Would > VACUUM_FSM be added to progress reporting, too? We're also talking about new > phase for TRUNCATE_PREFETCH and TRUNCATE_WAIT. I think we should use a separate enum. It's simple enough, and there's no reason to use the same enum for two different things if it seems to complicate matters. > Regarding the cbarg, at one point I took a suggestion from Andres to use the > LVRelStats struct. I got rid of that since I didn't like sharing "blkno" > between heap scanning and heap vacuuming, and needs to be reset when switching > back to scanning heap. I experimented now going back to that now. The only > utility is in having an single allocation of relname/space. I'm unsure about reusing that struct. Not saying don't do it, just ... unsure. It possibly has other responsibilities. I don't think there's a reason to keep 0002 separate. Regarding this, > + case PROGRESS_VACUUM_PHASE_VACUUM_HEAP: > + if (BlockNumberIsValid(cbarg->blkno)) > + errcontext("while vacuuming block %u of relation \"%s.%s\"", > + cbarg->blkno, cbarg->relnamespace, cbarg->relname); > + break; I think you should still call errcontext() when blkno is invalid. In fact, just remove the "if" line altogether and let it show whatever value is there. It should work okay. We don't expect the value to be invalid anyway. Maybe it would make sense to make the LVRelStats struct members be char arrays rather than pointers. Then you memcpy() or strlcpy() them instead of palloc/free. Please don't cuddle your braces. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services