mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-12-13 11:53:59 +02:00
Check page checksums for all pages of remote delta backup
This commit is contained in:
parent
9c27c4d928
commit
89c01d20c3
14
src/data.c
14
src/data.c
@ -266,14 +266,22 @@ read_page_from_file(pgFile *file, BlockNumber blknum,
|
||||
}
|
||||
|
||||
/* Verify checksum */
|
||||
if (current.checksum_version && read_len == BLCKSZ)
|
||||
if (current.checksum_version)
|
||||
{
|
||||
BlockNumber blkno = file->segno * RELSEG_SIZE + blknum;
|
||||
uint16 page_crc = read_len == BLCKSZ
|
||||
? pg_checksum_page(page, blkno)
|
||||
/*
|
||||
* Recompute Cpage checksum calculated by agent with blkno=0
|
||||
* pg_checksum_page is calculating it in this way:
|
||||
* (((checksum ^ blkno) % 65535) + 1)
|
||||
*/
|
||||
: (uint16)(((*(uint16*)((PageHeader)page)->pd_linp - 1) ^ blkno) + 1);
|
||||
/*
|
||||
* If checksum is wrong, sleep a bit and then try again
|
||||
* several times. If it didn't help, throw error
|
||||
*/
|
||||
if (pg_checksum_page(page, file->segno * RELSEG_SIZE + blknum)
|
||||
!= ((PageHeader) page)->pd_checksum)
|
||||
if (page_crc != ((PageHeader) page)->pd_checksum)
|
||||
{
|
||||
elog(WARNING, "File: %s blknum %u have wrong checksum, try again",
|
||||
file->path, blknum);
|
||||
|
@ -338,8 +338,13 @@ main(int argc, char *argv[])
|
||||
}
|
||||
canonicalize_path(backup_path);
|
||||
|
||||
MyLocation = IsSshProtocol()
|
||||
? backup_subcmd == ARCHIVE_PUSH_CMD
|
||||
? FIO_DB_HOST : FIO_BACKUP_HOST
|
||||
: FIO_LOCAL_HOST;
|
||||
|
||||
/* Ensure that backup_path is a path to a directory */
|
||||
rc = stat(backup_path, &stat_buf);
|
||||
rc = fio_stat(backup_path, &stat_buf, true, FIO_BACKUP_HOST);
|
||||
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
|
||||
elog(ERROR, "-B, --backup-path must be a path to directory");
|
||||
|
||||
@ -356,11 +361,6 @@ main(int argc, char *argv[])
|
||||
elog(ERROR, "required parameter not specified: --instance");
|
||||
}
|
||||
|
||||
MyLocation = IsSshProtocol()
|
||||
? backup_subcmd == ARCHIVE_PUSH_CMD
|
||||
? FIO_DB_HOST : FIO_BACKUP_HOST
|
||||
: FIO_LOCAL_HOST;
|
||||
|
||||
/*
|
||||
* If --instance option was passed, construct paths for backup data and
|
||||
* xlog files of this backup instance.
|
||||
@ -378,7 +378,7 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
if (backup_subcmd != INIT_CMD && backup_subcmd != ADD_INSTANCE_CMD)
|
||||
{
|
||||
if (access(backup_instance_path, F_OK) != 0)
|
||||
if (fio_access(backup_instance_path, F_OK, FIO_BACKUP_HOST) != 0)
|
||||
elog(ERROR, "Instance '%s' does not exist in this backup catalog",
|
||||
instance_name);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "pg_probackup.h"
|
||||
#include "storage/checksum.h"
|
||||
#include "file.h"
|
||||
|
||||
#define PRINTF_BUF_SIZE 1024
|
||||
@ -884,9 +885,12 @@ void fio_communicate(int in, int out)
|
||||
? PageXLogRecPtrGet(((PageHeader)buf)->pd_lsn) < horizon_lsn /* For non-delta backup horizon_lsn == 0, so this condition is always false */
|
||||
? sizeof(PageHeaderData) : BLCKSZ
|
||||
: 0;
|
||||
IO_CHECK(fio_write_all(out, &hdr, sizeof(hdr)), sizeof(hdr));
|
||||
if (hdr.size == sizeof(PageHeaderData))
|
||||
/* calculate checksum without XOR-ing with block number to compare it with page CRC at master */
|
||||
*(int16*)((PageHeader)buf)->pd_linp = pg_checksum_page(buf, 0);
|
||||
IO_CHECK(fio_write_all(out, &hdr, sizeof(hdr)), sizeof(hdr));
|
||||
if (hdr.size != 0)
|
||||
IO_CHECK(fio_write_all(out, buf, hdr.size), hdr.size);
|
||||
IO_CHECK(fio_write_all(out, buf, hdr.size), hdr.size);
|
||||
break;
|
||||
case FIO_FSTAT: /* Get information about opened file */
|
||||
hdr.size = sizeof(st);
|
||||
|
@ -52,12 +52,12 @@ static int split_options(int argc, char* argv[], int max_options, char* options)
|
||||
}
|
||||
|
||||
static int child_pid;
|
||||
|
||||
#if 0
|
||||
static void kill_child(void)
|
||||
{
|
||||
kill(child_pid, SIGTERM);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool launch_agent(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user