Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dy2B1-000716-Du for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Sep 2017 20:46:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dy2B0-0003qx-Ry for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Sep 2017 20:46:26 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dy29S-00012O-Ax for pgsql-hackers@postgresql.org; Fri, 29 Sep 2017 20:44:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dy29P-0004BE-2j for pgsql-hackers@postgresql.org; Fri, 29 Sep 2017 20:44:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v8TKihW8013190; Fri, 29 Sep 2017 16:44:43 -0400 From: Tom Lane To: Robert Haas cc: Noah Misch , "pgsql-hackers@postgresql.org" , Michael Paquier Subject: Re: Shaky coding for vacuuming partitioned relations In-reply-to: References: <25023.1506107590@sss.pgh.pa.us> <20170928053123.GD37725@rfd.leadboat.com> <1016.1506703393@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 29 Sep 2017 12:46:23 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13188.1506717882.1@sss.pgh.pa.us> Date: Fri, 29 Sep 2017 16:44:42 -0400 Message-ID: <13189.1506717882@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Robert Haas writes: > On Fri, Sep 29, 2017 at 12:43 PM, Tom Lane wrote: >> Robert Haas writes: >>> If I understand correctly, problem #1 is that get_rel_oids() can emit >>> a user-visible cache lookup failure message. There is a proposed patch >>> by Michael Paquier which appears to implement the design suggested by >>> Tom. I think that the normal procedure would be for Tom to commit >>> that change if he's happy with it. >> Yes, I'm happy to take responsibility for this. > Great, thanks. After thinking more carefully about the idea I proposed upthread (viz, take and keep ShareUpdateExclusiveLock), I realized that that will be pretty horrid once the proposed patch to allow VACUUM to name multiple target tables goes in. We'd be trying to take a pretty strong lock on multiple tables at once during get_rel_oids(), creating substantial risk of deadlock. Up to now, VACUUM has always been careful to not take more than one such lock at once, and I think we need to preserve that property. The simplest solution therefore seems to be to just take AccessShareLock and then release it as soon as we're done adding the rel and its partitions to the list of target rels. There's little point in taking a stronger lock here if we are going to end the transaction and drop it later, and it's a nicely low-risk answer for v10 in any case. >>> I don't think I understand problem #2. I think the concern is about >>> reporting the proper relation name when VACUUM cascades from a >>> partitioned table to its children and then some kind of concurrent DDL >>> happens, but I don't see a clear explanation on the thread as to what >>> exactly the failure scenario is, and I didn't see a problem in some >>> simple tests I just ran. >> I think the conclusion was that this wouldn't actually happen in v10, >> but I will take a closer look and do something about it if it is possible. > Even better, thanks. After looking closer, I confirmed that there's no live bug today, though it's a closer shave than one could wish. The RangeVar passed to vacuum_rel and/or analyze_rel can be wrong, or even NULL, but it is only used when autovacuum.c requests failure logging, and for that particular use-case the RangeVar will always be correct. I felt though that I didn't want to just leave it like that, particularly in view of the existence of multiple comments claiming things that were entirely false. So I adjusted those two functions to explicitly allow for NULL RangeVars, and tried to improve the comments. Nathan Bossart wants to see logging of relation-open failures in more cases, and to get that we're going to have to work harder to track valid RangeVars for target relations. But that is not v10 material. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers