Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxRRe-0006H6-9k for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Sep 2017 05:33:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dxRRd-0007RF-Lh for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Sep 2017 05:33:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dxRQ6-0004hH-2L for pgsql-hackers@postgresql.org; Thu, 28 Sep 2017 05:31:34 +0000 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dxRQ0-0006ZW-N7 for pgsql-hackers@postgresql.org; Thu, 28 Sep 2017 05:31:32 +0000 Received: by mail-pg0-x236.google.com with SMTP id j70so332770pgc.10 for ; Wed, 27 Sep 2017 22:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Z7QquyuEAgjOFfDE7KVGBd0Tu+Zye2dPjqbCsLblKqM=; b=O2TgRSO5u6S0mSES02k2zuu//0U2muG2YmhS2mNXCaEO6bC1naFCeWQx0bNnJXrQHb L+pMIxm5Rht/rcjglYdG2yzheOF1cWyGjWq0TclU5SBWjUHGTe8puYLa4xmU1TOPoZMm KexT78lYvGHKJumExBpTWPDy9t0tl8qPXmps0= 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=Z7QquyuEAgjOFfDE7KVGBd0Tu+Zye2dPjqbCsLblKqM=; b=lchWb28QCYWmyP7kCUhC4z3y7ofpTCrhKyb/llhXjNUDcIXMxtvjw+fG9ruqCrVJdJ cTX0GoAibqGKFq80whnrYBqoQeia/jaO6OmWciqLS7Egt7++I9i1pua9iDIVytvsBh/f ETuDve2XG4yyFTx5djl7ABrtVgJ/zlPZ1tMb1w9xoTBG/k3JZSL88JlbPqY8rBeidM7h iq03XM2U951NL0eI7TXUloAmnmw0j5sO4Qq4B3+mOs2ferLSw6StJoY1x6YRpGRgBkTe Wqx/UoFPJrtk8My+BT9eoE34RTwZJELdXRLQhOOcbKzZJC6e0RVFAkegdx3gW8EwD4Qv HiPg== X-Gm-Message-State: AHPjjUiAgozU+zqILYJMct0AJfNXUp0AO3oGaSop44upgZtGVbwiG3qa JUBxBmRSe0piDbAC6cfxetI1AQ== X-Google-Smtp-Source: AOwi7QD0d12eD5KmO9Lb79MputQu0U3yd55BbB4cTBrtYsbqWKAv0US889ZY7Ap/Xqgbg/PtW/LHQg== X-Received: by 10.99.152.17 with SMTP id q17mr3200836pgd.287.1506576686861; Wed, 27 Sep 2017 22:31:26 -0700 (PDT) Received: from rfd.leadboat.com (c-73-158-248-138.hsd1.ca.comcast.net. [73.158.248.138]) by smtp.gmail.com with ESMTPSA id n83sm1002665pfi.163.2017.09.27.22.31.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Sep 2017 22:31:25 -0700 (PDT) Date: Thu, 28 Sep 2017 05:31:23 +0000 From: Noah Misch To: robertmhaas@gmail.com Cc: pgsql-hackers@postgreSQL.org, Tom Lane Subject: Re: Shaky coding for vacuuming partitioned relations Message-ID: <20170928053123.GD37725@rfd.leadboat.com> References: <25023.1506107590@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25023.1506107590@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) 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 On Fri, Sep 22, 2017 at 03:13:10PM -0400, Tom Lane wrote: > Somebody inserted this into vacuum.c's get_rel_oids(): > > tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); > if (!HeapTupleIsValid(tuple)) > elog(ERROR, "cache lookup failed for relation %u", relid); > > apparently without having read the very verbose comment two lines above, > which points out that we're not taking any lock on the target relation. > So, if that relation is concurrently being dropped, you're likely to > get "cache lookup failed for relation NNNN" rather than anything more > user-friendly. > > A minimum-change fix would be to replace the elog() with an ereport > that produces the same "relation does not exist" error you'd have > gotten from RangeVarGetRelid, had the concurrent DROP TABLE committed > a few microseconds earlier. But that feels like its's band-aiding > around the problem. > > What I'm wondering about is changing the RangeVarGetRelid call to take > ShareUpdateExclusiveLock rather than no lock. That would protect the > syscache lookup, and it would also make the find_all_inheritors call > a lot more meaningful. > > If we're doing a VACUUM, the ShareUpdateExclusiveLock would be dropped > as soon as we close the caller's transaction, and then we'd acquire > the same or stronger lock inside vacuum_rel(). So that seems fine. > If we're doing an ANALYZE, then the lock would continue to be held > and analyze_rel would merely be acquiring it an extra time, so we'd > actually be removing a race-condition failure scenario for ANALYZE. > This would mean a few more cycles in lock management, but since this > only applies to a manual VACUUM or ANALYZE that specifies a table > name, I'm not too concerned about that. > > Thoughts? This thread now has two open items, both of them pertaining to VACUUM error messages involving partitioning. The pair is probably best treated as a single open item. [Action required within three days. This is a generic notification.] The above-described topic is currently a PostgreSQL 10 open item. Robert, since you committed the patch believed to have created it, you own this open item. If some other commit is more relevant or if this does not belong as a v10 open item, please let us know. Otherwise, please observe the policy on open item ownership[1] and send a status update within three calendar days of this message. Include a date for your subsequent status update. Testers may discover new open items at any time, and I want to plan to get them all fixed well in advance of shipping v10. Consequently, I will appreciate your efforts toward speedy resolution. Thanks. [1] https://www.postgresql.org/message-id/20170404140717.GA2675809%40tornado.leadboat.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers