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 1t9YXI-00Au1N-Hv for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Nov 2024 23:37:03 +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 1t9YXE-00EXEE-E3 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Nov 2024 23:37:01 +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 1t9YXE-00EXE6-5u for pgsql-bugs@lists.postgresql.org; Fri, 08 Nov 2024 23:37:00 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t9YX6-000vZ4-Fd for pgsql-bugs@lists.postgresql.org; Fri, 08 Nov 2024 23:36:59 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-720d5ada03cso2739769b3a.1 for ; Fri, 08 Nov 2024 15:36:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1731109012; x=1731713812; 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=8XhfLOP0l7DnFZkEtSDOsWh+KFPX3FxZMRFIYrOu8QA=; b=AnkWvbFKshiXfxXPiVikN61P7G5/Nq1fetfAOoEnwsXeH+IaxvNlo7MjrEiLej1FOp eO8GIM7fVhzDsUGw9j2H/eyMSZbBgqvE5yS1T6ZKQeG0ntDLDugw0a7QZ8DHdOSwfw7Z axUrpwfmyhJNSEW3ugUbYB0vHtGFOZmSqF7ho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731109012; x=1731713812; 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=8XhfLOP0l7DnFZkEtSDOsWh+KFPX3FxZMRFIYrOu8QA=; b=AoQPSfKH+bepyyfYzwSDbxcn19iba11jdn3gZz5mgiLoQ0r0rQ0YATHd82HZ7vn/wK pdVmJcgEW7YJZxzFFcO5INxrUlUiycrmpSY7LOV64KF+n0YBUa0agPc5G9yGTlIjfQxc UBBlCIO4qMHB0n96ik+tY9vnaXuMh+ctzs/a6ARCqltm/ed5BuzcHJfayQP8C8hZtfGm G9JZWyfAjK9+EPrrUP8skHojqBaMMJh8FdaW9AfDgSGAj6UitcTL/eozG/98biMDqL+S q6b3ZyKKzoNSd0ZPFoYWcAWZF6ghqJAAuadQs1dUpPbMEwlPz1TvSyebdZEuKOyzDEj1 Acxw== X-Forwarded-Encrypted: i=1; AJvYcCUmyVnR+OssWyQX0wJaclFVVylZ+fiG9qjBCXjkryaFRQY4wajkZ68ji/abdGWvAdPPKDIPsIZ2MZ39@lists.postgresql.org X-Gm-Message-State: AOJu0YwflBlp/65RJP4ZgD0RJFBjNqAFhXXNePu0M/3r3//UDeLUKVJA NFrtep3iQgHli5QSlGCNBT1nlCq2P0vIDHLnqIlvc2RYS1rjCL8tBsMwc7hk+c5RPNUEcbZ1/tw = X-Google-Smtp-Source: AGHT+IGs4Ki8w4JUl1JRJZ6q1he2/n6s7N/zcm2rTBx2upMfI0tM68W17VzawKpHQmwAjzdlkSxTWw== X-Received: by 2002:a05:6a00:84c:b0:71e:3b8:666b with SMTP id d2e1a72fcca58-724132c0dd7mr6148548b3a.15.1731109011641; Fri, 08 Nov 2024 15:36:51 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72407863dd8sm4508497b3a.26.2024.11.08.15.36.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Nov 2024 15:36:51 -0800 (PST) Date: Fri, 8 Nov 2024 15:36:49 -0800 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: <20241108233649.01.nmisch@google.com> References: <20240918030159.2a.nmisch@google.com> <1737570.1726633422@sss.pgh.pa.us> <20240918050434.13.nmisch@google.com> <3441950.1730999841@sss.pgh.pa.us> <20241107192233.94.nmisch@google.com> <3459938.1731007759@sss.pgh.pa.us> <20241107193823.dc.nmisch@google.com> <3694355.1731084396@sss.pgh.pa.us> <3793541.1731088615@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3793541.1731088615@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 Fri, Nov 08, 2024 at 12:56:55PM -0500, Tom Lane wrote: > I wrote: > > Here's a proposed patch along that line. I left the test case from > > ac04aa84a alone, since it works perfectly well to test this way too. > > I'd modeled that on the existing recovery code for DSM segment creation > failure, just below. But a look at the code coverage report shows > (unsurprisingly) that that path is never exercised in our regression > tests, so I wondered if it actually works ... and it doesn't work > very well. To test, I lobotomized InitializeParallelDSM to always > force pcxt->nworkers = 0. That results in a bunch of unsurprising > regression test diffs, plus a couple of > > +ERROR: could not find key 4 in shm TOC at 0x229f138 > > which turns out to be the fault of ExecHashJoinReInitializeDSM: > it's not accounting for the possibility that we didn't really > start a parallel hash join. > > I'm also not happy about ReinitializeParallelWorkers' > > Assert(pcxt->nworkers >= nworkers_to_launch); > > The one existing caller manages not to trigger that because it's > careful to reduce its request based on pcxt->nworkers, but it > doesn't seem to me that callers should be expected to have to. > > So I end with the attached. There might still be some more issues > that the regression tests don't reach, but I think this is the > best we can do for today. Looks good.