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 1k3PsX-0001XD-UW for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 20:19:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k3PsW-0007Zv-Pn for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 20:19:12 +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 1k3PsW-0007Zn-J4 for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2020 20:19:12 +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 1k3PsU-0005AJ-8i for pgsql-hackers@postgresql.org; Wed, 05 Aug 2020 20:19:11 +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 075KJ8eU2579007; Wed, 5 Aug 2020 16:19:08 -0400 From: Tom Lane To: Robert Haas cc: Amit Langote , Justin Pryzby , "pgsql-hackers@postgresql.org" Subject: Re: FailedAssertion("pd_idx == pinfo->nparts", File: "execPartition.c", Line: 1689) In-reply-to: References: <20200802181131.GA27754@telsasoft.com> <20200803161133.GA21372@telsasoft.com> <2528807.1596648630@sss.pgh.pa.us> <2550497.1596651719@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 05 Aug 2020 15:59:54 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2579005.1596658748.1@sss.pgh.pa.us> Date: Wed, 05 Aug 2020 16:19:08 -0400 Message-ID: <2579006.1596658748@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Wed, Aug 5, 2020 at 2:22 PM Tom Lane wrote: >> In the longer term, it's annoying that we have no test methodology >> for this other than "manually set a breakpoint here". If we're going >> to allow plan-relevant DDL changes to happen with less than full table >> lock, I think we need to improve that. I spent a little bit of time >> just now trying to build an isolationtester case for this, and failed >> completely. So I wonder if we can create some sort of test module that >> allows capture of a plan tree and then execution of that plan tree later >> (even after relcache inval would normally have forced replanning). >> Obviously that could not be a normal SQL-accessible feature, because >> some types of invals would make the plan completely wrong, but for >> testing purposes it'd be mighty helpful to check that a stale plan >> still works. > That's an interesting idea. I don't know exactly how it would work, > but I agree that it would allow useful testing that we can't do today. After thinking about it for a little bit, I'm envisioning a test module that can be loaded into a session, and then it gets into the planner_hook, and what it does is after each planner execution, take and release an advisory lock with some selectable ID. Then we can construct isolationtester specs that do something like session 1 session 2 LOAD test-module; SET custom_guc_for_lock_id = n; prepare test tables; SELECT pg_advisory_lock(n); SELECT victim-query-here; ... after planning, query blocks on lock perform DDL changes; SELECT pg_advisory_unlock(n); ... query executes with now-stale plan regards, tom lane