mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Add --ignore-rsync-warning command line option
This fix the rsync return code in case there are vanished files. Common situation are DROPed tables and TEMPorary object deletion and are handled by PostgreSQL. But as it may exist situation where an external process delete files in the PGDATA the flag is off by default. XXX 2 items : * is -I a good choice ? maybe we need to prevent future --ignore-foo and add something like : --ignore=rsync_warning -I rsync_warning * the warning message is not enough explicit with the risk involved by --force usage
This commit is contained in:
2
HISTORY
2
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)
|
||||
|
||||
29
repmgr.c
29
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"));
|
||||
@@ -1475,13 +1480,27 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
|
||||
|
||||
/*
|
||||
* If we are transfering a directory (ie: data directory, tablespace directories)
|
||||
* then we can ignore some rsync errors, so if we get some of those errors we
|
||||
* treat them as 0
|
||||
* 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 (is_directory && (r == 24))
|
||||
r = 0;
|
||||
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"),
|
||||
|
||||
Reference in New Issue
Block a user