Re: Offline data checksum changes can cause incorrect checksum state on standbys

Поиск
Список
Период
Сортировка
Искать

Re: Offline data checksum changes can cause incorrect checksum state on standbys

От:
João Rito <joaovictor.rito@gmail.com>
Дата:
Вложения:
Hi Raja,

Thanks for the patch. I tried v1 (cfbot branch cf/7587, commit
8dda72e) on Ubuntu 26.04 (WSL2), applied on master c1694b7. It applied
cleanly with git apply and pg_combinebackup rebuilt fine. The build
was --without-icu and without TAP tests.

I used a small script (attached as repro.sh) with initdb
--no-data-checksums, summarize_wal=on, a full backup, pg_checksums
--enable on the stopped cluster, then an incremental backup and
pg_combinebackup.

Before (master):
  pg_combinebackup: error: only some backups have checksums enabled
  pg_combinebackup: hint: Take a new full backup after changing the
data checksum state with pg_checksums.
  (exit=1)

After (v1):
  pg_combinebackup: error: only some backups have checksums enabled
  pg_combinebackup: hint: Take a new full backup after changing the
data checksum state.
  (exit=1)

I got the same before/after result for the online case. There I took a
full backup with checksums off, ran pg_enable_data_checksums(), waited
for data_checksums=on, took an incremental backup, and ran
pg_combinebackup. The full backup's control file shows
data_checksum_version 0 and the incremental shows 1.

Observations:
- The new hint matches the behaviour, since the check also triggers
after online enabling and the old hint pointed only at pg_checksums.
- The hint is now less actionable. A reader gets the "what" (take a
new full backup) but not how the state changed. That seems fine to me,
but you could keep it explicit, for example "after enabling or
disabling data checksums". I did not test a backup chain across a
disable.
- The doc xref checksums-online-enable-disable exists in wal.sgml. I
could not build the docs here (xmllint is missing), so the SGML change
is only read, not rendered.
- The new doc text says the chain is refused for backups taken "while
they were still being enabled". I did not test that intermediate
state, so I cannot confirm that sentence from a run.
- I did not run the pg_combinebackup TAP tests (IPC::Run not
available), and a grep for "data checksum state" in
src/bin/pg_combinebackup/t finds no test for this hint, so a small
test for the error/hint might be worth adding.
- src/bin/pg_combinebackup/po exists, so the translations may need an
update; I did not check the .po files.

Thanks again,
João Rito

Re: Offline data checksum changes can cause incorrect checksum state on standbys

От:
shihao zhong <zhong950419@gmail.com>
Дата:

Hi Raja,

Thanks for the patch, the new hint looks good to me.

One more thing. An incremental backup taken while checksums are still
being enabled online also gets refused, though the restored cluster
just comes up with checksums off. The comment in check_control_files()
says we only check when the last backup has checksums on, so I think
the test should be "== PG_DATA_CHECKSUM_VERSION" instead of "!= OFF".

Thanks,
Shihao

Re: Offline data checksum changes can cause incorrect checksum state on standbys

От:
Raja Sai pranav <rajasaipranav0@gmail.com>
Дата:
Вложения:
On Sun, Nov 22, 2026 at 12:35 AM shihao zhong <zhong950419@gmail.com> wrote:
> An incremental backup taken while checksums are still
> being enabled online also gets refused, though the restored cluster
> just comes up with checksums off. The comment in check_control_files()
> says we only check when the last backup has checksums on, so I think
> the test should be "== PG_DATA_CHECKSUM_VERSION" instead of "!= OFF".

Thanks, you're right. I tested it with an incremental backup taken while the state was inprogress-on. With your change pg_combinebackup accepts the chain, and the restored cluster logs "enabling data checksums was interrupted" and comes up with checksums off, with all rows readable.

I also checked the other way recovery can end. When the archive has WAL past the point where enabling finished, recovery replays the rest of it and the restored cluster ends with checksums on. pg_checksums --check then finds no bad blocks, because the worker writes every page with a full-page image.

The same change also accepts a final backup taken while checksums were being disabled, which is safe for the same reason.

v2 attached:

0001 is v1 unchanged (hint and docs).

0002 makes your change, adds a sentence to the docs, and adds a case to test_checksums/024_combinebackup_mixed.pl for a final backup taken during an online enable. The new case fails without the code change. While running it I hit a race: the first restored node in that test can archive a timeline 2 history file into the shared archive, and the second restored node then tries to follow a timeline that branched before its backup. The new node now sets recovery_target_timeline = 'current'.

I credited you with Suggested-by in 0002.

Regards,
Sai Pranav

FAQ