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 1lUZgK-0007Hd-2n for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 18:47:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUZgI-00019S-Lm for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 18:47:06 +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 1lUZgI-00016f-Es for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 18:47:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUZgG-0007es-B6 for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 18:47:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 138Il1sC1910761; Thu, 8 Apr 2021 14:47:01 -0400 From: Tom Lane To: Alvaro Herrera cc: pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables In-reply-to: <20210408183551.GA16359@alvherre.pgsql> References: <20210408183551.GA16359@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Thu, 08 Apr 2021 14:35:51 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1910759.1617907621.1@sss.pgh.pa.us> Date: Thu, 08 Apr 2021 14:47:01 -0400 Message-ID: <1910760.1617907621@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > On 2021-Apr-08, Tom Lane wrote: >> Yeah. I hit this on another machine that isn't using EXEC_BACKEND, >> and I concur it looks more like a race condition. I think the problem >> is that autovacuum is calling find_all_inheritors() on a relation it >> has no lock on, contrary to that function's API spec. > Hmm. Autovacuum tries hard to avoid grabbing locks on relations until > really needed (at vacuum/analyze time), which is why all these tests > only use data that can be found in the pg_class rows and pgstat entries. Yeah, I was worried about that. > So I tend to think that my initial instinct was the better direction: we > should not be doing any find_all_inheritors() here at all, but instead > rely on pg_class.reltuples to be set for the partitioned table. +1 regards, tom lane