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 1vEFiv-008ROJ-F8 for pgsql-bugs@arkaria.postgresql.org; Wed, 29 Oct 2025 23:37:01 +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 1vEFiu-004Oqh-EP for pgsql-bugs@arkaria.postgresql.org; Wed, 29 Oct 2025 23:36:59 +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.94.2) (envelope-from ) id 1vEFit-004OqZ-Qk for pgsql-bugs@lists.postgresql.org; Wed, 29 Oct 2025 23:36:59 +0000 Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1vEFir-004Sx4-0B for pgsql-bugs@lists.postgresql.org; Wed, 29 Oct 2025 23:36:57 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.stl.internal (Postfix) with ESMTP id B13B81D00211; Wed, 29 Oct 2025 19:36:55 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Wed, 29 Oct 2025 19:36:55 -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=fm3; t=1761781015; x=1761867415; bh=d93HUIObWA idp8emgLp4Gl7U850B14icxKGg0h5meXY=; b=LXcTlNnoiRNDT6QJA7PxpY5WrP QijOTLebhkaKBXgdyzajzRQaV9ffEMO/PGsUe2nfO33VvZYJoTxtYwqwSAbIuYm1 FZYcLbsZQhRK19nOQDiKG8as1l7RdQh7UWM9qI0mqRu6IeTeXmet2pMjWtiTYeT5 w2yBvaRx2/lZL5G5gfUPuPLb87mBa74m9PAG1psXbWjEHi5Mv4F/muJXK0vEuwk4 lT6w4iHJGMq3PBG+tdUa4vMqgzmHulU0zTupFAZs/3telNYE+1vNvW7yFkZ/JCHl GCIa2hWxHbNVfCxxOw8T9R9d9irVeg726hy0reOd+ZxNuc3AAh3djFcvzrOg== 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=fm3; t= 1761781015; x=1761867415; bh=d93HUIObWAidp8emgLp4Gl7U850B14icxKG g0h5meXY=; b=XgTlY5WeSwco7hTFZmbjQoUW7Jtr6W6iyNkfV34jt/zi0tva+LB 4N2USa+kbjYfLyJ6fMBiRMQJj86OJxov3K4uKxRCpJ2KYBTEOusXnPqVZj3k8ug1 0cKEMQs3InwpCH+Odysr04iqPPBJe73041xsYpHvNxaB/J010wOTri9HdcR076lz 7FX4fJtSA/PO22CfXWF8aCQWKIZJYC2z7Wb8+AQLYqECabJ/K+Sr1/9w2CxcbtLN d4QDsBXTdir6YQRd3M368kiEkzBOPWRlUQPKQbTbyvGQtzoHuWy+MSaKEt3SinnF rOvprkTKDQPX5W3K29GrTNVZ6j52IH7nb+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduieehtdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttdej necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepveetjefgjeevgedukeehieeuieeu ieevueeiudegheevuefggfduueelgeelieetnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp nhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepgihunh gvnhhgiihhohhusehgmhgrihhlrdgtohhmpdhrtghpthhtohepnhhorghhsehlvggruggs ohgrthdrtghomhdprhgtphhtthhopehrhigrnhiigihgsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepphhgshhqlhdqsghughhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhr ghdprhgtphhtthhopegvuhhlvghrsegvuhhlvghrthhordgtohhm X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Oct 2025 19:36:52 -0400 (EDT) Date: Thu, 30 Oct 2025 08:36:43 +0900 From: Michael Paquier To: Xuneng Zhou Cc: Noah Misch , ryanzxg@gmail.com, pgsql-bugs@lists.postgresql.org, Euler Taveira Subject: Re: BUG #19093: Behavioral change in walreceiver termination between PostgreSQL 14.17 and 14.18 Message-ID: References: <19093-c4fff49a608f82a0@postgresql.org> <20251027041241.ab.nmisch@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+KHcMK6jdnK3hobd" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+KHcMK6jdnK3hobd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 29, 2025 at 02:36:10PM +0800, Xuneng Zhou wrote: > Should we wrap this assertion within #ifdef USE_ASSERT_CHECKING? >=20 > #ifdef USE_ASSERT_CHECKING > { > WalRcvData *walrcv =3D WalRcv; > WalRcvState state; > SpinLockAcquire(&walrcv->mutex); > state =3D walrcv->walRcvState; > SpinLockRelease(&walrcv->mutex); > Assert(state !=3D WALRCV_STOPPING); > } > #endif Yep. Or provide a wrapper routine that's able to retrieve the state of a WAL receiver, then add it in xlogrecovery.c within an Assert(). It may be better to only do that on HEAD, the back-branches stress me a bit when we enforce such new assumptions.. Perhaps Noah has a different opinion. > However, I think Michael=E2=80=99s approach is better =E2=80=94 it=E2=80= =99s simpler, more > straightforward, and captures the buggy behavior well. I plan to > incorporate it into the next version of the patch. Thanks! One weakness of this approach is that this test would not be able to work if the error message is reworded for some reason. On stable branches, I doubt that this error message will ever change, but it could be updated to something else on HEAD. Hence, I would suggest one extra improvement for HEAD: let's also add a check for a valid case where a WAL receiver is stopped. We have one in 040_standby_failover_slots_sync.pl, where primary_conninfo is updated in standby1 and its configuration reloaded, so I'd be tempted to add a valid check in the server logs of $standby1. One difference is that we should grab the offset of the logs before the reload, then make sure that the log entry gets created with a wait_for_log(), as there may be a delay between the reload and the moment the log entry is generated. -- Michael --+KHcMK6jdnK3hobd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmkCpQsACgkQnvQgOdby QH18Nw/8CmMM6Lp+TdJ25JY+uk0y7sl/3xh/GDnjB+pZl2I9FTzK1H8X1b/7a0Ei ilvkHuaUforXNrHS1EKq3rzLoWyh/udqiP5ods4pX6ZljC1rviZ5jXe+FyGQaixN +1cmrOihT8prDGjtTlxg/yjMGaXzCs/suRRWm4pJPi3VLWvb+EUP6E9IZ424oFz3 vp3Bf9rocgfdSZeZxXBivc19gziGnOdyDSTgHmFL8XOwF+FF5Utf8CT2IqSHR4Ka 7tP3zb++WiAebyZoa+GfWUv/9XnLY4hH4cdvN3sWOjmEC+OMf7zOxGfOba1D6qs+ tHbrtbLjA2k6XFTTiHOxJC5XkpL/bID/V57dguBPkOYG76oqVdS+tDWTajc6Now5 6ALFLxV+j6uondgjskSX0CP8UOODQ2VeKIo0pfWJectFItESUXORe7TgjNIvgKjw w8viK5SebfPp2MrSDFYogw6b9KtHstL4i2nkmPCdD5IYN7EHvz1QCK8K9BQd2WVw IP0MDqnaM9QuTjwNmbMXDjTQqOGbDQYaOr2N85PDsWNpdZrBBU5hlsScHYhoadXL 012slLmjeH4uQDylQyew1G2RygGYBlGCuvA2/DnFGvHUSx9EayI0gEGY4LCyOUgA PNSLeeyrkeBzULbc08r9yrPd/t97YGtaALxfzfvyND03Iw+OBuI= =lJjs -----END PGP SIGNATURE----- --+KHcMK6jdnK3hobd--