[patch] Fix pg_checksums to allow checking of offline base backup directories

From: Michael Banck <michael(dot)banck(at)credativ(dot)de>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [patch] Fix pg_checksums to allow checking of offline base backup directories
Date: 2020-04-06 11:26:17
Message-ID: 78c199841acb84a47b55fd2dd6ee9619ab8a09c2.camel@credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Right now, pg_checksums cannot check a base backup directory taken by
pg_basebackup:

initdb -k data > /dev/null
pg_ctl -D data -l logfile start > /dev/null
pg_basebackup -D data_backup
pg_checksums -D data_backup
pg_checksums: error: cluster must be shut down

So users need to start and then stop postgres on the base backup
directory in order to run pg_checksums on it. This is due to this check
in pg_checksums.c:

if (ControlFile->state != DB_SHUTDOWNED &&
ControlFile->state != DB_SHUTDOWNED_IN_RECOVERY)
{
pg_log_error("cluster must be shut down");

I think we can allow checking of base backups if we make sure
backup_label exists in the data directory or am I missing something?
I think we need to have similar checks about pages changed during base
backup, so this patch ignores checksum failures between the checkpoint
LSN and (as a reasonable upper bound) the last LSN of the last existing
transaction log file. If no xlog files exist (the --wal-method=none
case), the last LSN of the checkpoint WAL segment is taken.

Michael

--
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax: +49 2166 9901-100
Email: michael(dot)banck(at)credativ(dot)de

credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Unser Umgang mit personenbezogenen Daten unterliegt
folgenden Bestimmungen: https://www.credativ.de/datenschutz

Attachment Content-Type Size
0001-Allow-checking-base-backups-in-pg_checksums.patch text/x-patch 6.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2020-04-06 11:39:03 Re: Make MemoryContextMemAllocated() more precise
Previous Message davinder singh 2020-04-06 11:07:57 PG compilation error with Visual Studio 2015/2017/2019