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.96) (envelope-from ) id 1wmLmB-000jiR-1p for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jul 2026 01:29:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wmLm8-009azF-3A for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jul 2026 01:29:32 +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.96) (envelope-from ) id 1wmLm8-009az7-1u for pgsql-hackers@lists.postgresql.org; Wed, 22 Jul 2026 01:29:32 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wmLm5-00000001LbO-0kcX for pgsql-hackers@lists.postgresql.org; Wed, 22 Jul 2026 01:29:31 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8E73914000DB; Tue, 21 Jul 2026 21:29:28 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 21 Jul 2026 21:29:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1784683768; x=1784770168; bh=ldQxLmsIdq A1kofqiYglxC8k23BbD0TROIQ6B3k6o6Q=; b=CS/IoC6rbV3VW0UsL2OslRz48j M78QbsCcKy1tD8N/E7l2xLzWL2M8kt3mSa96SMpZejakAA13HFJai3GmkPCwYas8 fVeWy+3Mw281McZLpUP5U/A/n0mmszX7UeTwsO1tkvugUMSp1usi97+b4xHDTm73 ++PgLrdtf4NLc1gST0RPZ2/kWWiwxekCtzeQvy5AQAJ0ZV8fhm6ySwfrA/YVtUR5 h3byeOGIrXv12mFAhZLHksUHGmP1UysPXX5A3nbYfcTGTLMjWqbR3F7fScHdcK1G riTQzd7BPK3ErYv97LsXp94PshKbGc7BGQmLz5vusWEekEf+VjK2ERJPa5qw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1784683768; x=1784770168; bh=ldQxLmsIdqA1kofqiYglxC8k23BbD0TROIQ 6B3k6o6Q=; b=O8Z7a0Kw+a21/EbCHe3sB06+xW2HFRNqWy4sjkreKMDLB4RSgZx etxaBWdMNup8HIpzt1ba4kwbCHXDCrA2ogcJgIpi7cLbOr1RjY3qcG++oVefgnfK Xz+46fu526fIuptSOLljmmqvZ58DyZZ/azt6iBTWHes/zDEYjohYtHfXdvyeBQ49 LqnEaAbjRzDQk4j3S59PAR6P+MLSDteV3x3y2kQgZIMu50h67MoviMzyGbt2r2ZL qKa0XlYS9P9WVf/YoVCUlVO3sIkUHGEiZt22lMLG3NOLAyyz6GcYxSBjWB8TWz5s WGd516TBgJOijXQRo3MlE3eIXyjI9S/zAnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFN5XHAN2D0cqxIcU5GgxVBA0kPc3qIrk0DrQOX6tx1ZGiNn6fNtihhn3SdmExRvn Upp6O8J0VXVFEmRmmlyNqBPQq1Bajr0b0fk6axg2lerupfSctW39SEhQX0DWzLIDuXyTF0 Xxpe5jzGS4j5o1YFqDL73Ars/3rV1LUn6e5HfvsicwaKafB2JDSZWGxpnwx3gfOsakLzrv UpJsaoyY51pqO0sWLQ6zl7tQtW3Ptc1hCysMh2+nZUiHpu+KkAL27IfpdfnBTIZblg/QfA IuirA/V0R6fbDr9Il/YVIrFN7LYDtA3grDFFQs11mbqmaiL+5r8XsBGuFABiuYM7tIXtDU K9o065oLkGD8zK7tfX28QP4MKcrLapWoFOOtnr+tq4dSZG4ToZGlFkO7ur2m4mG+rJ0eUb QKFJJ5oAHR1Qiami2YVaEsZn7frk0vohztOmDtyQbGjuHJCL/5e3bsnhr7x/W/H7wwnWFs FZiB3W7xmvFDgO8ZwB7Cbfo2A53ImX2PNMYsq0lGbnscIlvULO7MjkEYyzNoEd2Y7p0wQp 9KBBw6e8jG/doaysFSul1ip5Xyc/6kRqroOpijH0p1Qh0g6PP68G0OG4dRV3jAMXPhA3wo nrCOFeEVJ68MHqSqIcB9P560ZMAxlqBvejqhk8yzQo/PRAh9zJz3Uee+8JVQ X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Jul 2026 21:29:27 -0400 (EDT) Date: Wed, 22 Jul 2026 10:29:23 +0900 From: Michael Paquier To: Zsolt Parragi Cc: PostgreSQL Hackers Subject: Re: injection_points: canceled or terminated waiters leak their wait slots Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9AxgHkP5UHQ+qFd2" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --9AxgHkP5UHQ+qFd2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 21, 2026 at 09:28:22AM +0100, Zsolt Parragi wrote: > While stress-testing REPACK CONCURRENTLY on 19beta2 I saw a logical > decoding activation race, and I extended 051_effective_wal_level.pl > with a test that waits on an injection point and wakes it up later. > 051 cancels two injection point waiters earlier in the script, and > injection_wait() never cleans up after a canceled waiter, the wakeup > never arrived and the test deadlocked. >=20 > I think we are missing an ENSURE_ERROR_CLEANUP block there. See > attached patch with a testcase reproducing the issue. Hmm. I think that I'd rather use a PG_TRY/PG_FINALLY and avoid the refactoring with the extra routine required, keeping the cleanup action local to injection_wait(). That's also because the cleanup action is the same for both the "normal" exit path and the interrupt path. > I also attached a separate version for pg19, as master has a > refactored version of injection_wait. All previous branches have the > 19 version, it should be easy to backport to other branches. Thanks for that. I'm always OK to deal with a backpatch as required. Posting versions saves some time, of course, just don't feel obliged if you feel that this is extra work on your side. On an unpatched code, the test would hang due to the fact that we are doing a wait but we should not because the slot was not cleaned up. It means that a failure mode equals to a timeout. Why not, we have other tests of this class. Another thought: the addition of a SQL function that provides the list of waiters that we reuse here. I don't really see why this is worth the cost compared to your test, but opinions of others are welcome, of course. -- Michael --9AxgHkP5UHQ+qFd2 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmpgHPMACgkQnvQgOdby QH3LuhAAhCvmF2t5YdrdU6nJ1wxow+EETUqkqKvMqpYbPJOYOjUsp5tYmNBIsv6R 9efScGB0/+QpfmHlHwWSXTFHztSD3Q4ANraQvzzqENzE5/q9JwsYZAcXtFy9nNg8 ukL8eDMQ+Vhow8iPMztfr4aEdbTsVjeB7mmBzRMXogsqUQyApjFqMQusuW9nWHIo 1jRUW8UtL1ZdWU70DId/49OZ8mC2uAdhP+uRbfDgSXwQz3iCOFdG/6xrevUOSgB7 hrGzVHOfRL9WuEjhuvVSO5Y5gKqGLIAhlYswSYxb1qDSlEPk7AEgbW/ZSo6tbnxc 97sMUk1Hz4Q1igmvZxEGpF+JioWpM2D16AxnXKj3CFekCU+cW0G7UbnJPGf4GUjm HdAMnZ1+D/jQV01DVAYmDrcVpoz26l7uf4qjiUC1w4upyF/8UdYH6gtCAkhLy4Fl PRA7ESUu8iAG4kNYvbX+sa1Ly7zMTLzR5BGnHkXlTMxDPLBJrexshICtjCwhYkMY s+d99b7OCiqrINxk9x3nFZ8IpRONSFlm2slBvLId+hEy2zw5sxnbvb0Vbj0LWcxf tUDqBmd290VU5JyoBwzNekxsJY5tccwNnBxFWkxeFNGGYdWQwGquNQyrJqf1YxkC jo2rzp7NXAqnKQli0aa4pME2cIEN5UEvJV2n9v9kXtKcqoH1U6M= =54Gz -----END PGP SIGNATURE----- --9AxgHkP5UHQ+qFd2--