diff options
author | Robert Haas <rhaas@postgresql.org> | 2024-04-25 14:58:59 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2024-04-25 14:58:59 -0400 |
commit | 205db0114e03496f1d6febf276374900b6314e67 (patch) | |
tree | 3134b6354ec1e3d4884d8a04c6f028b5e4f28e8d /src | |
parent | 6d4bc96eb77bca6277880f218cd7a2f9e44bddc0 (diff) | |
download | postgresql-205db0114e03496f1d6febf276374900b6314e67.tar.gz postgresql-205db0114e03496f1d6febf276374900b6314e67.zip |
pg_combinebackup: Detect checksum mismatches and document limitation.
If not all backups have the same checksum status, but the final backup
has checksums enabled, then the output directory may include pages
with invalid checksums. Document this limitation and explain how to
work around it.
In a future release, we may want to teach pg_combinebackup to
recompute page checksums when required, but as feature freeze has come
and gone, it seems a bit too late to do that for this release.
Patch by me, reviewed by Daniel Gustafsson
Discussion: http://postgr.es/m/CA+TgmoZugzOSmgkx97u3pc0M7U8LycWvugqoyWBv6j15a4hE5g@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_combinebackup/pg_combinebackup.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c index 4958372653b..232ba5b0697 100644 --- a/src/bin/pg_combinebackup/pg_combinebackup.c +++ b/src/bin/pg_combinebackup/pg_combinebackup.c @@ -583,6 +583,8 @@ check_control_files(int n_backups, char **backup_dirs) { int i; uint64 system_identifier = 0; /* placate compiler */ + uint32 data_checksum_version = 0; /* placate compiler */ + bool data_checksum_mismatch = false; /* Try to read each control file in turn, last to first. */ for (i = n_backups - 1; i >= 0; --i) @@ -612,6 +614,16 @@ check_control_files(int n_backups, char **backup_dirs) controlpath, (unsigned long long) system_identifier, (unsigned long long) control_file->system_identifier); + /* + * Detect checksum mismatches, but only if the last backup in the + * chain has checksums enabled. + */ + if (i == n_backups - 1) + data_checksum_version = control_file->data_checksum_version; + else if (data_checksum_version != 0 && + data_checksum_version != control_file->data_checksum_version) + data_checksum_mismatch = true; + /* Release memory. */ pfree(control_file); pfree(controlpath); @@ -624,6 +636,16 @@ check_control_files(int n_backups, char **backup_dirs) pg_log_debug("system identifier is %llu", (unsigned long long) system_identifier); + /* + * Warn the user if not all backups are in the same state with regards to + * checksums. + */ + if (data_checksum_mismatch) + { + pg_log_warning("only some backups have checksums enabled"); + pg_log_warning_hint("disable, and optionally reenable, checksums on the output directory to avoid failures"); + } + return system_identifier; } |