Permalink
Browse files

Add a new standby_name parameter that, when provided in repmgr.conf,

is included in the primary_conninfo as application_name... This is
a simple first step towards making repmgr works fine with 9.1 and
sync standbys
  • Loading branch information...
1 parent 10817ec commit 020e17b0599dbc2bcdcf772dfaf994dc6b00b3e3 @Jaime2ndQuadrant Jaime2ndQuadrant committed Jul 26, 2011
Showing with 14 additions and 2 deletions.
  1. +4 −0 config.c
  2. +1 −0 config.h
  3. +8 −2 repmgr.c
  4. +1 −0 repmgr.conf.sample
View
@@ -37,6 +37,7 @@ parse_config(const char *config_file, t_configuration_options *options)
memset(options->conninfo, 0, sizeof(options->conninfo));
options->failover = MANUAL_FAILOVER;
options->priority = 0;
+ memset(options->standby_name, 0, sizeof(options->standby_name));
memset(options->promote_command, 0, sizeof(options->promote_command));
memset(options->follow_command, 0, sizeof(options->follow_command));
memset(options->rsync_options, 0, sizeof(options->rsync_options));
@@ -91,6 +92,8 @@ parse_config(const char *config_file, t_configuration_options *options)
}
else if (strcmp(name, "priority") == 0)
options->priority = atoi(value);
+ else if (strcmp(name, "standby_name") == 0)
+ strncpy(options->standby_name, value, MAXLEN);
else if (strcmp(name, "promote_command") == 0)
strncpy(options->promote_command, value, MAXLEN);
else if (strcmp(name, "follow_command") == 0)
@@ -221,6 +224,7 @@ reload_configuration(char *config_file, t_configuration_options *orig_options)
strcpy(orig_options->conninfo, new_options.conninfo);
orig_options->failover = new_options.failover;
orig_options->priority = new_options.priority;
+ strcpy(orig_options->standby_name, new_options.standby_name);
strcpy(orig_options->promote_command, new_options.promote_command);
strcpy(orig_options->follow_command, new_options.follow_command);
strcpy(orig_options->rsync_options, new_options.rsync_options);
View
@@ -30,6 +30,7 @@ typedef struct
char conninfo[MAXLEN];
int failover;
int priority;
+ char standby_name[MAXLEN];
char promote_command[MAXLEN];
char follow_command[MAXLEN];
char loglevel[MAXLEN];
View
@@ -2065,6 +2065,7 @@ write_primary_conninfo(char* line)
char host_buf[MAXLEN] = "";
char conn_buf[MAXLEN] = "";
char user_buf[MAXLEN] = "";
+ char appname_buff[MAXLEN] = "";
char password_buf[MAXLEN] = "";
/* Environment variable for password (UGLY, please use .pgpass!) */
@@ -2086,8 +2087,13 @@ write_primary_conninfo(char* line)
maxlen_snprintf(user_buf, " user=%s", runtime_options.username);
}
- maxlen_snprintf(conn_buf, "port=%s%s%s%s",
- (runtime_options.masterport[0]) ? runtime_options.masterport : "5432", host_buf, user_buf, password_buf);
+ if (options.standby_name[0]) {
+ maxlen_snprintf(appname_buff, " application_name=%s", options.standby_name);
+ }
+
+ maxlen_snprintf(conn_buf, "port=%s%s%s%s%s",
+ (runtime_options.masterport[0]) ? runtime_options.masterport : "5432", host_buf, user_buf, password_buf,
+ appname_buf);
maxlen_snprintf(line, "primary_conninfo = '%s'", conn_buf);
View
@@ -7,6 +7,7 @@ cluster=test
# Node ID
node=2
+standby_name=standby2
# Connection information
conninfo='host=192.168.204.104'

0 comments on commit 020e17b

Please sign in to comment.