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 1uT90z-000RFI-9L for pgsql-committers@arkaria.postgresql.org; Sun, 22 Jun 2025 00:56:57 +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 1uT90w-00AEy7-3X for pgsql-committers@arkaria.postgresql.org; Sun, 22 Jun 2025 00:56:54 +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 1uT90v-00AExy-O3 for pgsql-committers@lists.postgresql.org; Sun, 22 Jun 2025 00:56:54 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uT90u-003JEq-14 for pgsql-committers@lists.postgresql.org; Sun, 22 Jun 2025 00:56:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 55M0uoIc2852530; Sat, 21 Jun 2025 20:56:50 -0400 From: Tom Lane To: Alexander Korotkov cc: Melanie Plageman , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Improve runtime and output of tests for replication slots checkp In-reply-to: References: <2542023.1750456985@sss.pgh.pa.us> <2585993.1750458298@sss.pgh.pa.us> <2594452.1750462958@sss.pgh.pa.us> Comments: In-reply-to Alexander Korotkov message dated "Sun, 22 Jun 2025 03:16:10 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2852528.1750553810.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sat, 21 Jun 2025 20:56:50 -0400 Message-ID: <2852529.1750553810@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Korotkov writes: > On Sat, Jun 21, 2025 at 2:42 AM Tom Lane wrote: >> But "Wait for the next page to become available" seems awfully >> trusting that there will be another page. Should this be >> using the no-wait code path? > Thank you for the help. It seems to me that problem is deeper. The > code seems to only trying to read till the end of given WAL record, > but can't reach it. According to the values I've seen in XLogCtl, it > seems that RedoRecPtr points somewhere inside of that record's body. > I don't feel confident about to understand what's going on and how to > fix it. 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. 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. > The new tests just spotted the existing bug. 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. regards, tom lane