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 1sg5Pe-00FDEY-6P for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Aug 2024 16:39:22 +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 1sg5Pb-000RWW-KM for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Aug 2024 16:39:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sg5Pb-000RWN-8y for pgsql-hackers@lists.postgresql.org; Mon, 19 Aug 2024 16:39:19 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sg5PZ-000R2E-52 for pgsql-hackers@postgresql.org; Mon, 19 Aug 2024 16:39:18 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a7b2dbd81e3so627830966b.1 for ; Mon, 19 Aug 2024 09:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724085555; x=1724690355; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OKhoOo30U4PBjBb5D7F9AyxMx5g0pmzO2jRPCzc0Bas=; b=lvchF2fol8FNxUfmn17QYNWSf2p+/k4lbd8FUqd85pAKvFcGJwUDfHDNFCaL1U+bp5 GVRFsRMFVe9aticQxyDx9K1wZEMDw1nGDGJ8jHUH87Csq9N5IE9Ev2LwV3cNbCiR55S4 DABzANiybiMJKrtGwFwv9uTrnKX3A1vv1IUWweArwHYdWI0/HlkeHIuT9uOHmkyz3yWM lt9zGskoPRe2udojjI239NacEM1VxdB3yQhxo3R+e3GNBUCrPT4rdJsYv1hhNsPx9M0o /JeMhznOZuQO04o+B3EPs2XQ0R7yHZQ+JZtu4eh6ErPGnB89g14tFCv4lUgkLSAGrEcx nAJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724085555; x=1724690355; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OKhoOo30U4PBjBb5D7F9AyxMx5g0pmzO2jRPCzc0Bas=; b=A9U4XZ9GqiSXQU4lOp3k8zCnZYAoLubjV11vjMRFBDc+t4cZkdM1QSpNtEi6+4Qsoi 9XAdMDN+o+ypeHIIwzZiMQ+hPC05yZsA4pZV9xKTuRn+DV8OYWxJ6P1xLdeWaEvfMsRm vZ8d8e8EbshaqmmlzBELIrfuk3j8uk9vgAHC7vbUc3zlrXimoFsBEcZzJcYl7dQzt58t WjobVku7TmiSh2G70WZtJ2DIxd3vedT38Zm2IAthmar4dVfyOkyrROXW9sAPSKcKGFw6 Kht1L0YAqkXUxPT0FjpaL6g+VUlZfXmtPFKVElLqEBO3TyHygOLEPSA1WeHHWNcuBFn0 RR+w== X-Forwarded-Encrypted: i=1; AJvYcCWq9cSJNYweSRNtH9VMobJ6P3ycuOIHMj/b5kb+4b7F8AkOS1lNy4016JwJOTXB8YFNT5IBBlGyWIFlYfWnJzkt8lLPwQkod26mRAtz X-Gm-Message-State: AOJu0YzFRADm2/yVhBFsJw4V/aEJebmwzYgvqLGq6dtKYEP24LbnHNt5 UPI7CwC9gl6LfuzfuulRf/WApfeFoJ90xnavRx5sLy9/HJVHurdWXTD/yZnYKYwpJddC8YCMV0i IpiiExEDbUl9q2AgD+UxPF1pO1mU= X-Google-Smtp-Source: AGHT+IFHFzZnbBk9EbEpUeEpGP4D1iVOjlwLxJslKipY6zBLHO6UayXV5D8crAhqoO7LCZHGuht1Ri0wDO6Y6e0yOdU= X-Received: by 2002:a17:907:7d9f:b0:a80:f6a9:c311 with SMTP id a640c23a62f3a-a839256bc37mr822594266b.0.1724085554064; Mon, 19 Aug 2024 09:39:14 -0700 (PDT) MIME-Version: 1.0 References: <202406191709.jbvpf7d7hl6g@alvherre.pgsql> In-Reply-To: From: Robert Haas Date: Mon, 19 Aug 2024 12:39:02 -0400 Message-ID: Subject: Re: generic plans and "initial" pruning To: Amit Langote Cc: Alvaro Herrera , Andres Freund , Daniel Gustafsson , David Rowley , PostgreSQL Hackers , Thom Brown , Tom Lane Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. > One perhaps crazy idea [1]: > > What if we remove AcquireExecutorLocks() and move the responsibility > of taking the remaining necessary locks into the executor (those on > any inheritance children that are added during planning and thus not > accounted for by AcquirePlannerLocks()), like the patch already does, > but don't make it also check if the plan has become invalid, which it > can't do anyway unless it's from a CachedPlan. That means we instead > let the executor throw any errors that occur when trying to either > initialize the plan because of the changes that have occurred to the > objects referenced in the plan, like what is happening in the above > example. If that case is going to be rare anway, why spend energy on > checking the validity and replan, especially if that's not an easy > thing to do as we're finding out. In the above example, we could say > that it's a user error to create a rule like that, so it should not > happen in practice, but when it does, the executor seems to deal with > it correctly by refusing to execute a broken plan . Perhaps it's more > worthwhile to make the executor behave correctly in face of plan > invalidation than teach the rest of the system to deal with the > executor throwing its hands up when it runs into an invalid plan? > Again, I think this may be a crazy line of thinking but just wanted to > get it out there. I don't know whether this is crazy or not. I think there are two issues. One, the set of checks that we have right now might not be complete, and we might just not have realized that because it happens infrequently enough that we haven't found all the bugs. If that's so, then a change like this could be a good thing, because it might force us to fix stuff we should be fixing anyway. I have a feeling that some of the checks you hit there were added as bug fixes long after the code was written originally, so my confidence that we don't have more bugs isn't especially high. And two, it matters a lot how frequent the errors will be in practice. I think we normally try to replan rather than let a stale plan be used because we want to not fail, because users don't like failure. If the design you propose here would make failures more (or less) frequent, then that's a problem (or awesome). --=20 Robert Haas EDB: http://www.enterprisedb.com