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 1lUZW6-0006yi-NB for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 18:36:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUZVX-0002Z6-Li for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 18:35:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUZVX-0002Yz-3W for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 18:35:59 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUZVU-0008LX-3X for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 18:35:58 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 36D515C00D3; Thu, 8 Apr 2021 14:35:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 08 Apr 2021 14:35:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=w67uaIkr4x7TOiwXV499m1taRPk3CmVLoXfwyX8NzUU=; b=D0Wsq1Z9 raTOq9FSIXb36oG8DJflH8Xx/6Ob4RFPoq0RIOADo05idQc+CrENSl5wM8rbWwuG Kj/3bEREFiM0GaTFXUooosKOorbXyCrWx9b4BtqD/deq/zMGFOlX8ULKAsdHWVMD gcLvJqVVG7XfNlTGlKNN0VTeumXnF6/VNVCf83VMOo0NGkRXLjmhFHXtEYFZr4mi VG/5IPoC3ymj7nSWaeM/b1YNm4Zb4egLWksMzIQbp/Uv+y+spjX5e9Gj3uzlM9Sd cq355ZFI2+4pbv6f4kIcxGJMXbVVGejIwopdmz2FHxz72TCHWr+6wARN7a7mQzwh vdIz88AevEEbOA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejledguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggugfgjfgesth ekredttderudenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghr rhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepueffhfejie euueffgedvudekgeeltdeviedvieeufeeiieevgfetheeufeethedvnecukfhppeduledt rdelhedrudelrdelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 67EC2240054; Thu, 8 Apr 2021 14:35:53 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 23B1A2A062E; Thu, 8 Apr 2021 14:35:51 -0400 (-04) Date: Thu, 8 Apr 2021 14:35:51 -0400 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables Message-ID: <20210408183551.GA16359@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1901125.1617904665@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. find_all_inheritors > assumes the OID it's given is valid and locked, and adds it to the > result list automatically. Then it looks for children, and won't find > any in the race case where somebody else just dropped the table. 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. 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. I'll give that another look. Most places already assume that reltuples isn't set for a partitioned table, so they shouldn't care. I wonder, though, whether we should set relpages to some value other than 0 or -1. (I'm inclined not to, since autovacuum does not use it.) -- Álvaro Herrera Valdivia, Chile