basebackup: do not verify checksums on pages written before enabling checksums

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: basebackup: do not verify checksums on pages written before enabling checksums
Date: 2026-08-14 19:36:09
Message-ID: CAN4CZFP=-cVVVPue+e8qqPtDfuLuQn=ZB4Mw_C9-Ncru2wqAsQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello!

While testing the online checksum enabling feature, I discovered that
basebackup can fail when it is interleaved with enabling data
checksums. When the checksum enablement process finishes, we mark the
checksum state as "on" before the checkpoint that flushes pages
written by the worker completes. This means that a basebackup process
active at this time can start verifying checksums before we flushed
all checksum calculations, and can fail with checksum errors because
of this. This doesn't result in a corrupt backup, the process fails,
but that is still an issue.

I attached a test case and a proposed patch that solves this by
recording the status of checksums at the last checkpoint when the
backup starts, instead of using the current value. If checksums were
not fully enabled at the beginning, we do not verify them during the
backup run, even if they become enabled during it.

I am not 100% happy with the shape of the patch, but I couldn't come
up with a better solution even after staring at it for a long time,
and I think it is at least correct and good enough. But maybe somebody
has a better idea for solving this problem.

Attachment Content-Type Size
0001-basebackup-do-not-verify-checksums-on-pages-from-bef.patch application/octet-stream 10.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-14 19:57:32 Re: basebackup: do not verify checksums on pages written before enabling checksums
Previous Message Robert Treat 2026-08-14 19:11:31 Re: Doc update proposal for the note on log_statement in the runtime config for logging page