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 1sqmEH-00Ci4A-K1 for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2024 04:23:50 +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 1sqmEG-0037mZ-Ky for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2024 04:23:48 +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 1sqmEG-0037mQ-Bi for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2024 04:23:48 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqmED-001kGf-IM for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2024 04:23:47 +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 48I4NgkR1737571; Wed, 18 Sep 2024 00:23:42 -0400 From: Tom Lane To: Noah Misch cc: Francesco Degrassi , pgsql-bugs@lists.postgresql.org Subject: Re: Leader backend hang on IPC/ParallelFinish when LWLock held at parallel query start In-reply-to: <20240918030159.2a.nmisch@google.com> References: <20240918030159.2a.nmisch@google.com> Comments: In-reply-to Noah Misch message dated "Tue, 17 Sep 2024 20:01:59 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1737569.1726633422.1@sss.pgh.pa.us> Date: Wed, 18 Sep 2024 00:23:42 -0400 Message-ID: <1737570.1726633422@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Noah Misch writes: > On Mon, Sep 16, 2024 at 09:35:13PM +0200, Francesco Degrassi wrote: >> The problem appears to manifest when a backend is holding an LWLock and >> starting a query, and the planner chooses a parallel plan for the >> latter. > Thanks for the detailed report and for the fix. I do not have much faith in this patch. It assumes that the condition "interrupts can be processed" is the same at plan time and execution time. For plans extracted from the plan cache, there seems little reason to assume that must be true. The proposed test case cannot trigger that (today anyway) because SQL-language functions don't deal in cached plans, but I suspect it could be broken with a test case using a plpgsql function instead. I actually think that the problem is somewhere upstream of here: what in the world are we doing invoking planning and execution of arbitrary queries in a context where interrupts are held off? That seems certain to fail in multiple ways besides parallel workers not working. I think we need to fix whatever code believes that that could be OK. And maybe then insert "Assert(INTERRUPTS_CAN_BE_PROCESSED())" at planner start and executor start. regards, tom lane