Add new option pg_restore_command.

This can be used so that repmgr standby clone adds the string
specified in repmgr.conf as a restore_command in recovery.conf.

We can use this option for integration with barman by setting the
parameter to an appropriate get-wal call.
This commit is contained in:
Martin
2016-05-17 15:19:20 -03:00
parent c30609426a
commit cf46834041
4 changed files with 20 additions and 2 deletions

View File

@@ -224,6 +224,7 @@ parse_config(t_configuration_options *options)
memset(options->pg_bindir, 0, sizeof(options->pg_bindir));
memset(options->pg_ctl_options, 0, sizeof(options->pg_ctl_options));
memset(options->pg_basebackup_options, 0, sizeof(options->pg_basebackup_options));
memset(options->pg_restore_command, 0, sizeof(options->pg_restore_command));
/* default master_response_timeout is 60 seconds */
options->master_response_timeout = 60;
@@ -340,7 +341,8 @@ parse_config(t_configuration_options *options)
strncpy(options->follow_command, value, MAXLEN);
else if (strcmp(name, "master_response_timeout") == 0)
options->master_response_timeout = repmgr_atoi(value, "master_response_timeout", &config_errors, false);
/* 'primary_response_timeout' as synonym for 'master_response_timeout' -
/*
* 'primary_response_timeout' as synonym for 'master_response_timeout' -
* we'll switch terminology in a future release (3.1?)
*/
else if (strcmp(name, "primary_response_timeout") == 0)
@@ -372,6 +374,8 @@ parse_config(t_configuration_options *options)
parse_event_notifications_list(options, value);
else if (strcmp(name, "tablespace_mapping") == 0)
tablespace_list_append(options, value);
else if (strcmp(name, "pg_restore_command") == 0)
strncpy(options->pg_restore_command, value, MAXLEN);
else
{
known_parameter = false;

View File

@@ -72,6 +72,7 @@ typedef struct
char pg_bindir[MAXLEN];
char pg_ctl_options[MAXLEN];
char pg_basebackup_options[MAXLEN];
char pg_restore_command[MAXLEN];
char logfile[MAXLEN];
int monitor_interval_secs;
int retry_promote_interval_secs;
@@ -82,7 +83,7 @@ typedef struct
TablespaceList tablespace_mapping;
} t_configuration_options;
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, {NULL, NULL} }
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, {NULL, NULL} }
typedef struct ErrorListCell
{

View File

@@ -4219,6 +4219,15 @@ create_recovery_file(const char *data_dir)
log_debug(_("recovery.conf: %s"), line);
}
/* If pg_restore_command is set, we use it as resore_cmmand in recovery.conf */
if (strcmp(options.pg_restore_command, "") != 0)
{
maxlen_snprintf(line, "restore_command = '%s'\n",
options.pg_restore_command);
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
return false;
log_debug(_("recovery.conf: %s"), line);
}
fclose(recovery_file);
return true;

View File

@@ -113,6 +113,10 @@
#
# tablespace_mapping=/path/to/original/tablespace=/path/to/new/tablespace
# You can specify a restore_command to be used in the recovery.conf that
# will be placed in the cloned standby
#
# pg_resore_command = cp /path/to/archived/wals/%f %p
# Failover settings (repmgrd)
# ---------------------------