diff --git a/HISTORY b/HISTORY index 3a6b8913..bb6ddadc 100644 --- a/HISTORY +++ b/HISTORY @@ -31,3 +31,5 @@ 1.1.0 2011-03-09 Make options -U, -R and -p not mandatory (Jaime) +X.X.X 2011-XX-XX + Add --ignore-rsync-warning (Cédric) diff --git a/repmgr.c b/repmgr.c index 05c095b3..607c869d 100644 --- a/repmgr.c +++ b/repmgr.c @@ -71,7 +71,7 @@ bool need_a_node = true; bool require_password = false; /* Initialization of runtime options */ -t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, "" }; +t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, "" }; t_configuration_options options = { "", -1, "", "", "" }; static char *server_mode = NULL; @@ -91,6 +91,7 @@ main(int argc, char **argv) {"remote-user", required_argument, NULL, 'R'}, {"wal-keep-segments", required_argument, NULL, 'w'}, {"force", no_argument, NULL, 'F'}, + {"ignore-rsync-warning", no_argument, NULL, 'I'}, {"verbose", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0} }; @@ -150,6 +151,9 @@ main(int argc, char **argv) case 'F': runtime_options.force = true; break; + case 'I': + runtime_options.ignore_rsync_warn = true; + break; case 'v': runtime_options.verbose = true; break; @@ -1337,6 +1341,7 @@ void help(const char *progname) printf(_(" -R, --remote-user=USERNAME database server username for rsync\n")); printf(_(" -w, --wal-keep-segments=VALUE minimum value for the GUC wal_keep_segments (default: 5000)\n")); printf(_(" -F, --force force potentially dangerous operations to happen\n")); + printf(_(" -I, --ignore-rsync-warning Ignore partial transfert warning\n")); printf(_("\n%s performs some tasks like clone a node, promote it "), progname); printf(_("or making follow another node and then exits.\n")); @@ -1473,6 +1478,30 @@ copy_remote_files(char *host, char *remote_user, char *remote_path, r = system(script); + /* + * If we are transfering a directory (ie: data directory, tablespace directories) + * then we can ignore some rsync warning, so if we get some of those errors we + * treat them as 0 if we have --ignore-rsync-warning commandline option set + * List of ignorable rsync errors: + * 24 Partial transfer due to vanished source files + */ + if ((r == 24) && is_directory) + { + if (!runtime_options.ignore_rsync_warn) + { + log_warning( _("\nrsync completed with return code 24 " + "\"Partial transfer due to vanished source files\".\n" + "This can happen because of normal operation " + "on the master server, but it may indicate an " + "issue during cloning. If you are certain no " + "changes were made to the master, try cloning " + "again using \"repmgr --force --ignore-rsync-warning\".")); + exit(ERR_BAD_RSYNC); + } + else + r = 0; + } + if (r != 0) log_err(_("Can't rsync from remote file or directory (%s:%s)\n"), host_string, remote_path); diff --git a/repmgr.h b/repmgr.h index c2c96fab..bd219692 100644 --- a/repmgr.h +++ b/repmgr.h @@ -55,6 +55,7 @@ typedef struct char wal_keep_segments[MAXLEN]; bool verbose; bool force; + bool ignore_rsync_warn; char masterport[MAXLEN];