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 1jGjvM-00032B-SY for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2020 13:48:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGjvL-0001nY-Lb for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2020 13:48:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jGjvL-0001nP-5t for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2020 13:48:55 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jGjvI-0004Ht-8I for pgsql-hackers@postgresql.org; Tue, 24 Mar 2020 13:48:53 +0000 Received: by mail-qk1-x732.google.com with SMTP id l25so14347697qki.7 for ; Tue, 24 Mar 2020 06:48:52 -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=rH1jVSOJSs2ClJzCR8oiZIAhMLDKFSo2XickgvV0AZ4=; b=iixGmtQnoHuT67sLvih2Rx92nPft+2Jjs7xohJHTWZsys9X2oBk2APefyMiYFcZyO+ n8HA1WM0AD/lIuRN8U7ud566Lij4Y+bmF11Q4SA4T/NBm1rIV1urvblhjWra3Gc6hV4i I2N2TYCOouvc0FJOah1vt4U/P8sRRdWn8Utgz6C2K2xfvhvYi0MLMnqtUuz5o4hB1+e4 02dWtqWrBwhKkdivAxPx4//lMyKaNsHvTK56JCQCK60wCXtavqEx9HyfG1BnHwrHBypI TL8U8BpW0zfetoftAYQVmao8DJLZR3fRezJYARjFIQTvTi200cCovQ/pF7Gf/BTEuQPt Bg+g== 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=rH1jVSOJSs2ClJzCR8oiZIAhMLDKFSo2XickgvV0AZ4=; b=boXr55dLxK2JnEJA6ENBmr+tkxWMrrXD+fVYa/CBc3RV1yU+dgL9kMDN2xTYUUAj/i k+uAfCwjzR72atZeoG6gl0svttCb5lBC5958C7TgyK9ls/h9e5VPLchO6rkFeqmuNSwV IRrxNj9PV24nIbM9W4b48at9DIHMxR4Lab9J0AxljrA1gdvB5AtNC8G6S8dCh3Gi1zt/ I3HUapetwDA00IYADFw8ElUvMti6rLa/gj9ibe9kzzXAUXjbQmpwRSER2p1hTP2MqvUS hC/4RJO3D9DXStAt6g0sd41yLW+7E2iYnFcQvEOWqt/8ss4nQKkqlIKKgrYl7h+4K0j7 o78Q== X-Gm-Message-State: ANhLgQ1LuiNv/KlvaS0VfydtobSOmCj5dwKq9GIo3Ci5/7qdoXokUk/Z v7jANnl0ekGDABCDERgKmS+syA== X-Google-Smtp-Source: ADFU+vvdR3m1xSz815gEp5v6+OZflVU1nMBHQaNb8N6+8ITY74OAqlM4HAwScpKYxznIsnc+Jk6vNg== X-Received: by 2002:a37:9ac6:: with SMTP id c189mr25516945qke.214.1585057731340; Tue, 24 Mar 2020 06:48:51 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id k124sm5314511qke.108.2020.03.24.06.48.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2020 06:48:50 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 2B4B5800C28; Tue, 24 Mar 2020 08:48:49 -0500 (CDT) Date: Tue, 24 Mar 2020 08:48:49 -0500 From: Justin Pryzby To: Amit Kapila Cc: Masahiko Sawada , Alvaro Herrera , Andres Freund , Michael Paquier , pgsql-hackers@postgresql.org Subject: Re: error context for vacuum to include block number Message-ID: <20200324134848.GH21443@telsasoft.com> References: <20200323081639.GI2563@telsasoft.com> <20200324041616.GA21443@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 Tue, Mar 24, 2020 at 07:07:03PM +0530, Amit Kapila wrote: > On Tue, Mar 24, 2020 at 6:18 PM Masahiko Sawada wrote: > > 1. > > + /* Update error traceback information */ > > + olderrcbarg = *vacrelstats; > > + update_vacuum_error_cbarg(vacrelstats, > > + VACUUM_ERRCB_PHASE_TRUNCATE, > > new_rel_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); > > > > We need to set the error context after setting new_rel_pages. > > We want to cover the errors raised in count_nondeletable_pages(). In > an earlier version of the patch, we had TRUNCATE_PREFETCH phase which > use to cover those errors, but that was not good as we were > setting/resetting it multiple times and it was not clear such a > separate phase would add any value. I insisted on covering count_nondeletable_pages since it calls ReadBuffer(), but I think we need to at least set vacrelsats->blkno = new_rel_pages, since it may be different, right ? > > 2. > > + vacrelstats->relnamespace = > > get_namespace_name(RelationGetNamespace(onerel)); > > + vacrelstats->relname = pstrdup(RelationGetRelationName(onerel)); > > > > I think we can pfree these two variables to avoid a memory leak during > > vacuum on multiple relations. > > Yeah, I had also thought about it but I noticed that we are not > freeing for vacrelstats. Also, I think the memory is allocated in > TopTransactionContext which should be freed via > CommitTransactionCommand before vacuuming of the next relation, so not > sure if there is much value in freeing those variables. One small reason to free them is that (as Tom mentioned upthread) it's good to ensure that those variables are their own allocation, and not depending on being able to access relcache or anything else during an unexpected error. -- Justin