@@ -849,7 +849,7 @@ merge_files(void *arg)
849849 goto done ;
850850
851851 if (progress )
852- elog (INFO , "Progress: (%d/%lu). Process file \"%s\"" ,
852+ elog (INFO , "Progress: (%d/%lu). Merging file \"%s\"" ,
853853 i + 1 , (unsigned long ) parray_num (arguments -> dest_backup -> files ), dest_file -> rel_path );
854854
855855 if (dest_file -> is_datafile && !dest_file -> is_cfs )
@@ -1111,14 +1111,28 @@ merge_data_file(parray *parent_chain, pgBackup *full_backup,
11111111 dest_backup -> compress_alg , dest_backup -> compress_level ,
11121112 dest_backup -> checksum_version , 0 , NULL , false);
11131113
1114+ /* drop restored temp file */
1115+ if (unlink (to_fullpath_tmp1 ) == -1 )
1116+ elog (ERROR , "Cannot remove file \"%s\": %s" , to_fullpath_tmp1 ,
1117+ strerror (errno ));
1118+
11141119 /*
11151120 * In old (=<2.2.7) versions of pg_probackup n_blocks attribute of files
11161121 * in PAGE and PTRACK wasn`t filled.
11171122 */
1118- // Assert(tmp_file->n_blocks == dest_file->n_blocks);
1123+ //Assert(tmp_file->n_blocks == dest_file->n_blocks);
1124+
1125+ /* Backward compatibility kludge:
1126+ * When merging old backups, it is possible that
1127+ * to_fullpath_tmp2 size will be 0, and so it will be
1128+ * truncated in backup_data_file().
1129+ * TODO: remove in 3.0.0
1130+ */
1131+ if (tmp_file -> write_size == 0 )
1132+ return ;
11191133
11201134 if (fio_sync (to_fullpath_tmp2 , FIO_BACKUP_HOST ) != 0 )
1121- elog (ERROR , "Cannot fsync merge temp file \"%s\": %s" ,
1135+ elog (ERROR , "Cannot sync merge temp file \"%s\": %s" ,
11221136 to_fullpath_tmp2 , strerror (errno ));
11231137
11241138 /* Do atomic rename from second temp file to destination file */
@@ -1223,7 +1237,7 @@ merge_non_data_file(parray *parent_chain, pgBackup *full_backup,
12231237
12241238 /* TODO: --no-sync support */
12251239 if (fio_sync (to_fullpath_tmp , FIO_BACKUP_HOST ) != 0 )
1226- elog (ERROR , "Cannot fsync merge temp file \"%s\": %s" ,
1240+ elog (ERROR , "Cannot sync merge temp file \"%s\": %s" ,
12271241 to_fullpath_tmp , strerror (errno ));
12281242
12291243 /* Do atomic rename from second temp file to destination file */
0 commit comments