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 1sriYa-003ypo-LW for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Sep 2024 18:40:41 +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 1sriXa-00BkhK-6V for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Sep 2024 18:39:39 +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 1sriXZ-00Bkh5-Su for pgsql-hackers@lists.postgresql.org; Fri, 20 Sep 2024 18:39:39 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sriXW-000EO4-Tv for pgsql-hackers@postgresql.org; Fri, 20 Sep 2024 18:39:38 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-7d7a9200947so1537397a12.3 for ; Fri, 20 Sep 2024 11:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1726857574; x=1727462374; darn=postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xBvtCRit1VjgYevCppgFg3jofY5u+5gCknchhnPh4Ig=; b=eBGRtPXaRsJ62r1weBdaKYI52sqGNhahuqfBvj8ul14yVMLTDxT9qLAjZdHnlwCM8j V3J+2HRj9ROblTrFt7uQ0+ERweeDxrxm/VKJA/Z8+QyKl0ASFTjs2uGFOoeNO+f1UVrX HVTKj5B5pIfQTdoQg/n7VcrY3/gypzdqiPfzw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726857574; x=1727462374; h=user-agent:in-reply-to:content-transfer-encoding :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=xBvtCRit1VjgYevCppgFg3jofY5u+5gCknchhnPh4Ig=; b=owyrM6Zhj0ImgZ6aIYYaqUfx+ITSVIoIOhAq0Vgy8JSgvNdnzTcKWNjLlus6DhmSPY VDqR+EIrtS2G3MvOdxG6jsX3pcfkWvv15SHhOiCDhNw8dmyMXaukqJdsDexhLepWynx9 KuSCxrwUgK++JzaMtKBruF/1a1frWEGnsQI0dFSU08wmyKbdwMqLsxS5Uz/khNSuVFd8 18m6mRWZZ19Gtl1BhDLFpboSwSE7UGtIc0TkU7+YQjTwmxACmdEaw1K8ak/Mj+1zQgyO Io1R2EkVng1PNHBdbNViIvYdbcBpVsvUT7UUUleTYGEo7u9k9CpmuBOtU5cw9wduOyMj 1c7Q== X-Forwarded-Encrypted: i=1; AJvYcCXGY4MDc+qxcIvtJimGw1GBuBmm638f5nC/wptPbZoLHgKJBtVVqKsr1q/bJWL7vbGRZZGBKqmEdq7Dydgo@postgresql.org X-Gm-Message-State: AOJu0YxCIogMdwq52jd6jDH41LiGxYAFqTQlRqP2uNCYqZQbs0FoRv32 eXncBx4yGbk56LGorglMpX+QavBm86oiVXlplbavTPxSTvyWHTbF0T8ldxHCUQ== X-Google-Smtp-Source: AGHT+IGDLht0kw7yeHy5I13tAOHpfY11YloFQMwgbrh4Ts7TbZg+8BM9uXiFA4x/2dK0nj3Kqhj72A== X-Received: by 2002:a05:6a20:918c:b0:1d3:aff:210e with SMTP id adf61e73a8af0-1d30aff2199mr6421078637.0.1726857573826; Fri, 20 Sep 2024 11:39:33 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db499942besm11103946a12.63.2024.09.20.11.39.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Sep 2024 11:39:33 -0700 (PDT) Date: Fri, 20 Sep 2024 11:39:31 -0700 From: Noah Misch To: Robert Haas Cc: Laurenz Albe , "pgsql-hackers@postgresql.org" Subject: Re: pgsql: Don't enter parallel mode when holding interrupts. Message-ID: <20240920183931.f0.nmisch@google.com> References: <57d244a6a2558b8bed0f0297761e998ff66d5a26.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Thu, Sep 19, 2024 at 09:25:05AM -0400, Robert Haas wrote: > On Wed, Sep 18, 2024 at 3:27 AM Laurenz Albe wrote: > > On Wed, 2024-09-18 at 02:58 +0000, Noah Misch wrote: > > > Don't enter parallel mode when holding interrupts. > > > > > > Doing so caused the leader to hang in wait_event=ParallelFinish, which > > > required an immediate shutdown to resolve. Back-patch to v12 (all > > > supported versions). > > > > > > Francesco Degrassi > > > > > > Discussion: https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com > > > > Does that warrant mention on this page? > > https://www.postgresql.org/docs/current/when-can-parallel-query-be-used.html > > IMHO, no. This seems too low-level and too odd to mention. Agreed. If I were documenting it, I would document it with the material for writing opclasses. It's probably too esoteric to document even there. > TBH, I'm kind of surprised to learn that it's possible to start > executing a query while holding an LWLock. I see Tom is expressing > some doubts on the original thread, too. I wonder if we should instead > be erroring out if an LWLock is held at the start of query execution > -- or even earlier, like when we try to call a plpgsql function while > holding one. Leaving parallel query aside, what would prevent us from > attempting to reacquire the exact same LWLock that we already hold and > self-deadlocking? Or attempting to acquire some other LWLock and > deadlocking that way? I don't really feel like this is a parallel > query problem. I don't think we should be trying to run any > user-defined code while holding an LWLock, unless that code is written > in C (or C++, Rust, etc.). Trying to run procedural code at that point > doesn't seem reasonable. Nothing prevents those lwlock deadlocks. If you think it's worth breaking the things folks use today (see original thread) in order to prevent that, please do share that on the original thread. I'm fine either way. I think given infinite resources across both postgresql.org and all extension maintainers, I would do what you're thinking in v18 while in back branches, I would change "erroring out" to "warn when assertions are enabled". I also think it's a low-priority bug, given the only known ways to reach it are C code or a custom opclass. Since resources aren't infinite, I'm inclined toward one of (a) stop here or (b) all branches "warn when assertions are enabled" and maybe block the plancache route discussed on the original thread.