Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit b30398bf2a4fd189001275e78d30746c9d4520ba 1 parent e74e319
@klando klando authored
Showing with 27 additions and 5 deletions.
  1. +2 −0  HISTORY
  2. +24 −5 repmgr.c
  3. +1 −0  repmgr.h
View
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)
View
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"),
View
1  repmgr.h
@@ -55,6 +55,7 @@ typedef struct
char wal_keep_segments[MAXLEN];
bool verbose;
bool force;
+ bool ignore_rsync_warn;
char masterport[MAXLEN];
Please sign in to comment.
Something went wrong with that request. Please try again.