Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sg5fB-00FF9W-1i for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Aug 2024 16:55:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sg5eA-000Ymn-Om for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Aug 2024 16:54:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sg5eA-000Ymf-F6 for pgsql-hackers@lists.postgresql.org; Mon, 19 Aug 2024 16:54:23 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sg5e7-000Tex-Ja for pgsql-hackers@postgresql.org; Mon, 19 Aug 2024 16:54:22 +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 47JGsErT1386846; Mon, 19 Aug 2024 12:54:14 -0400 From: Tom Lane To: Robert Haas cc: Amit Langote , Alvaro Herrera , Andres Freund , Daniel Gustafsson , David Rowley , PostgreSQL Hackers , Thom Brown Subject: Re: generic plans and "initial" pruning In-reply-to: References: <202406191709.jbvpf7d7hl6g@alvherre.pgsql> Comments: In-reply-to Robert Haas message dated "Mon, 19 Aug 2024 12:39:02 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1386844.1724086454.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 19 Aug 2024 12:54:14 -0400 Message-ID: <1386845.1724086454@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Fri, Aug 16, 2024 at 8:36=E2=80=AFAM Amit Langote wrote: >> So it is possible for the executor to try to run a plan that has >> become invalid since it was created, so... > I'm not sure what the "so what" here is. The fact that there are holes in our protections against that doesn't make it a good idea to walk away from the protections. That path leads to crashes and data corruption and unhappy users. What the examples here are showing is that AcquireExecutorLocks is incomplete because it only provides defenses against DDL initiated by other sessions, not by our own session. We have CheckTableNotInUse but I'm not sure if it could be applied here. We certainly aren't calling that in anywhere near as systematic a way as we have for acquiring locks. Maybe we should rethink the principle that a session's locks never conflict against itself, although I fear that might be a nasty can of worms. Could it work to do CheckTableNotInUse when acquiring an exclusive table lock? I don't doubt that we'd have to fix some code paths, but if the damage isn't extensive then that might offer a more nearly bulletproof approach. regards, tom lane