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 1sqkxH-00CWcC-O3 for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2024 03:02:12 +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 1sqkxH-002FtW-7c for pgsql-bugs@arkaria.postgresql.org; Wed, 18 Sep 2024 03:02:11 +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 1sqkxG-002FtO-O4 for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2024 03:02:10 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sqkx8-001kMP-IB for pgsql-bugs@lists.postgresql.org; Wed, 18 Sep 2024 03:02:09 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-71790ed8c2dso5719825b3a.3 for ; Tue, 17 Sep 2024 20:02:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1726628522; x=1727233322; 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=fD45A2to7ymMlvMK7vVcB3AVDTa9tn1/0TxF9D3s2w4=; b=ZkeoViVH1s846tKY1iO6ufoxbAK+Ptamxb9OCfJmhQ9EMkIuCiNw+M3xRidpxFsytL bhAQW0mvrewrUq3ntobDr8VnZCfM1GlW8XunykyEYxha/OVqVWo6qyvbxfXUGcHPnj0J NvoXhR6C0GYAdpo7b/b32lohj0o7sJf/YcWGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726628522; x=1727233322; 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=fD45A2to7ymMlvMK7vVcB3AVDTa9tn1/0TxF9D3s2w4=; b=UYRD7JRfomjGqIZbLsCnh3zEfb1DC40vdtqAryUrtFItZQ+r7sPAw6cjexcOnMTNtH 7bjq0nhSjJQUJDR7Ro4ePwNdC5c6iGzCg9qW0akYYT70lT+MzpiKAVBG3q9aQYqtgblm kRgijrZDfw2Uf2a3rvOiAUZQ2c5MWLVAhEowSgV47o6or+Wez7LBpoXU+4jwIcvulEYr 06JZ/Ve8UeuAVJzE9+NWwfAXcdAYVL6LuYVqTm5nUchT1pA+P6t9nhpvwXSQNx5LS3Ec u3bzFzuZ09cOROsoSlwCj7y3pZ6xiVaSCrebkOzzvG8YmbEzSr1u3DBK4mqg9ocEz+/y bUUw== X-Gm-Message-State: AOJu0Ywt201kKoNpfR3MtZugd6shQMxAfcKXaNOYsCkdvP/USGEoa6uP TYNEUUVj81LN+1gPE8sSshSDjx3l5AH6blB+/QLkikZHbUa0WvguwIgtPw4aOBKrXFNbVYNLU8g = X-Google-Smtp-Source: AGHT+IGsG/AtwY7A3dd9lL75AFmChcf21IiS6TlavM1GZLOd9HvnW4O7n3SpRELVPlpqw1bc0Iy3WA== X-Received: by 2002:a05:6a00:8c4:b0:714:2069:d90e with SMTP id d2e1a72fcca58-71926211087mr28327447b3a.26.1726628521749; Tue, 17 Sep 2024 20:02:01 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-719858156f9sm198763b3a.76.2024.09.17.20.02.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Sep 2024 20:02:01 -0700 (PDT) Date: Tue, 17 Sep 2024 20:01:59 -0700 From: Noah Misch To: Francesco Degrassi Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Leader backend hang on IPC/ParallelFinish when LWLock held at parallel query start Message-ID: <20240918030159.2a.nmisch@google.com> References: 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 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. > Potential fixes > --------------- > > As an experiment, we modified the planner code to consider the state of > `InterruptHoldoffCount` when determining the value of > `glob->parallelOK`: if `InterruptHoldoffCount` > 0, then `parallelOK` > is set to false. > > This ensures a sequential plan is executed if interrupts are being held > on the leader backend, and the query completes normally. > > The patch is attached as `no_parallel_on_interrupts_held.patch`. Looks good. An alternative would be something like the leader periodically waking up to call HandleParallelMessages() outside of ProcessInterrupts(). I like your patch better, though. Parallel query is a lot of infrastructure to be running while immune to statement_timeout, pg_cancel_backend(), etc. I opted to check INTERRUPTS_CAN_BE_PROCESSED(), since QueryCancelHoldoffCount!=0 doesn't cause the hang but still qualifies as a good reason to stay out of parallel query. Pushed that way: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=ac04aa8 > Related issues > ============== > > - Query stuck with wait event IPC / ParallelFinish > - > https://www.postgresql.org/message-id/0f64b4c7fc200890f2055ce4d6650e9c2191fac2.camel\@j-davis.com This one didn't reproduce for me. Like your test, it involves custom code running inside an opclass. I'm comfortable assuming it's the same problem. > - BUG \#18586: Process (and transaction) is stuck in IPC when the DB > is under high load > - > https://www.postgresql.org/message-id/flat/18586-03e1535b1b34db81%40postgresql.org Here, I'm not seeing enough detail to judge if it's the same. That's okay.