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 1lUWRe-00089p-9j for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 15:19:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lUWRd-0000a9-6j for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Apr 2021 15:19:45 +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 1lUWRc-0000a2-W7 for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 15:19:44 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lUWRa-0006jM-Bp for pgsql-hackers@lists.postgresql.org; Thu, 08 Apr 2021 15:19:44 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 71BE95C0126; Thu, 8 Apr 2021 11:19:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 08 Apr 2021 11:19:40 -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=MhGhyeO0dkLwSONNGRB48tEiem9HBCFJ29Zr72mW4GQ=; b=smHS1iyd vqooUSrGnjhQPyL0j2t8WIn8yYU2g5uZmlP5JpWw5o39aZiDfLZFBdd47jVUwjXg GIg3mm0kYe1mkZFqXrJJGJkwPdwE60sV0HiyaDv4lV9Gz9RJAFnYVwyMuTf2AhXD GiAPVGL/lxgTIoQGlytZV7fY38a1VCspPlUgVo/cL5miBJQGvqWLf70T4z8W3sHq UuPTY+Vrn4kmZ8dYNpRAFymQTulE5s+fRWnogTgDLFqdv13DJqrNIVXAEi50iA15 l+syzk06X9hOYht5gLh/+A2XYz7F2fU/1ypgxt78fjMXjd3Sd3kcwxjNXxXYhkBO fKOZbWAo8uGTAg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejledgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugfgjggfsehmke erredtredunecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeeggfdtvdfhie fhudekuefgheefgeejffeiuedulefggeehteejteduteehkeffieenucffohhmrghinhep phhoshhtghhrvghsqhhlrdhorhhgpdhpghhsqhhlrdgsuhhilhgunecukfhppeduledtrd elhedrudelrdelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id E78071080063; Thu, 8 Apr 2021 11:19:39 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4EADD2A0FC3; Thu, 8 Apr 2021 11:19:37 -0400 (-04) Date: Thu, 8 Apr 2021 11:19:37 -0400 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables Message-ID: <20210408151937.GA1712@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1823909.1617862590@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 --J/dobhs11T7y2rNN Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2021-Apr-08, Tom Lane wrote: > Alvaro Herrera writes: > > autovacuum: handle analyze for partitioned tables > > Looks like this has issues under EXEC_BACKEND: > > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=culicidae&dt=2021-04-08%2005%3A50%3A08 Hmm, I couldn't reproduce this under EXEC_BACKEND or otherwise, but I think this is unrelated to that, but rather a race condition. The backtrace saved by buildfarm is: Program terminated with signal SIGSEGV, Segmentation fault. #0 relation_needs_vacanalyze (relid=relid@entry=43057, relopts=relopts@entry=0x0, classForm=classForm@entry=0x7e000501eef0, tabentry=0x5611ec71b030, effective_multixact_freeze_max_age=effective_multixact_freeze_max_age@entry=400000000, dovacuum=dovacuum@entry=0x7ffd78cc4ee0, doanalyze=0x7ffd78cc4ee1, wraparound=0x7ffd78cc4ee2) at /mnt/resource/andres/bf/culicidae/HEAD/pgsql.build/../pgsql/src/backend/postmaster/autovacuum.c:3237 3237 childclass = (Form_pg_class) GETSTRUCT(childtuple); #0 relation_needs_vacanalyze (relid=relid@entry=43057, relopts=relopts@entry=0x0, classForm=classForm@entry=0x7e000501eef0, tabentry=0x5611ec71b030, effective_multixact_freeze_max_age=effective_multixact_freeze_max_age@entry=400000000, dovacuum=dovacuum@entry=0x7ffd78cc4ee0, doanalyze=0x7ffd78cc4ee1, wraparound=0x7ffd78cc4ee2) at /mnt/resource/andres/bf/culicidae/HEAD/pgsql.build/../pgsql/src/backend/postmaster/autovacuum.c:3237 #1 0x00005611eb09fc91 in do_autovacuum () at /mnt/resource/andres/bf/culicidae/HEAD/pgsql.build/../pgsql/src/backend/postmaster/autovacuum.c:2168 #2 0x00005611eb0a0f8b in AutoVacWorkerMain (argc=argc@entry=1, argv=argv@entry=0x5611ec61f1e0) at /mnt/resource/andres/bf/culicidae/HEAD/pgsql.build/../pgsql/src/backend/postmaster/autovacuum.c:1715 the code in question is: children = find_all_inheritors(relid, AccessShareLock, NULL); foreach(lc, children) { Oid childOID = lfirst_oid(lc); HeapTuple childtuple; Form_pg_class childclass; childtuple = SearchSysCache1(RELOID, ObjectIdGetDatum(childOID)); childclass = (Form_pg_class) GETSTRUCT(childtuple); Evidently SearchSysCache must be returning NULL, but how come that happens, when we have acquired lock on the rel during find_all_inheritors? I would suggest that we do not take lock here at all, and just skip the rel if SearchSysCache returns empty, as in the attached. Still, I am baffled about this crash. -- Álvaro Herrera Valdivia, Chile "Oh, great altar of passive entertainment, bestow upon me thy discordant images at such speed as to render linear thought impossible" (Calvin a la TV) --J/dobhs11T7y2rNN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-race-condition-in-relation_needs_vacanalyze.patch"