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 1uTV3j-005Fus-Bb for pgsql-committers@arkaria.postgresql.org; Mon, 23 Jun 2025 00:29:15 +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 1uTV3g-00G6f3-1v for pgsql-committers@arkaria.postgresql.org; Mon, 23 Jun 2025 00:29:12 +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 1uTV3f-00G6ev-Ke for pgsql-committers@lists.postgresql.org; Mon, 23 Jun 2025 00:29:12 +0000 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uTV3d-003SRA-0b for pgsql-committers@lists.postgresql.org; Mon, 23 Jun 2025 00:29:10 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id DB302138082D; Sun, 22 Jun 2025 20:29:07 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 22 Jun 2025 20:29:07 -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=1750638547; x=1750724947; bh=1IUXM4HgZo k19pW2zXmke64fNGJ+HgOrKPZ+SRWooww=; b=N8JkS/f51vdxsDkhUqE18BBPZP 0NJ7sIoPM2cxi4Z8uslXuJuBQkIwJdPYt0pyj3ZJiaFjC4+0JhPpaXR612TnsgOi c+SI3wZYC8Pyt39EG+3PElEMIlbB+/ErWLv90BKeHdAFBmJmWg2Ya0KbX2IPDnPX IwHN4ZpnzjUmtNTi0pyN2aOCLPs+NqrwjcdzNj53GyI0H/rhRQzJtqmpyPQPOQoi ghykGCyGfNZCId1ty3fOhXIQLpqyp2aRmBiIIAfyEsFZGY/SIiYBlxLVB22ioEdL XU4AvTEw/nFbVtITKkzCLaujJes88Zi/Oplpv5IpUDGJVycmF7p/u8wP849Q== 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= 1750638547; x=1750724947; bh=1IUXM4HgZok19pW2zXmke64fNGJ+HgOrKPZ +SRWooww=; b=Twyd69EIy027FoZKs7eEgo/obV5s3OB4XoiyNu9AzOf0OigKcB3 KsvP6EQCpqBMuNM8KmzsDnyAw44BiRUgz7sa3Je3AzAPDN6m2ahIC46NoS4GYq4Q Wn7RK4bIrC79cTipDRto6MB9E6TBnIe/m2LdSHOSnil6rDG56KazT4QH12ygvkF4 C8zCXwdHsFDHmrn70hPStOHxPWHbiOmqsjvtuuhdd/cfgZUaBmWwfG/x3mZR0vvy VxPcSSM8cTwmiSZdJp+H2SlMEoteh64gJTG7O82QPNbc8MVOtirELoNpw6osJnFS VjfFMuX0SbuNrTo0UvaGxRCISDfI36lOmBw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddvgdduheeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehtghhlse hsshhsrdhpghhhrdhprgdruhhspdhrtghpthhtoheprggvkhhorhhothhkohhvsehgmhgr ihhlrdgtohhmpdhrtghpthhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghilh drtghomhdprhgtphhtthhopehpghhsqhhlqdgtohhmmhhithhtvghrsheslhhishhtshdr phhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 22 Jun 2025 20:29:05 -0400 (EDT) Date: Mon, 23 Jun 2025 09:28:53 +0900 From: Michael Paquier To: Tom Lane Cc: Alexander Korotkov , Melanie Plageman , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Improve runtime and output of tests for replication slots checkp Message-ID: References: <2542023.1750456985@sss.pgh.pa.us> <2585993.1750458298@sss.pgh.pa.us> <2594452.1750462958@sss.pgh.pa.us> <2852529.1750553810@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xcrv24uG3IrlNE0x" Content-Disposition: inline In-Reply-To: <2852529.1750553810@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xcrv24uG3IrlNE0x Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 21, 2025 at 08:56:50PM -0400, Tom Lane wrote: > Hmm. My theory about what's happening is that we are writing a WAL > record that spans across a page boundary, and the asynchronous > immediate-stop request comes in and kills that operation, so that > the first half of the record is on disk but the second is not. > (This outcome would obviously be very timing-dependent.) Then > we restart the server, and crash recovery copes with that situation > successfully. But pg_logical_slot_get_changes() fails to, because > it's coded in such a way that it will wait forever for the second > half of the WAL record to appear. >=20 > The main hole in this theory is: if crash recovery thought that the > partial record was invalid, wouldn't it set the end-of-WAL position > to the start of that record? And shouldn't that stop > pg_logical_slot_get_changes() from trying to process the partial > record? So I'm sure there's some details not quite right about > this picture. But maybe it's within hailing distance of the truth. Obviously pg_logical_slot_get_changes() should not try to read the record if it's not complete yet. XLogDecodeNextRecord() may be trusting too much the LSN given by its caller, though. >> The new tests just spotted the existing bug. >=20 > Yeah, that's what I think too. The unintentional omission of a > pre-shutdown delay in the 046 test has exposed some pre-existing > fragility in pg_logical_slot_get_changes(). So I'm not in favor > of changing 046 till we understand this better. Yes, better to understand what's going on before changing the test, and perhaps change 046 so as it provide stable coverage for this case, even if discovered accidentally. So, is it only pg_logical_slot_get_changes_guts() that's messed up in this context, because XLogDecodeNextRecord() is trying to read pages as it has a logic too permissive? How did any of you reproduce the failure? Just by running the test in a loop? It is one of these patterns where a hardcoded sleep should do the trick and help with a bisect. By the way, At the bottom of test 046_checkpoint_logical_slot.pl, if you expect the checkpoint to complete before sending the immediate shutdown request, I would suggest to use a wait_for_log() based on "checkpoint complete" or an equivalent loop. What you are doing in the test is unstable as written. -- Michael --xcrv24uG3IrlNE0x Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmhYn8UACgkQnvQgOdby QH2pLw/+IAOKvPKBbRgTBB/3d0shPneD1BYLfLWi5shLuHCdYkCUzgYHbbwIYobu EjwywG7gi1jh7bhxLFjUkSRz1nzLpGGCx2lEWAB1ORqT5pzy+jhrLfer7UtQLtLw J+lmBxaUaDlZCAPuAZQezFMqP6OtUhL0oVL5HfnIUEWErwpsI0tNNZ3jXs4cMI4a bQyIUYvpSUWT63Qjhbiew9hyYQ51qanbnGqXP0TQN2XHnTxxX/tateMbbAOD/5UM Sf184wefVVcJv0+6kjPwtO4Ms+Okhez4nzaSpnPC2FImuSrN7bwXseZunaXgb7Ry dGu2pGXWTr6pDGOLWvxZyho7HbsSZy8fT0TelqImj1PbatzLB8go4lO/93AYAeIX ZrRxueLLyUXragvXv8SUp6xlaTTkJ/JX4VoHWAzjcwmGNtVotHjVRqEPpf0T1Qwt JdOwxOAExYFOmftPv2h3rXDHWvl4nPyVfxYlI4Vg2MdMurGi6tfkyVRF8iG928vu VdFe5iJxo9RYNqwbCNYAWo6Cw5y74fJweg31LVLWwCprmXzTBNm1UP5p7vvJdnBw a01Q5iLeGTavlTBgEwXSKNYt+xs4woRsficCmUcNQb3kfln7kvATUPvXcY8XM3FA BrjV+T5y8OVv0DC30p5pYBOOb2hrrcsb27+ruuAASQtSnuEP/IE= =57W1 -----END PGP SIGNATURE----- --xcrv24uG3IrlNE0x--