@@ -511,14 +511,18 @@ catchup_multithreaded_copy(int num_threads,
511
511
threads = (pthread_t * ) palloc (sizeof (pthread_t ) * num_threads );
512
512
for (i = 0 ; i < num_threads ; i ++ )
513
513
{
514
- elog (VERBOSE , "Start thread num: %i" , i );
515
- pthread_create (& threads [i ], NULL , & catchup_thread_runner , & (threads_args [i ]));
514
+ if (!dry_run )
515
+ {
516
+ elog (VERBOSE , "Start thread num: %i" , i );
517
+ pthread_create (& threads [i ], NULL , & catchup_thread_runner , & (threads_args [i ]));
518
+ }
516
519
}
517
520
518
521
/* Wait threads */
519
522
for (i = 0 ; i < num_threads ; i ++ )
520
523
{
521
- pthread_join (threads [i ], NULL );
524
+ if (!dry_run )
525
+ pthread_join (threads [i ], NULL );
522
526
all_threads_successful &= threads_args [i ].completed ;
523
527
transfered_bytes_result += threads_args [i ].transfered_bytes ;
524
528
}
@@ -714,6 +718,8 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
714
718
start_WAL_streaming (source_conn , dest_xlog_path , & instance_config .conn_opt ,
715
719
current .start_lsn , current .tli , false);
716
720
}
721
+ else
722
+ elog (INFO , "WAL streaming cannot be started with --dry-run option" );
717
723
718
724
source_filelist = parray_new ();
719
725
@@ -784,9 +790,9 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
784
790
785
791
/* Build the page map from ptrack information */
786
792
make_pagemap_from_ptrack_2 (source_filelist , source_conn ,
787
- source_node_info .ptrack_schema ,
788
- source_node_info .ptrack_version_num ,
789
- dest_redo .lsn );
793
+ source_node_info .ptrack_schema ,
794
+ source_node_info .ptrack_version_num ,
795
+ dest_redo .lsn );
790
796
time (& end_time );
791
797
elog (INFO , "Pagemap successfully extracted, time elapsed: %.0f sec" ,
792
798
difftime (end_time , start_time ));
@@ -909,7 +915,7 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
909
915
*/
910
916
if (current .backup_mode != BACKUP_MODE_FULL )
911
917
{
912
- elog (INFO , "Redundant files %s in destination directory" , dry_run ? "can" : "will" );
918
+ elog (INFO , "Redundant files in destination directory %s be removed " , dry_run ? "can" : "will" );
913
919
parray_qsort (dest_filelist , pgFileCompareRelPathWithExternalDesc );
914
920
for (i = 0 ; i < parray_num (dest_filelist ); i ++ )
915
921
{
@@ -945,8 +951,7 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
945
951
}
946
952
947
953
/* shrink dest pgdata list */
948
- if (!dry_run )
949
- pgFileFree (file );
954
+ pgFileFree (file );
950
955
parray_remove (dest_filelist , i );
951
956
i -- ;
952
957
}
@@ -963,17 +968,14 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
963
968
if (dest_filelist )
964
969
parray_qsort (dest_filelist , pgFileCompareRelPathWithExternal );
965
970
966
- if (!dry_run )
967
- {
968
- /* run copy threads */
969
- elog (INFO , "Start transferring data files" );
970
- time (& start_time );
971
- transfered_datafiles_bytes = catchup_multithreaded_copy (num_threads , & source_node_info ,
972
- source_pgdata , dest_pgdata ,
973
- source_filelist , dest_filelist ,
974
- dest_redo .lsn , current .backup_mode );
975
- catchup_isok = transfered_datafiles_bytes != -1 ;
976
- }
971
+ /* run copy threads */
972
+ elog (INFO , "Transferring data files %s started" , dry_run ? "can be" : "" );
973
+ time (& start_time );
974
+ transfered_datafiles_bytes = catchup_multithreaded_copy (num_threads , & source_node_info ,
975
+ source_pgdata , dest_pgdata ,
976
+ source_filelist , dest_filelist ,
977
+ dest_redo .lsn , current .backup_mode );
978
+ catchup_isok = transfered_datafiles_bytes != -1 ;
977
979
978
980
/* at last copy control file */
979
981
if (catchup_isok && !dry_run )
@@ -1101,7 +1103,7 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
1101
1103
pretty_size (transfered_datafiles_bytes , pretty_transfered_data_bytes , lengthof (pretty_transfered_data_bytes ));
1102
1104
pretty_size (transfered_walfiles_bytes , pretty_transfered_wal_bytes , lengthof (pretty_transfered_wal_bytes ));
1103
1105
1104
- elog (INFO , "Databases %s synchronized. Transfered datafiles size : %s, transfered wal size: %s, time elapsed: %s" ,
1106
+ elog (INFO , "Databases %s synchronized. Transfered datafiles sizes : %s, transfered wal size: %s, time elapsed: %s" ,
1105
1107
dry_run ? "can be" : "was" ,
1106
1108
pretty_transfered_data_bytes , pretty_transfered_wal_bytes , pretty_time );
1107
1109
@@ -1112,14 +1114,10 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
1112
1114
}
1113
1115
1114
1116
/* Sync all copied files unless '--no-sync' flag is used */
1115
- if (!dry_run )
1116
- {
1117
- /* Sync all copied files unless '--no-sync' flag is used */
1118
- if (sync_dest_files )
1119
- catchup_sync_destination_files (dest_pgdata , FIO_LOCAL_HOST , source_filelist , source_pg_control_file );
1120
- else
1121
- elog (WARNING , "Files are not synced to disk" );
1122
- }
1117
+ if (sync_dest_files && !dry_run )
1118
+ catchup_sync_destination_files (dest_pgdata , FIO_LOCAL_HOST , source_filelist , source_pg_control_file );
1119
+ else
1120
+ elog (WARNING , "Files are not synced to disk" );
1123
1121
1124
1122
/* Cleanup */
1125
1123
if (dest_filelist && !dry_run )
0 commit comments