Re: basebackup: do not verify checksums on pages written before enabling checksums
Re: basebackup: do not verify checksums on pages written before enabling checksums
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 15 Aug 2026, at 10:10, Zsolt Parragi wrote: > >> I had a look and I wonder if the boolean could miss an on->off->on series of >> changes. > > Good catch, I missed that. I checked that on->off works, but > on->off->on reenables verification and can again see checksum errors. > >> Maybe tracking a checksum transition generation/LSN would make this easier to >> reason about? > > That seems like a good idea, that would allow us to remove the static > variable. v2 attached based on this approach. (the on-off-on issue can > also be fixed in the original static bool version with slightly more > changes, we could also go in that direction, but let's first see what > everyone thinks about this approach) I prefer this approach, getting rid of the static variable is a neat win. Can we combine the two tests into a single 010_backup.pl to keep cluster inits down? + * If we weren't told not to verify checksums, and if checksums have been While not the fault of this patch, I think we should take this opportunity to remove the double negative and rewrite this to "If we were told to verify checksums". -- Daniel Gustafsson
Re: basebackup: do not verify checksums on pages written before enabling checksums
> Can we combine the two tests into a single 010_backup.pl to keep cluster > inits down? I reworked the tests with another injection point as part of this, this way they shouldn't be flaky on CI and they are significantly faster now. > I'm not sure that "since the server started" is enough for a backup taken from > a standby. XLogCtl is zeroed at startup, while the checksum state is restored > from pg_control. The standby can become available before replay reaches the > latest checksum transition, so verification could resume with > lastChecksumChangeRecPtr invalid. There was really an issue there, I think we can solve that by advancing minrecoverypoint. I kept a test case for this separate for now, as I am unsure if we want to include it in some form. > I think that an atomic would make more sense. Also done.
Re: basebackup: do not verify checksums on pages written before enabling checksums
От:
Zsolt Parragi <zsolt.parragi@percona.com>
Дата:
> I think we should still to doing it for every transition in 19, and if someone > feels like optimizing it can be revisited for 20. Agree, this is the simplest/safest choice for now. > Another thing I am pondering is to place these tests under PG_TEST_EXTRA. > While 128MB for shared_buffers is pretty moderate, I'm not sure we want to > induce that on a normal BF run. 0002 does some backup cleaning as well as a > pgperltidy and pgindent and some very minor fiddling with test code. If we include 011, that definitely should go into extra as that's also slow. 010 is at least relatively quick in its current form. Also 128 is just a quick "should be large enough" guess, 32mb also seems to be enough for 010, it still triggers the failure without the fix. > Users will obtain a backup with zero checksum validation, while believing checksum verification is enabled. Why would they believe that it has checksums enabled, if they started the backup before checksums completed? > > but 010_backup_straddle.pl does not. Should 010_backup_straddle.pl also disable > > bgwriter to preserve dirty pages? > > I'm not sure, does it need to? I think the test should be safe as-is, since we have more than enough shared buffers. Even with 32mb shared buffers, the test reliably errors out without the fix.
Re: basebackup: do not verify checksums on pages written before enabling checksums
> The failure is triggered at the end of perform_base_backup() when total_checksum_failures equals 1, > via ereport(ERROR, errcode(XX001)). > However, pg_stat_database.checksum_failures is not updated at all. This seems like a separate issue existing for much longer, I'll submit a separate patch about it. > Judging by the current test cases,, > pg_stat_database.checksum_failures appears to offer no detection capability beyond what ok($backup->finish) already provides. I improved the tests a bit, while also adding the 32m shared buffers change to 010. I kept this as a separate commit for easier review.
Re: basebackup: do not verify checksums on pages written before enabling checksums
От:
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Дата:
Hi, On Mon, Aug 17, 2026 at 11:03:31AM +0200, Daniel Gustafsson wrote: > > On 17 Aug 2026, at 05:07, Bertrand Drouvot wrote: > > On Sat, Aug 15, 2026 at 03:30:56PM +0100, Zsolt Parragi wrote: > > I think we should still to doing it for every transition in 19, and if someone > feels like optimizing it can be revisited for 20. Yeah, makes sense. > I tried that in the attached 0002. That looks ok, thanks! > The risk I see is that it may become flaky > if we don't set about waiting for the next event in time after waking up this > wait. The launcher stays blocked and keeps reporting the event until explicitly woken, so I'm not sure I get your point. > > I think that only prove that no false checksum failure is reported. > > Could one post transition backup reuse the existing corruption mechanism (see > > 010_pg_basebackup.pl) to check that verification resumes? > > Good idea, also done in 0002. +$node->stop; +$node->corrupt_page_checksum($fcorrupt, 0); +$node->start; The test stops and restarts the node before taking the backup, which resets lastChecksumChangeRecPtr. Should we also test that verification resumes while lastChecksumChangeRecPtr is still set? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
Re: basebackup: do not verify checksums on pages written before enabling checksums
От:
Daniel Gustafsson <daniel@yesql.se>
Дата:
> On 17 Aug 2026, at 14:54, Bertrand Drouvot wrote: > +$node->stop; > +$node->corrupt_page_checksum($fcorrupt, 0); > +$node->start; > > The test stops and restarts the node before taking the backup, which resets > lastChecksumChangeRecPtr. > > Should we also test that verification resumes while lastChecksumChangeRecPtr is > still set? corrupt_page_checksum() only works reliably when the cluster is turned off, a reliable corrupt-checksum mechanism for an online cluster could for sure be done but seems a bit more invasive at this point. Or am I missing something obvious? -- Daniel Gustafsson
Re: basebackup: do not verify checksums on pages written before enabling checksums
> On 18 Aug 2026, at 06:18, Bertrand Drouvot wrote: > The test does not check that verification resumes while lastChecksumChangeRecPtr > is set. Just to be sure, did you skip that on purpose, or did you miss [1]? Sorry, missed to mention that I skipped it on purpose since I don't really foresee it providing much value. That being said, I have been wrong before so I ended up adding one in the attached v7 anyway. -- Daniel Gustafsson