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 1tpgdO-00AJp2-1c for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Mar 2025 04:45:30 +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 1tpgdM-000Wia-3z for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Mar 2025 04:45:28 +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 1tpgdL-000Whh-IE for pgsql-hackers@lists.postgresql.org; Wed, 05 Mar 2025 04:45:27 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tpgdH-00124e-2d for pgsql-hackers@postgresql.org; Wed, 05 Mar 2025 04:45:27 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id E893F1382701; Tue, 4 Mar 2025 23:45:23 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Tue, 04 Mar 2025 23:45:23 -0500 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=1741149923; x=1741236323; bh=xWyEw5kfnJ gnVdBP8EPtvtJr8AX/Lf0dT1MHytwXrME=; b=JHM/lBUAiZXhWczgHWo+wcG0Q/ Nb1EEOoHDFYZFzQL4h8pkmFJyqs6Zjv8BD0/AuF+MFfdVBNhkea4g8IyUeWgNksW T5EB/uauPv5QDAcLXAKZXFo33tH7iuwaStVkVCRH0br1mBmsqetbwLxtloWHNf5w upNiaCL5kg+0kZ+1Av8wYK44WxS563dhqr0ol+XZrASZ89Ej4kKoJjoIfYajwzdO tGiQqmNsVY3HBS8uZc7ClrAktrsNtJKXm01vmwOpNyEV+QUOatFsNHrLxgOr/B8I Y4VZJGggcNGdm6Iit7T8w7gbGjvjQ9mhhy+uAOUs5db2V9AkdCJf3piP+wgA== 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= 1741149923; x=1741236323; bh=xWyEw5kfnJgnVdBP8EPtvtJr8AX/Lf0dT1M HytwXrME=; b=P7bDMrDkBGNH1xWIdfalgmub8z0FPB9mJOzWooWVLyw+wY2ic+H C2Oe9R93bMuQM/InmzJruk3WZDgsSo13JQwwiPU1KYaQDJzuOQ9abXVENzAByD/F dzud9R5q6qtKVAy0fA6mvDTJSH8Yp2Z1ghvpVJW9PZC7ma65UGNiYioNHpgkvIwj iTjiiS0ir135eBBwwD8Hl59Pxe3jEQYXcHllAiPb8GWO11nmliUtgpHrY0UbzX3J M4Q4dYDXJ7fhcpabs43HnPXQ/w8jzp86GbVEDtpDQi333dgi128lXacxjpJU+BHK 20QIg1w2q3pnUy18v8FlW1T+CyfIR4Cw2dg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddutdefkeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefu kfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivg hruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhep teelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggv lhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtph houhhtpdhrtghpthhtohepjhgrtghosgdrtghhrghmphhiohhnsegvnhhtvghrphhrihhs vggusgdrtghomhdprhgtphhtthhopegrnhgurhgvshesrghnrghrrgiivghlrdguvgdprh gtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghpthhtohep nhhorghhsehlvggruggsohgrthdrtghomhdprhgtphhtthhopegrnhgurhgvfiesughunh hslhgrnhgvrdhnvghtpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshht ghhrvghsqhhlrdhorhhgpdhrtghpthhtohepvghulhgvrhdrthgrvhgvihhrrgesvghnth gvrhhprhhishgvuggsrdgtohhmpdhrtghpthhtohepuggrnhhivghlseihvghsqhhlrdhs vg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Mar 2025 23:45:20 -0500 (EST) Date: Wed, 5 Mar 2025 13:45:12 +0900 From: Michael Paquier To: Jacob Champion Cc: Andres Freund , Robert Haas , Noah Misch , Andrew Dunstan , PostgreSQL Hackers , Euler Taveira , Daniel Gustafsson Subject: Re: [PATCH] pg_stat_activity: make slow/hanging authentication more visible Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="IqKghAUJG4NQOj8y" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --IqKghAUJG4NQOj8y Content-Type: multipart/mixed; boundary="/gQizRf4znsGxEBN" Content-Disposition: inline --/gQizRf4znsGxEBN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Mar 04, 2025 at 04:53:14PM -0800, Jacob Champion wrote: > I'll work on a fix, but it probably won't be fast since I need to > learn more about the injection points architecture. The test may need > to be disabled, or the patch backed out, depending on how painful the > flake is for everybody. Oops, missed these failures.. So we have a race condition where we are trying to wake up a point that's not waiting yet, because there is a small window between the moment when the backend entry is marked as "starting" and the injection point wait. What this is telling us is that we should change the query scanning pg_stat_activity for a PID of a backend in 'starting' state so as we also check the wait_event init-pre-auth, as this is reported when using injection point waits. The attached should be enough to take care of this race condition. -- Michael --/gQizRf4znsGxEBN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-race-condition-in-pre-auth-test.patch" Content-Transfer-Encoding: quoted-printable =46rom d5c976dc995bf09c4868e0b07d4652dabcaec888 Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Wed, 5 Mar 2025 13:30:43 +0900 Subject: [PATCH] Fix race condition in pre-auth test --- src/test/authentication/t/007_pre_auth.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/authentication/t/007_pre_auth.pl b/src/test/authentic= ation/t/007_pre_auth.pl index a638226dbaf1..90aaea4b5a64 100644 --- a/src/test/authentication/t/007_pre_auth.pl +++ b/src/test/authentication/t/007_pre_auth.pl @@ -43,12 +43,14 @@ $psql->query_safe("SELECT injection_points_attach('init= -pre-auth', 'wait')"); # authentication. Use the $psql connection handle for server interaction. my $conn =3D $node->background_psql('postgres', wait =3D> 0); =20 -# Wait for the connection to show up. +# Wait for the connection to show up in pg_stat_activity, with the wait_ev= ent +# of the injection point. my $pid; while (1) { $pid =3D $psql->query( - "SELECT pid FROM pg_stat_activity WHERE state =3D 'starting';"); + qq{SELECT pid FROM pg_stat_activity + WHERE state =3D 'starting' and wait_event =3D 'init-pre-auth';}); last if $pid ne ""; =20 usleep(100_000); --=20 2.47.2 --/gQizRf4znsGxEBN-- --IqKghAUJG4NQOj8y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmfH1tgACgkQnvQgOdby QH3nLBAAg0llom63A9aeG12fAEHTWy6AIkPL0OCSxaEni/OQas11VDpfKN82zkHm Jo5iVbcCBT7vFO5UO4+/JCMmpsUjNcjy87cT3HYwzyhlDtr/IeDzvenh/ginmeLz tbK+9gcEUEBJNMC+bXBW2vHhZpAoRV1ady/raXSh1jY8pKVYIHtO/enAHcv4PBT6 GdlgmUSKAgZZphsFHiiFbriQTYsezf9esVv+vHAcmnrorA125F8jIijQew9dAJC7 BzI7g+iGn9xO/cL7TVEezFLYRj/C6KoE3ZLNN3IGAqdAXTauufrgolPMtres5YdZ +pzTAU0VhE/3LAuvnPB8VwYbEK+rkCndB2iTkyus6BJ84b2d1xanIBvEHpMs7RMG paZgY1TNwpoeIhS/ZbF5bh+zuvBdcAaTQcM+Kqmz7KzniVWt7+Jwum8Sfwi22fih C91ZYsewHfDimlCtFAxOPNOL45oWBGOhwYQdK+rDIYpZfNrjmlEfS95j1b1sjojl yoem/m8fal8uIx3JZ0txF8s4ZS6eZg1EnAuwjDjtJXs3MQR/qtEtzPorPFzuH7cI VZlXFvIB92z2mikENZVksbAv2s/FylmUsFZbMNKFv8bj31pU3YFXeX6FGJ5iC49x G8ZxhyqkvR3xpgYIWAg8FiFvqZ3Pwt15MHgtwzuy5RpATyAUHqg= =cMys -----END PGP SIGNATURE----- --IqKghAUJG4NQOj8y--