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 1wYuyX-000cjM-1c for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Jun 2026 00:14:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wYuyU-0097Ph-0A for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Jun 2026 00:14:46 +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.96) (envelope-from ) id 1wYuyT-0097PY-0a for pgsql-hackers@lists.postgresql.org; Mon, 15 Jun 2026 00:14:45 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wYuyO-00000000Qaf-1jXD for pgsql-hackers@lists.postgresql.org; Mon, 15 Jun 2026 00:14:44 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id F37F87A0082; Sun, 14 Jun 2026 20:14:36 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sun, 14 Jun 2026 20:14:37 -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=fm1; t=1781482476; x=1781568876; bh=p26w/6tc3h yBLYAgjoFyImBSg5zxjBivNI8WLekxJEU=; b=h+SsSa0pcvVuAe2iuN8xb3rjqr IXLunB1/9n9Miok4FDFKMrEnHZYzq0lBwujWDNfKu22i7DkkGwngiU+UrwvFi/GR GeNMTjIinSZz43OGqfeCGjpUcQ5cF7Gp7yrPgcbRfjNX7V6ASL7Tl9pJcU+IPmfv GjFph2CYcm2Z0VbqMA1p8DRRWT1iyFSRAGadjWvckPwSeFIrDczZfa+Ub6csV0+D bws+jpd8IZS98iZpwayqeHPyYhArQ+rW0v3ABw1a9S76tWXghZEaNeFGoZ1mBU8C G1PkvhinadkbUgRDjvgg8RDTTa+UMV2BG1MWnQhDyX2iszo6YmYsaZP/ETmw== 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=fm1; t= 1781482476; x=1781568876; bh=p26w/6tc3hyBLYAgjoFyImBSg5zxjBivNI8 WLekxJEU=; b=TuFtdm8EYA00ZfZt1wD2fvbvkTdsSZJgkLH+AdFYCtC0GNzX6NJ +mE+SbIvL+LTPThygZGENjbZi2g+cl9+x5Az+/0WouyWqm0zTEKEuMw3cTies8en xASZCS3EyI/nkoKSrPJfURn5V4R5ghiCEBIQ+0B7b0aFJVpF595kD2NMo8tROvPB SC7gmd7BcTYW4AGPaHZU60xLGPTG7QuiZKiUUkGe1HObqvoYZrFuTm8D84oHqHCS arHW9giWEfm6C/0qppMPuF50no1Iug7lIwm5B7GU/7uG+NzJhzqN7eN+GWrej0or c0OF4Y7UQv4/qCShOak3K4Gl99P3sRlU2SQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF3u8QYb2jiDnBZAOTuJEfdtlVSfVrj61mJpOQ2b/TkIvbOLTXxZ1RS0uE6r1hoMj KK/tdN3osSV9sthX07Ngyi8T1zlr4xOzDqJAd3kb1d/KEGpo7gllYKzkBj7+TwRA3l/lcU 5cuCYQ2acrC/wffHj/o+QJv0EDoU8Kmu4QTvQnXa+52p3SXVY7a8W5rjDNlKGYNj4eWqEN CtkhD6498zWnRZjwqoyTZVyjfUgcIqusN7foQ5aWvE8WitUiKPJZxKdHxvVo8BqRFNaBc5 QSO2iR7tSFMS+eVvfjyDx24G3JAF7wlFdZ8DlhjSvabtUNRxEoAThVNnEJ0laoG6EdNtHS kd1lH4GDDzMjEZ7mGblvJ/zY+Jz4uTBFWZB03qYMKQY3R/7dMfq/NYFpMMxnrIqkwpupDA LjyEbS3gCfJxta45wL5S+GvzL6SVnukH/m1R+g9Noz8Z7+LEm/RO8xVOWV4mfobgLQtc4U 6axXsNXOUmOeBOL0jIK/xHwr68e2J/CJzYE8m7OZXLLlr334OFhu0vtIzwH2IKU8n/CsNr VqXcK3XifOZ7BbNWsCFjJcLLXZFPSLqHnhM15RlMbWCByeN0sqCHCJUvJogcSvZx9sDcb6 6nOms9ebKaNKZpcxNyU9KX8DBOqZ6kdTiVlTkvOOXma4nPPQxZdcRrjMKdJQ X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 14 Jun 2026 20:14:34 -0400 (EDT) Date: Mon, 15 Jun 2026 09:14:31 +0900 From: Michael Paquier To: Andrey Borodin Cc: Robert Haas , Postgres hackers , Heikki Linnakangas Subject: Re: injection_points: Switch wait/wakeup to use atomics rather than latches Message-ID: References: <46821C66-E6B2-420D-BB83-E20EF36665B8@yandex-team.ru> <688F6266-3901-4C84-B27A-AF5904801A3A@yandex-team.ru> <0C7D1930-F8BD-45D3-980B-841F1DBE1204@yandex-team.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="aMQG3DFkC7ukMd1s" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --aMQG3DFkC7ukMd1s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jun 14, 2026 at 02:23:54PM +0500, Andrey Borodin wrote: > The same revision also closes an unrelated init race: when two processes > create the backing file at once, the loser could map it before the winner > sized it (SIG-something on first touch). The attach path now waits for the > file to reach full size before mapping. >=20 > CI is green. Same two patches on top of your atomics commit. Let me know > if this prototype goes radically wrong way. You may find my reply surprising (or not), but using a client tool to bypass the SQL protocol is super invasive in terms of the in-core changes, and I'm -1 on that. Test tooling should rely on simple facilities, and you are re-implementing quite a few things here that come with a new class of bugs and what look like design issues to me due to the invasiveness: - Reimplementation of the registry protocol for file mapping. That may be useful for other things, and there may be use for a refactored in-core API, but I don't see why we should use it here: - Mirroring of internal structs for shmem manipulation. - Core data updates with zero locking. I am wondering if we are not overcomplicating things here.. How about this idea instead of 0002 and 0003, for paths that cannot rely on some SQL: - Let's use a file-based markup, located in a injection_points/ in the data folder. - When attaching a wait point, write a marker, say wait_$POINT. - On wakeup, write a wakeup_$POINT.=20 - The wait routine does periodic checks of the wakeup_$POINT file, using a stat(). It depends on how much we want to achieve, but forcing a postmaster to wait at an early startup sequence would then be something like: - Add the a wait markup. - At startup, shared_preload_libraries scans the pg_injection_points/ repo, fills in its shmem state by calling InjectionPointAttach(). - postmaster hits the injection point, calls injection_wait() - Test does what it wants while the postmaster waits, manipulates states. - Test script drops a wakeup file. - Postmaster sees the file, continues its startup sequence. This means one cannot set an injection point until shared_preload_libraries is loaded, of course. Cleanup logic feels kind of nice: test cleans his stuff, or just remove pg_injection_points/ at shutdown with an exit callback. No platform specific logic, only FS checks. This means a bit higher latency, but it eliminates a full class of bugs due to the fact that it is simpler. This would need to live alongside patch 0001 so as a _PG_init() can be loaded when the injection_points lib is loaded; we're still going to need it to fill the shmem info with the wait slot being occupied. -- Michael --aMQG3DFkC7ukMd1s Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmovQ+cACgkQnvQgOdby QH1XRxAAlCE7dpE2F3ppWlF7zwDWbLmjua4QxQub7Ss0PWmvrInn7BGdx/Ngy405 4KVn936ABwfYNpOn5SFfdoL+wY41noZeMZjPD0+rep/9y385lwWZqGu9NnnnyaYx g6kkDJ8UMVxY+2aI2GWQND3qH8b+fPPbBODjelHC9LHIt4O73RUyiY8dLvWJrIxI yxk0yx6A5V/RBpvtvmUezrX4rH2sYp0tuGBcTE3bZiLqMztAw0tk71CZrHjQmUWM hvd4zer1V4lkydOY/ib1/8afAuPrJ2VseiV9TGR71IB9VdvpbB83d9CjxXZfm6El 7XKJEf1rYswaY/gRW7D8e80W62uSrefo91KvxuDMOlUi5NsAHC7cz+kx2OVtEqZH RHBqxOYXUjlOeORhRkpMQsaQ8K81PDUm0W46c10iPJ/IIBUIDAAMJF1+3FheCN/k wd3riRm0K92r0bBDca39TJfwGcEa02AHzW79OrPG39MS4F9YRQE9h9n3uqrrHnG1 zoIYL4V4IHkf8pwwWBWtSRRJp8JT9FyVbQqsc+LHAq+OAOxLFucNwIu4oEmbRdAs 5a5HEBKDxiUF399rqvS23TmMtZEPq3GTXxCL9JTXvjZ3FB80kLsZbjyeqt3kjLQ+ 9NQxE1z6EoYCGJwr/dm/YpB6EpN/3Y5u0uxAqY7Ohv2t+GzU/pg= =yGPN -----END PGP SIGNATURE----- --aMQG3DFkC7ukMd1s--