@@ -268,7 +268,7 @@ get_checksum_errormsg(Page page, char **errormsg, BlockNumber absolute_blkno)
268
268
* PageIsOk(0) if page was successfully retrieved
269
269
* PageIsTruncated(-1) if the page was truncated
270
270
* SkipCurrentPage(-2) if we need to skip this page,
271
- * only used for DELTA backup
271
+ * only used for DELTA and PTRACK backup
272
272
* PageIsCorrupted(-3) if the page checksum mismatch
273
273
* or header corruption,
274
274
* only used for checkdb
@@ -403,7 +403,12 @@ prepare_page(pgFile *file, XLogRecPtr prev_backup_start_lsn,
403
403
page_st -> lsn > 0 &&
404
404
page_st -> lsn < prev_backup_start_lsn )
405
405
{
406
- elog (VERBOSE , "Skipping blknum %u in file: \"%s\"" , blknum , from_fullpath );
406
+ elog (VERBOSE , "Skipping blknum %u in file: \"%s\", file->exists_in_prev: %s, page_st->lsn: %X/%X, prev_backup_start_lsn: %X/%X" ,
407
+ blknum , from_fullpath ,
408
+ file -> exists_in_prev ? "true" : "false" ,
409
+ (uint32 ) (page_st -> lsn >> 32 ), (uint32 ) page_st -> lsn ,
410
+ (uint32 ) (prev_backup_start_lsn >> 32 ), (uint32 ) prev_backup_start_lsn
411
+ );
407
412
return SkipCurrentPage ;
408
413
}
409
414
@@ -2255,7 +2260,7 @@ send_pages(ConnectionArgs* conn_arg, const char *to_fullpath, const char *from_f
2255
2260
/* copy local file (взята из send_pages, но используется простое копирование странички, без добавления заголовков и компрессии) */
2256
2261
int
2257
2262
copy_pages (const char * to_fullpath , const char * from_fullpath ,
2258
- pgFile * file , XLogRecPtr prev_backup_start_lsn ,
2263
+ pgFile * file , XLogRecPtr sync_lsn ,
2259
2264
uint32 checksum_version , bool use_pagemap ,
2260
2265
BackupMode backup_mode , int ptrack_version_num , const char * ptrack_schema )
2261
2266
{
@@ -2303,13 +2308,26 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
2303
2308
setvbuf (in , in_buf , _IOFBF , STDIO_BUFSIZE );
2304
2309
}
2305
2310
2306
- /* ошибки бы тут обработать! */
2307
- out = open_local_file_rw (to_fullpath , & out_buf , STDIO_BUFSIZE );
2311
+ out = fio_fopen (to_fullpath , PG_BINARY_R "+" , FIO_BACKUP_HOST );
2312
+ if (out == NULL )
2313
+ elog (ERROR , "Cannot open destination file \"%s\": %s" ,
2314
+ to_fullpath , strerror (errno ));
2315
+
2316
+ /* update file permission */
2317
+ if (fio_chmod (to_fullpath , file -> mode , FIO_BACKUP_HOST ) == -1 )
2318
+ elog (ERROR , "Cannot change mode of \"%s\": %s" , to_fullpath ,
2319
+ strerror (errno ));
2320
+
2321
+ if (!fio_is_remote_file (out ))
2322
+ {
2323
+ out_buf = pgut_malloc (STDIO_BUFSIZE );
2324
+ setvbuf (out , out_buf , _IOFBF , STDIO_BUFSIZE );
2325
+ }
2308
2326
2309
2327
while (blknum < file -> n_blocks )
2310
2328
{
2311
2329
PageState page_st ;
2312
- int rc = prepare_page (file , prev_backup_start_lsn ,
2330
+ int rc = prepare_page (file , sync_lsn ,
2313
2331
blknum , in , backup_mode , curr_page ,
2314
2332
true, checksum_version ,
2315
2333
ptrack_version_num , ptrack_schema ,
@@ -2318,7 +2336,14 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
2318
2336
break ;
2319
2337
2320
2338
else if (rc == PageIsOk )
2339
+ {
2340
+ if (fio_fseek (out , blknum * BLCKSZ ) < 0 )
2341
+ {
2342
+ elog (ERROR , "Cannot seek block %u of \"%s\": %s" ,
2343
+ blknum , to_fullpath , strerror (errno ));
2344
+ }
2321
2345
copy_page (file , blknum , in , out , curr_page , to_fullpath );
2346
+ }
2322
2347
2323
2348
n_blocks_read ++ ;
2324
2349
@@ -2339,8 +2364,8 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
2339
2364
to_fullpath , strerror (errno ));
2340
2365
2341
2366
/* close local output file */
2342
- if (out && fclose (out ))
2343
- elog (ERROR , "Cannot close the backup file \"%s\": %s" ,
2367
+ if (out && fio_fclose (out ))
2368
+ elog (ERROR , "Cannot close the destination file \"%s\": %s" ,
2344
2369
to_fullpath , strerror (errno ));
2345
2370
2346
2371
pg_free (iter );
0 commit comments