Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit547470a

Browse files
committed
check size of the file if block reading has failed
1 parentbe18e8d commit547470a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎data.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ backup_data_page(pgFile *file, const XLogRecPtr *lsn,
6060
XLogRecPtrpage_lsn;
6161
intret;
6262
inttry_checksum=100;
63+
structstatst;
6364

6465
header.block=blknum;
6566
offset=blknum*BLCKSZ;
@@ -72,9 +73,22 @@ backup_data_page(pgFile *file, const XLogRecPtr *lsn,
7273
(long long unsignedint)offset,ret);
7374

7475
read_len=fread(&page,1,sizeof(page),in);
76+
7577
if (read_len!=sizeof(page))
76-
elog(ERROR,"File: %s, block size of block %u of nblocks %u is incorrect %lu",
78+
{
79+
stat(file->path,&st);
80+
81+
if (st.st_size/BLCKSZ <=blknum)
82+
{
83+
elog(WARNING,"File: %s, file was truncated after backup start."
84+
"Expected nblocks %u. Real nblocks %ld. Cannot read block %u ",
85+
file->path,nblocks,st.st_size/BLCKSZ,blknum);
86+
return;
87+
}
88+
else
89+
elog(ERROR,"File: %s, block size of block %u of nblocks %u is incorrect %lu",
7790
file->path,blknum,nblocks,read_len);
91+
}
7892

7993
/*
8094
* If an invalid data page was found, fallback to simple copy to ensure
@@ -187,7 +201,7 @@ backup_data_file(const char *from_root, const char *to_root,
187201
stat(file->path,&st);
188202

189203
if (st.st_size<file->size)
190-
elog(ERROR,"File: %s, file was truncated after backup start. Expected size %lu",
204+
elog(WARNING,"File: %s, file was truncated after backup start. Expected size %lu",
191205
file->path,file->size);
192206

193207
if (file->size %BLCKSZ!=0)
@@ -456,8 +470,6 @@ restore_data_file(const char *from_root,
456470
{
457471
size_tread_len;
458472
DataPagepage;/* used as read buffer */
459-
intupper_offset;
460-
intupper_length;
461473

462474
/* read BackupPageHeader */
463475
read_len=fread(&header,1,sizeof(header),in);
@@ -502,8 +514,6 @@ restore_data_file(const char *from_root,
502514
((PageHeader)page.data)->pd_checksum=pg_checksum_page(page.data,file->segno*RELSEG_SIZE+header.block);
503515
}
504516

505-
skip_checksum:
506-
507517
/*
508518
* Seek and write the restored page. Backup might have holes in
509519
* differential backups.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp