@@ -468,9 +468,6 @@ merge_files(void *arg)
468
468
char from_file_path [MAXPGPATH ];
469
469
char * prev_file_path ;
470
470
471
- if (!pg_atomic_test_set_flag (& file -> lock ))
472
- continue ;
473
-
474
471
/* check for interrupt */
475
472
if (interrupted || thread_interrupted )
476
473
elog (ERROR , "Interrupted during merging backups" );
@@ -479,6 +476,9 @@ merge_files(void *arg)
479
476
if (S_ISDIR (file -> mode ))
480
477
continue ;
481
478
479
+ if (!pg_atomic_test_set_flag (& file -> lock ))
480
+ continue ;
481
+
482
482
if (progress )
483
483
elog (INFO , "Progress: (%d/%d). Process file \"%s\"" ,
484
484
i + 1 , num_files , file -> path );
@@ -491,20 +491,28 @@ merge_files(void *arg)
491
491
492
492
/*
493
493
* Skip files which haven't changed since previous backup. But in case
494
- * of DELTA backup we should consider n_blocks to truncate the target
495
- * backup .
494
+ * of DELTA backup we must truncate the target file to n_blocks.
495
+ * Unless it is a non data file, in this case truncation is not needed .
496
496
*/
497
- if (file -> write_size == BYTES_INVALID && file -> n_blocks == BLOCKNUM_INVALID )
497
+ if (file -> write_size == BYTES_INVALID )
498
498
{
499
- elog (VERBOSE , "Skip merging file \"%s\", the file didn't change" ,
500
- file -> path );
501
-
502
- /*
503
- * If the file wasn't changed in PAGE backup, retreive its
504
- * write_size from previous FULL backup.
505
- */
506
- if (to_file )
499
+ /* sanity */
500
+ if (!to_file )
501
+ elog (ERROR , "The file \"%s\" is missing in FULL backup %s" ,
502
+ file -> rel_path , base36enc (to_backup -> start_time ));
503
+
504
+ /* for not changed files of all types in PAGE and PTRACK */
505
+ if (from_backup -> backup_mode != BACKUP_MODE_DIFF_DELTA ||
506
+ /* and not changed non-data files in DELTA */
507
+ (!file -> is_datafile || file -> is_cfs ))
507
508
{
509
+ elog (VERBOSE , "Skip merging file \"%s\", the file didn't change" ,
510
+ file -> path );
511
+
512
+ /*
513
+ * If the file wasn't changed, retreive its
514
+ * write_size and compression algorihtm from previous FULL backup.
515
+ */
508
516
file -> compress_alg = to_file -> compress_alg ;
509
517
file -> write_size = to_file -> write_size ;
510
518
@@ -516,9 +524,9 @@ merge_files(void *arg)
516
524
/* Otherwise just get it from the previous file */
517
525
else
518
526
file -> crc = to_file -> crc ;
519
- }
520
527
521
- continue ;
528
+ continue ;
529
+ }
522
530
}
523
531
524
532
/* We need to make full path, file object has relative path */
@@ -667,6 +675,8 @@ merge_files(void *arg)
667
675
if (file -> write_size != BYTES_INVALID )
668
676
elog (VERBOSE , "Merged file \"%s\": " INT64_FORMAT " bytes" ,
669
677
file -> path , file -> write_size );
678
+ else
679
+ elog (ERROR , "Merge of file \"%s\" failed. Invalid size: %i" , BYTES_INVALID );
670
680
671
681
/* Restore relative path */
672
682
file -> path = prev_file_path ;
0 commit comments