@@ -60,6 +60,7 @@ backup_data_page(pgFile *file, const XLogRecPtr *lsn,
6060XLogRecPtr page_lsn ;
6161int ret ;
6262int try_checksum = 100 ;
63+ struct stat st ;
6364
6465header .block = blknum ;
6566offset = blknum * BLCKSZ ;
@@ -72,9 +73,22 @@ backup_data_page(pgFile *file, const XLogRecPtr *lsn,
7273(long long unsignedint )offset ,ret );
7374
7475read_len = fread (& page ,1 ,sizeof (page ),in );
76+
7577if (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" ,
7790file -> 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,
187201stat (file -> path ,& st );
188202
189203if (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" ,
191205file -> path ,file -> size );
192206
193207if (file -> size %BLCKSZ != 0 )
@@ -456,8 +470,6 @@ restore_data_file(const char *from_root,
456470{
457471size_t read_len ;
458472DataPage page ;/* used as read buffer */
459- int upper_offset ;
460- int upper_length ;
461473
462474/* read BackupPageHeader */
463475read_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.