@@ -532,23 +532,19 @@ merge_chain(parray *parent_chain, pgBackup *full_backup, pgBackup *dest_backup)
532532 * If current program version differs from destination backup version,
533533 * then in-place merge is not possible.
534534 */
535- if (parse_program_version (dest_backup -> program_version ) ==
536- parse_program_version (PROGRAM_VERSION ))
535+ if ((parse_program_version (full_backup -> program_version ) ==
536+ parse_program_version (dest_backup -> program_version )) &&
537+ (parse_program_version (dest_backup -> program_version ) ==
538+ parse_program_version (PROGRAM_VERSION )))
537539 program_version_match = true;
538540 else
539541 elog (WARNING , "In-place merge is disabled because of program "
540- "versions mismatch: backup %s was produced by version %s, "
541- "but current program version is %s" ,
542- base36enc (dest_backup -> start_time ),
543- dest_backup -> program_version , PROGRAM_VERSION );
544-
545- /* Construct path to database dir: /backup_dir/instance_name/FULL/database */
546- join_path_components (full_database_dir , full_backup -> root_dir , DATABASE_DIR );
547- /* Construct path to external dir: /backup_dir/instance_name/FULL/external */
548- join_path_components (full_external_prefix , full_backup -> root_dir , EXTERNAL_DIR );
549-
550- elog (INFO , "Validate parent chain for backup %s" ,
551- base36enc (dest_backup -> start_time ));
542+ "versions mismatch. Full backup version: %s, "
543+ "destination backup version: %s, "
544+ "current program version: %s" ,
545+ full_backup -> program_version ,
546+ dest_backup -> program_version ,
547+ PROGRAM_VERSION );
552548
553549 /* Forbid merge retry for failed merges between 2.4.0 and any
554550 * older version. Several format changes makes it impossible
@@ -568,6 +564,9 @@ merge_chain(parray *parent_chain, pgBackup *full_backup, pgBackup *dest_backup)
568564 * with sole exception of FULL backup. If it has MERGING status
569565 * then it isn't valid backup until merging is finished.
570566 */
567+ elog (INFO , "Validate parent chain for backup %s" ,
568+ base36enc (dest_backup -> start_time ));
569+
571570 for (i = parray_num (parent_chain ) - 1 ; i >= 0 ; i -- )
572571 {
573572 pgBackup * backup = (pgBackup * ) parray_get (parent_chain , i );
@@ -611,6 +610,11 @@ merge_chain(parray *parent_chain, pgBackup *full_backup, pgBackup *dest_backup)
611610 write_backup_status (backup , BACKUP_STATUS_MERGING , instance_name , true);
612611 }
613612
613+ /* Construct path to database dir: /backup_dir/instance_name/FULL/database */
614+ join_path_components (full_database_dir , full_backup -> root_dir , DATABASE_DIR );
615+ /* Construct path to external dir: /backup_dir/instance_name/FULL/external */
616+ join_path_components (full_external_prefix , full_backup -> root_dir , EXTERNAL_DIR );
617+
614618 /* Create directories */
615619 create_data_directories (dest_backup -> files , full_database_dir ,
616620 dest_backup -> root_dir , false, false, FIO_BACKUP_HOST );
@@ -627,6 +631,7 @@ merge_chain(parray *parent_chain, pgBackup *full_backup, pgBackup *dest_backup)
627631 if (full_externals && dest_externals )
628632 reorder_external_dirs (full_backup , full_externals , dest_externals );
629633
634+ /* bitmap optimization rely on n_blocks, which is generally available since 2.3.0 */
630635 if (parse_program_version (dest_backup -> program_version ) < 20300 )
631636 use_bitmap = false;
632637
@@ -981,7 +986,8 @@ merge_files(void *arg)
981986 * In-place merge is also impossible, if program version of destination
982987 * backup differs from PROGRAM_VERSION
983988 */
984- if (arguments -> program_version_match && arguments -> compression_match )
989+ if (arguments -> program_version_match && arguments -> compression_match &&
990+ !arguments -> is_retry )
985991 {
986992 /*
987993 * Case 1:
@@ -1049,7 +1055,7 @@ merge_files(void *arg)
10491055 * page header map cannot be trusted when retrying, so no
10501056 * in place merge for retry.
10511057 */
1052- if (in_place && ! arguments -> is_retry )
1058+ if (in_place )
10531059 {
10541060 pgFile * * res_file = NULL ;
10551061 pgFile * file = NULL ;
0 commit comments