Skip to content

Commit bed0a45

Browse files
committed
minor bugfix: dissapeared during backup files were marked as 'not changed', now such files are removed from backup_list at the end of the backup
1 parent 10b8db3 commit bed0a45

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/backup.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,19 @@ do_backup_instance(void)
763763
else
764764
elog(ERROR, "Data files transferring failed");
765765

766+
/* Remove disappeared during backup files from backup_list */
767+
for (i = 0; i < parray_num(backup_files_list); i++)
768+
{
769+
pgFile *tmp_file = (pgFile *) parray_get(backup_files_list, i);
770+
771+
if (tmp_file->write_size == FILE_NOT_FOUND)
772+
{
773+
pg_atomic_clear_flag(&tmp_file->lock);
774+
pgFileFree(tmp_file);
775+
parray_remove(backup_files_list, i);
776+
}
777+
}
778+
766779
/* clean previous backup file list */
767780
if (prev_backup_filelist)
768781
{
@@ -2241,7 +2254,7 @@ backup_files(void *arg)
22412254
* If file is not found, this is not en error.
22422255
* It could have been deleted by concurrent postgres transaction.
22432256
*/
2244-
file->write_size = BYTES_INVALID;
2257+
file->write_size = FILE_NOT_FOUND;
22452258
elog(LOG, "File \"%s\" is not found", file->path);
22462259
continue;
22472260
}
@@ -2291,7 +2304,9 @@ backup_files(void *arg)
22912304
instance_config.compress_alg,
22922305
instance_config.compress_level))
22932306
{
2294-
file->write_size = BYTES_INVALID;
2307+
/* disappeared file not to be confused with 'not changed' */
2308+
if (file->write_size != FILE_NOT_FOUND)
2309+
file->write_size = BYTES_INVALID;
22952310
elog(VERBOSE, "File \"%s\" was not copied to backup", file->path);
22962311
continue;
22972312
}
@@ -2315,7 +2330,9 @@ backup_files(void *arg)
23152330
if (skip ||
23162331
!copy_file(arguments->from_root, arguments->to_root, file))
23172332
{
2318-
file->write_size = BYTES_INVALID;
2333+
/* disappeared file not to be confused with 'not changed' */
2334+
if (file->write_size != FILE_NOT_FOUND)
2335+
file->write_size = BYTES_INVALID;
23192336
elog(VERBOSE, "File \"%s\" was not copied to backup",
23202337
file->path);
23212338
continue;

src/data.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ backup_data_file(backup_files_arg* arguments,
564564
if (errno == ENOENT)
565565
{
566566
elog(LOG, "File \"%s\" is not found", file->path);
567+
file->write_size = FILE_NOT_FOUND;
567568
return false;
568569
}
569570

@@ -946,7 +947,11 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
946947

947948
/* maybe deleted, it's not error */
948949
if (errno == ENOENT)
950+
{
951+
elog(LOG, "File \"%s\" is not found", file->path);
952+
file->write_size = FILE_NOT_FOUND;
949953
return false;
954+
}
950955

951956
elog(ERROR, "cannot open source file \"%s\": %s", file->path,
952957
strerror(errno));

src/pg_probackup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ typedef enum ShowFormat
165165

166166
/* special values of pgBackup fields */
167167
#define INVALID_BACKUP_ID 0 /* backup ID is not provided by user */
168-
#define BYTES_INVALID (-1)
168+
#define BYTES_INVALID (-1) /* file didn`t changed since previous backup, DELTA backup do not rely on it */
169+
#define FILE_NOT_FOUND (-2) /* file disappeared during backup */
169170
#define BLOCKNUM_INVALID (-1)
170171

171172
/*

0 commit comments

Comments
 (0)