Skip to content

Commit c5f0787

Browse files
committed
Fix. Pages read via SQL don't have checksum, so calculate it at the backup side. It's an arguable decision, but at least now we are able to test other possible issues.
1 parent 5947741 commit c5f0787

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/data.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
233233

234234
int try_again = 100;
235235
bool page_is_valid = false;
236-
236+
BlockNumber absolute_blknum = file->segno * RELSEG_SIZE + blknum;
237+
237238
/*
238239
* Read the page and verify its header and checksum.
239240
* Under high write load it's possible that we've read partly
@@ -263,22 +264,26 @@ backup_data_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
263264
(backup_mode == BACKUP_MODE_DIFF_PTRACK))
264265
{
265266
size_t page_size = 0;
267+
PageHeader phdr = (PageHeader) page;
268+
266269
free(page);
267270
page = NULL;
268271

269-
page = (Page) pg_ptrack_get_block(file->tblspcOid, file->relOid, blknum, &page_size);
272+
page = (Page) pg_ptrack_get_block(file->tblspcOid, file->relOid, absolute_blknum, &page_size);
270273

271274
if (page == NULL)
272275
{
273276
elog(WARNING, "File %s, block %u, file was truncated",
274-
file->path, blknum);
277+
file->path, absolute_blknum);
275278
return;
276279
}
277280

278281
if (page_size != BLCKSZ)
279282
elog(ERROR, "File: %s, block %u, expected block size %lu,"
280283
"but read %d, try again",
281-
file->path, blknum, page_size, BLCKSZ);
284+
file->path, absolute_blknum, page_size, BLCKSZ);
285+
286+
((PageHeader) page)->pd_checksum = pg_checksum_page(page, absolute_blknum);
282287
}
283288

284289

0 commit comments

Comments
 (0)