Skip to content

Commit

Permalink
Add --ignore-rsync-warning command line option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Cédric Villemain authored and Cédric Villemain committed Mar 28, 2011
1 parent e74e319 commit b30398b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 24 additions & 5 deletions repmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions repmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef struct
char wal_keep_segments[MAXLEN];
bool verbose;
bool force;
bool ignore_rsync_warn;

char masterport[MAXLEN];

Expand Down

0 comments on commit b30398b

Please sign in to comment.