Skip to content

Commit e865c83

Browse files
committed
fix destination file existance
1 parent 861ddd3 commit e865c83

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/catchup.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ do_catchup_instance(const char *source_pgdata, const char *dest_pgdata, PGconn *
389389
}
390390

391391
/*
392-
* Make directories before catchup and setup threads at the same time
392+
* Make directories before catchup
393393
*/
394394
/*
395395
* We iterate over source_filelist and for every directory with parent 'pg_tblspc'
@@ -541,7 +541,11 @@ do_catchup_instance(const char *source_pgdata, const char *dest_pgdata, PGconn *
541541
pfilearray_clear_locks(source_filelist);
542542

543543
/* Sort by size for load balancing */
544-
parray_qsort(source_filelist, pgFileCompareSize);
544+
parray_qsort(source_filelist, pgFileCompareSizeDesc);
545+
546+
/* Sort the array for binary search */
547+
if (dest_filelist)
548+
parray_qsort(dest_filelist, pgFileCompareRelPathWithExternal);
545549

546550
/* init thread args */
547551
threads = (pthread_t *) palloc(sizeof(pthread_t) * num_threads);
@@ -653,9 +657,6 @@ do_catchup_instance(const char *source_pgdata, const char *dest_pgdata, PGconn *
653657
stop_backup_result.tablespace_map_content_len = 0;
654658
}
655659

656-
//REVIEW We don't pass a filelist. Please adjust the comment.
657-
/* This function will also add list of xlog files
658-
* to the passed filelist */
659660
if(wait_WAL_streaming_end(NULL))
660661
elog(ERROR, "WAL streaming failed");
661662

src/data.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,12 +717,15 @@ catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpa
717717
else
718718
use_pagemap = true;
719719

720+
if (use_pagemap)
721+
elog(VERBOSE, "Using pagemap for file \"%s\"", file->rel_path);
722+
720723
/* Remote mode */
721724
if (fio_is_remote(FIO_DB_HOST))
722725
{
723726
rc = fio_copy_pages(to_fullpath, from_fullpath, file,
724727
/* send prev backup START_LSN */
725-
backup_mode == BACKUP_MODE_DIFF_DELTA &&
728+
(backup_mode == BACKUP_MODE_DIFF_DELTA || backup_mode == BACKUP_MODE_DIFF_PTRACK) &&
726729
file->exists_in_prev ? prev_backup_start_lsn : InvalidXLogRecPtr,
727730
calg, clevel, checksum_version,
728731
/* send pagemap if any */
@@ -735,7 +738,7 @@ catchup_data_file(pgFile *file, const char *from_fullpath, const char *to_fullpa
735738
/* TODO: stop handling errors internally */
736739
rc = copy_pages(to_fullpath, from_fullpath, file,
737740
/* send prev backup START_LSN */
738-
backup_mode == BACKUP_MODE_DIFF_DELTA &&
741+
(backup_mode == BACKUP_MODE_DIFF_DELTA || backup_mode == BACKUP_MODE_DIFF_PTRACK) &&
739742
file->exists_in_prev ? prev_backup_start_lsn : InvalidXLogRecPtr,
740743
checksum_version, use_pagemap,
741744
backup_mode, ptrack_version_num, ptrack_schema);

src/dir.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,13 @@ pgFileCompareSize(const void *f1, const void *f2)
485485
return 0;
486486
}
487487

488+
/* Compare two pgFile with their size in descending order */
489+
int
490+
pgFileCompareSizeDesc(const void *f1, const void *f2)
491+
{
492+
return -1 * pgFileCompareSize(f1, f2);
493+
}
494+
488495
static int
489496
pgCompareString(const void *str1, const void *str2)
490497
{

src/pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ extern int pgFileCompareRelPathWithExternal(const void *f1, const void *f2);
10861086
extern int pgFileCompareRelPathWithExternalDesc(const void *f1, const void *f2);
10871087
extern int pgFileCompareLinked(const void *f1, const void *f2);
10881088
extern int pgFileCompareSize(const void *f1, const void *f2);
1089+
extern int pgFileCompareSizeDesc(const void *f1, const void *f2);
10891090
extern int pgCompareOid(const void *f1, const void *f2);
10901091
extern void pfilearray_clear_locks(parray *file_list);
10911092

0 commit comments

Comments
 (0)