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 1sr7Js-00FUyy-7E for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Sep 2024 02:55:00 +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 1sr7Iq-002Mx6-Is for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Sep 2024 02:53:56 +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 1sr7Iq-002Mwy-AG for pgsql-bugs@lists.postgresql.org; Thu, 19 Sep 2024 02:53:56 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sr7Io-001vLb-4Q for pgsql-bugs@lists.postgresql.org; Thu, 19 Sep 2024 02:53:55 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-7db12af2f31so272754a12.1 for ; Wed, 18 Sep 2024 19:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1726714432; x=1727319232; 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=b90p3boT8qdhjy3RC2weAqb/Vv32KNh0E5gjBbB2YtQ=; b=f9d+S03Nimn4SPo13kqtUjlF3Bf3O8VSdRCyZN/dw5+0ZDfuR1LNeGBiR9ENUaTM/H uTUWg07XGDaSSkW19mHwBVDg2622P9ymm1JkkMVYRlNeEcr4cESREO4RhpbC/jrOlErB dp062cWlU09wkYq0C5CeZrBqYkGu8BUi46WHg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726714432; x=1727319232; 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=b90p3boT8qdhjy3RC2weAqb/Vv32KNh0E5gjBbB2YtQ=; b=Cq/ZPZu16n//9vRX9H2Z0Q8jpnkIkhaFmRT0u0igXIdLwJW4Tj3HwqsIZSkCjEfEvb qlTTdm6L9Y1zO8JvTixYFqJjDgNsgGfHhCR2VdR280DRRuh+9FMhJC53JuLrZnwu67Zm wQI/bfzcS3C1TZognh4VvVF0gd+0Y3+cA3UD4x+RmRYAtVk+47iMjXYmxfQEI9xeAEX4 bSoJBKmPqKQWBoxIYJBbOrHxTA6UY7QbJVI37P6WrQaCbAhOTg2fPsF8kJ0qzOdQQ2Jx pUFaMF1N2P/LsoBTSDUIhelRTqNREkJl4/kCxyZ9wsU2+S3KT8npgnMzFSxqlmAaI93+ FlaQ== X-Forwarded-Encrypted: i=1; AJvYcCVrxTGL8JV3HHXNCTquwNwqmzN+6AYD/0++799GN0TqMvCkMKrqW9hVdMoDIa55KYbiaRG4uun/Qtyf@lists.postgresql.org X-Gm-Message-State: AOJu0YwkyQMB6IpduRR+HgNb5dzZM7VTzzhJwvldjkID1TinXeOl3Ui1 my+ZEt+khc9RgXJhg/8Og2HnjOdWKKLfJFuTk4hYzQmerDRREpr4iT/yUkKVE2tddDfWBSKwMMY = X-Google-Smtp-Source: AGHT+IGlfTfJsG37a+YE5oWnmiYuQzAdKGjV2s8hk8accGYtQ1ARNcT3rfA0kXFpbD0AMze3Vkdn/w== X-Received: by 2002:a05:6a21:114d:b0:1cc:ce91:8459 with SMTP id adf61e73a8af0-1cf75ea2351mr41914838637.5.1726714431816; Wed, 18 Sep 2024 19:53:51 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7db498dd88dsm8176462a12.11.2024.09.18.19.53.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Sep 2024 19:53:50 -0700 (PDT) Date: Wed, 18 Sep 2024 19:53:48 -0700 From: Noah Misch To: Tom Lane , Peter Geoghegan 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: <20240919025348.c5.nmisch@google.com> References: <20240918030159.2a.nmisch@google.com> <1737570.1726633422@sss.pgh.pa.us> <20240918050434.13.nmisch@google.com> <1744648.1726636728@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Wed, Sep 18, 2024 at 01:45:31AM -0400, Tom Lane wrote: > Noah Misch writes: > > What if we just ignored the plancache when uninterruptible? The new planner > > check would then suffice. > > Only if you believe that parallel-query is the only problem, > which is something I seriously doubt. I fear that the > committed patch is just a band-aid over one symptom of the > general problem that we can't permit arbitrary operations > to be invoked from a btree comparison function. It's late > here so I'm not sufficiently awake to think of examples, > but I'm sure there are some. I bet one can cause an (undetected) lwlock deadlock, but I don't know of a way to do that "accidentally". > However ... clearly a maliciously-coded btree support function can > do arbitrarily bad stuff. We restrict creation of opclasses to > superusers for exactly that reason. If our ambitions are only > to prevent support functions from *accidentally* causing problems, > is disabling parallel query enough? I'm still pretty uncomfortable > about it, but it's less obviously insufficient than in the general > case. I'm okay stopping at blocking some known accidents. I'm not aware of an approach that would block 100% of unwanted outcomes here without also removing a feature folks would miss. Nice things about blocking parallel query: - Cheap to block - Always hangs if attempted, so blocking it doesn't take away something of value - Query still completes, without parallelism - Writers of opclass functions probably aren't thinking of parallel query For what it's worth, I tried making standard_ExecutorStart() warn if !INTERRUPTS_CAN_BE_PROCESSED(). Only this thread's new test and 004_verify_nbtree_unique reached the warning. (That's not a surprise.) On Wed, Sep 18, 2024 at 08:59:22AM -0400, Peter Geoghegan wrote: > The test case provided was intended to be illustrative of a problem > that some foreign data wrapper ran into, when it used SPI. Ideally, we'd block those or at least warn under assertions so FDW authors don't accidentally run the executor with an LWLock held. Unlike the opclass case, we so far don't have a valid use case for holding an LWLock there. In other words, if the opclass use case is the only known-valid one, it would be nice to have checks so new use cases don't creep in.