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 1kj956-0007o3-8D for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Nov 2020 22:52:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kj953-0001v8-EI for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Nov 2020 22:52:37 +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 1kj953-0001v0-7h for pgsql-hackers@lists.postgresql.org; Sat, 28 Nov 2020 22:52:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kj94z-0008Mi-LP for pgsql-hackers@lists.postgresql.org; Sat, 28 Nov 2020 22:52:36 +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 0ASMqSRN919904; Sat, 28 Nov 2020 17:52:28 -0500 From: Tom Lane To: Andreas Seltenreich cc: pgsql-hackers@lists.postgresql.org Subject: Re: [sqlsmith] Failed assertion during partition pruning In-reply-to: <87sg8tqhsl.fsf@aurora.ydns.eu> References: <87sg8tqhsl.fsf@aurora.ydns.eu> Comments: In-reply-to Andreas Seltenreich message dated "Sat, 28 Nov 2020 22:43:06 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <919902.1606603948.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2020 17:52:28 -0500 Message-ID: <919903.1606603948@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andreas Seltenreich writes: > testing master at 3df51ca8 with sqlsmith triggers the following > assertion: > TRAP: FailedAssertion("!bms_is_empty(present_parts)", File: "partpru= ne.c", Line: 588, PID: 8540) > I looked at a dozen backtraces and they all sport a window aggregate but > that may still be random chance since sqlsmith really likes generating > these a lot... Yeah, it doesn't seem to need a window aggregate: regression=3D# select a from trigger_parted where pg_trigger_depth() <> a = order by a limit 40; server closed the connection unexpectedly What it looks like to me is that the code for setting up run-time partition pruning has failed to consider the possibility of nested partitioning: it's expecting that every partitioned table will have at least one direct child that is a leaf. I'm not sure though whether just the Assert is wrong, or there's more fundamental issues here. It's also somewhat interesting that you need the "order by a limit 40" to get a crash. Poking around in the failing backend, I can see that that causes the leaf-partition subplan to be an indexscan not a seqscan, but it's far from clear why that'd make any difference to the partition pruning logic. regards, tom lane