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 1sqmrv-00CnkN-UO for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2024 05:04:48 +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 1sqmrv-003bBv-3P for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2024 05:04:47 +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 1sqmru-003b9q-KH for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2024 05:04:46 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sqmrr-001kW8-BT for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2024 05:04:45 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2d8a54f1250so4368976a91.0 for ; Tue, 17 Sep 2024 22:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1726635882; x=1727240682; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=I9lUxeYn6nx6Jbt7OcLGqIA7xpShANVGW2dkw1pjKm8=; b=VYr4c17Y9duQzBCRJnz+5P4UKnjR+1CDDCbBFPoDJa+m4iGaRJQUSaaiZaKMBdEmx2 WLOcVaJGPnw/dBtirGNBnthkE/v25zfqzZAyOmbLAg/oPV06WIa1d6gng88/YC0krqSF qE0l0Qd/sxqeB8YMDiA5cnBdpI0UK1nrcXk5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726635882; x=1727240682; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I9lUxeYn6nx6Jbt7OcLGqIA7xpShANVGW2dkw1pjKm8=; b=cTB1cLPA3mKYTJDks+GMq8/hPsDUidyZhHIQJ0YsDV26GSJTpp67mYAaaEGVnuOP75 HSIWS0yA4OpFaf8uD8rnN2G8u7twSXl0zEUhoLdBb5RWAUgyrWfK4KjYalSyHdQXqhOD 6mlQBru74XAJQk5sCTQv4PzQistUchv3cfE3r3U2iRnmja/JK05ssS/JSsqyLcVwWTaH 9Rq+85V1jyq+nqqlKnO7nN+1tvfdaDloco/eWWhrBL9F3GiJm94pDUZr1z1TZCiJXGte gKWNlfcYxnSbA7WSwPB+OALeD5gL4j1kKhS8By415CyLZMW2dvu4iTtT4feWmaRGJ78s 2obw== X-Forwarded-Encrypted: i=1; AJvYcCUhy8+ZDGvWXgFMnahWJFYmWzHCuA+vsa6VJgV/46l3dmumbgnTZeRhv98ZSEzl+lxdr0LruDaQIIud@lists.postgresql.org X-Gm-Message-State: AOJu0YwZEmJ8l+7oSuWpCPKqDbxHgcAXVypKIE0S0VROT5rX0EMSO3Wt HmhKWPgmSl9XhMZ4KhWUkiRK3fcuPwXD97OvNsJV0lvVHMlT0I0FIF+LMC4c3Q== X-Google-Smtp-Source: AGHT+IEjDBok5Ygh4vq7mtMZm361rNZykgvWFjaSwH3HMbhKWGPLq9asx7w6unhgxHtzyMe/xsfwhg== X-Received: by 2002:a17:90b:4a43:b0:2c9:a3ca:cc98 with SMTP id 98e67ed59e1d1-2db9ffaf481mr24708084a91.7.1726635882433; Tue, 17 Sep 2024 22:04:42 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd608589f5sm468456a91.3.2024.09.17.22.04.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Sep 2024 22:04:41 -0700 (PDT) Date: Tue, 17 Sep 2024 22:04:34 -0700 From: Noah Misch To: Tom Lane Cc: Francesco Degrassi , pgsql-bugs@lists.postgresql.org Subject: Re: Leader backend hang on IPC/ParallelFinish when LWLock held at parallel query start Message-ID: <20240918050434.13.nmisch@google.com> References: <20240918030159.2a.nmisch@google.com> <1737570.1726633422@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1737570.1726633422@sss.pgh.pa.us> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Sep 18, 2024 at 12:23:42AM -0400, Tom Lane wrote: > 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. Good point. I missed that. > 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. It would be nice to never run planning or execution with interrupts held. The concrete examples so far involve btree operator classes with non-C support functions. How practical would it be to release buffer content locks before running index support functions? An alternative would be blocking non-C support functions (and instructing C support function authors to not use planner/executor). Non-C support functions have been handy for testing if nothing else, though. Do non-bundled modules rely on non-C support functions? Thanks, nm