Enabling data checksums in a running cluster changes the state to "on" before the checkpoint which flushes the pages the worker rewrote. A base backup which started before that transition absorbs the barrier mid-run and starts verifying pages whose on-disk copies legitimately lack checksums, and whose LSNs predate the backup start, so the LSN check does not skip them either. The backup fails with bogus corruption warnings. The same applies to checksums being disabled and re-enabled while the backup runs: hint bits set while checksums were off reach disk without a checksum update and without moving the page LSN, tripping verification once the re-enabling completes. To fix, verify checksums only while they have been continuously enabled since the checkpoint the backup started from: track the location of the last XLOG2_CHECKSUMS record inserted or replayed, and verify only when the state is "on" and the last change predates the backup start. The starting checkpoint then guarantees that every page flushed before it has a checksum written, and any later change disables verification for the rest of the backup. A standby loses the tracked location when restarting, while pg_control already carries the new state, so it could reach consistency below the record and serve base backups with the location unknown. To prevent this, replaying XLOG2_CHECKSUMS advances minRecoveryPoint to the record, like XLOG_PARAMETER_CHANGE does. The tests hold the enabling between the state change and its final checkpoint with injection points, straddling it with backups on the primary and across a standby crash-restart. Author: Zsolt Parragi <zsolt.parragi@percona.com> Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/CAN4CZFP=-cVVVPue+e8qqPtDfuLuQn=ZB4Mw_C9-Ncru2wqAsQ@mail.gmail.com Backpatch-through: 19
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/19/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/19/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.