@@ -829,6 +829,8 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
829829
830830 if (write_header )
831831 {
832+ /* We uncompressed the page, so its size is BLCKSZ */
833+ header .compressed_size = BLCKSZ ;
832834 if (fwrite (& header , 1 , sizeof (header ), out ) != sizeof (header ))
833835 elog (ERROR , "cannot write header of block %u of \"%s\": %s" ,
834836 blknum , file -> path , strerror (errno ));
@@ -1592,19 +1594,23 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
15921594 if (read_len == 0 && feof (in ))
15931595 break ; /* EOF found */
15941596 else if (read_len != 0 && feof (in ))
1595- elog (ERROR ,
1597+ elog (WARNING ,
15961598 "odd size page found at block %u of \"%s\"" ,
15971599 blknum , file -> path );
15981600 else
1599- elog (ERROR , "cannot read header of block %u of \"%s\": %s" ,
1601+ elog (WARNING , "cannot read header of block %u of \"%s\": %s" ,
16001602 blknum , file -> path , strerror (errno_tmp ));
1603+ return false;
16011604 }
16021605
16031606 COMP_FILE_CRC32 (use_crc32c , crc , & header , read_len );
16041607
16051608 if (header .block < blknum )
1606- elog (ERROR , "backup is broken at file->path %s block %u" ,
1609+ {
1610+ elog (WARNING , "backup is broken at file->path %s block %u" ,
16071611 file -> path , blknum );
1612+ return false;
1613+ }
16081614
16091615 blknum = header .block ;
16101616
@@ -1620,8 +1626,11 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
16201626 read_len = fread (compressed_page .data , 1 ,
16211627 MAXALIGN (header .compressed_size ), in );
16221628 if (read_len != MAXALIGN (header .compressed_size ))
1623- elog (ERROR , "cannot read block %u of \"%s\" read %zu of %d" ,
1629+ {
1630+ elog (WARNING , "cannot read block %u of \"%s\" read %zu of %d" ,
16241631 blknum , file -> path , read_len , header .compressed_size );
1632+ return false;
1633+ }
16251634
16261635 COMP_FILE_CRC32 (use_crc32c , crc , compressed_page .data , read_len );
16271636
@@ -1648,11 +1657,13 @@ check_file_pages(pgFile *file, XLogRecPtr stop_lsn, uint32 checksum_version,
16481657 is_valid = false;
16491658 continue ;
16501659 }
1651- elog (ERROR , "page of file \"%s\" uncompressed to %d bytes. != BLCKSZ" ,
1660+ elog (WARNING , "page of file \"%s\" uncompressed to %d bytes. != BLCKSZ" ,
16521661 file -> path , uncompressed_size );
1662+ return false;
16531663 }
1664+
16541665 if (validate_one_page (page .data , file , blknum ,
1655- stop_lsn , checksum_version ) == PAGE_IS_FOUND_AND_NOT_VALID )
1666+ stop_lsn , checksum_version ) == PAGE_IS_FOUND_AND_NOT_VALID )
16561667 is_valid = false;
16571668 }
16581669 else
0 commit comments