mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Convert --recovery-min-apply-delay to configuration file option
That way it only needs to be set once, and won't get lost during follow operations etc.
This commit is contained in:
38
configfile.c
38
configfile.c
@@ -22,6 +22,8 @@ static bool parse_bool(const char *s,
|
||||
|
||||
static void _parse_line(char *buf, char *name, char *value);
|
||||
static void parse_event_notifications_list(t_configuration_options *options, const char *arg);
|
||||
static void parse_time_unit_parameter(const char *name, const char *value, char *dest, ItemList *errors);
|
||||
|
||||
static void tablespace_list_append(t_configuration_options *options, const char *arg);
|
||||
|
||||
|
||||
@@ -233,6 +235,7 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
memset(options->restore_command, 0, sizeof(options->restore_command));
|
||||
options->tablespace_mapping.head = NULL;
|
||||
options->tablespace_mapping.tail = NULL;
|
||||
memset(options->recovery_min_apply_delay, 0, sizeof(options->recovery_min_apply_delay));
|
||||
|
||||
/* repmgrd settings
|
||||
* ---------------- */
|
||||
@@ -388,6 +391,8 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
tablespace_list_append(options, value);
|
||||
else if (strcmp(name, "restore_command") == 0)
|
||||
strncpy(options->restore_command, value, MAXLEN);
|
||||
else if (strcmp(name, "recovery_min_apply_delay") == 0)
|
||||
parse_time_unit_parameter(name, value, options->recovery_min_apply_delay, error_list);
|
||||
|
||||
/* node check settings */
|
||||
else if (strcmp(name, "archive_ready_warning") == 0)
|
||||
@@ -781,10 +786,43 @@ _parse_line(char *buf, char *name, char *value)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
parse_time_unit_parameter(const char *name, const char *value, char *dest, ItemList *errors)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
int targ = strtol(value, &ptr, 10);
|
||||
|
||||
if (targ < 1)
|
||||
{
|
||||
item_list_append_format(
|
||||
errors,
|
||||
_("invalid value provided for \"%s\""),
|
||||
name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptr && *ptr)
|
||||
{
|
||||
if (strcmp(ptr, "ms") != 0 && strcmp(ptr, "s") != 0 &&
|
||||
strcmp(ptr, "min") != 0 && strcmp(ptr, "h") != 0 &&
|
||||
strcmp(ptr, "d") != 0)
|
||||
{
|
||||
item_list_append_format(
|
||||
errors,
|
||||
_("value provided for \"%s\" must be one of ms/s/min/h/d"),
|
||||
name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(dest, value, MAXLEN);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
reload_config(t_configuration_options *orig_options)
|
||||
{
|
||||
// XXX implement!
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ typedef struct
|
||||
char pg_basebackup_options[MAXLEN];
|
||||
char restore_command[MAXLEN];
|
||||
TablespaceList tablespace_mapping;
|
||||
char recovery_min_apply_delay[MAXLEN];
|
||||
|
||||
/* node check settings */
|
||||
int archive_ready_warning;
|
||||
@@ -133,7 +134,7 @@ typedef struct
|
||||
/* log settings */ \
|
||||
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
||||
/* standby clone settings */ \
|
||||
false, "", "", "", "", { NULL, NULL }, \
|
||||
false, "", "", "", "", { NULL, NULL }, "", \
|
||||
/* node check settings */ \
|
||||
DEFAULT_ARCHIVE_READY_WARNING, DEFAULT_ARCHIVE_READY_CRITICAL, \
|
||||
DEFAULT_REPLICATION_LAG_WARNING, DEFAULT_REPLICATION_LAG_CRITICAL, \
|
||||
|
||||
@@ -344,32 +344,6 @@ main(int argc, char **argv)
|
||||
runtime_options.no_upstream_connection = true;
|
||||
break;
|
||||
|
||||
/* --recovery-min-apply-delay */
|
||||
case OPT_RECOVERY_MIN_APPLY_DELAY:
|
||||
{
|
||||
char *ptr = NULL;
|
||||
int targ = strtol(optarg, &ptr, 10);
|
||||
|
||||
if (targ < 1)
|
||||
{
|
||||
item_list_append(&cli_errors, _("invalid value provided for '--recovery-min-apply-delay'"));
|
||||
break;
|
||||
}
|
||||
if (ptr && *ptr)
|
||||
{
|
||||
if (strcmp(ptr, "ms") != 0 && strcmp(ptr, "s") != 0 &&
|
||||
strcmp(ptr, "min") != 0 && strcmp(ptr, "h") != 0 &&
|
||||
strcmp(ptr, "d") != 0)
|
||||
{
|
||||
item_list_append(&cli_errors,
|
||||
_("value provided for '--recovery-min-apply-delay' must be one of ms/s/min/h/d"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(runtime_options.recovery_min_apply_delay, optarg, MAXLEN);
|
||||
break;
|
||||
}
|
||||
|
||||
case OPT_UPSTREAM_CONNINFO:
|
||||
strncpy(runtime_options.upstream_conninfo, optarg, MAXLEN);
|
||||
@@ -557,6 +531,11 @@ main(int argc, char **argv)
|
||||
_("--remote-config-file is no longer required"));
|
||||
break;
|
||||
|
||||
/* --recovery-min-apply-delay */
|
||||
case OPT_RECOVERY_MIN_APPLY_DELAY:
|
||||
item_list_append(&cli_warnings,
|
||||
_("--recovery-min-apply-delay is now a configuration file parameter, \"recovery_min_apply_delay\""));
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2607,10 +2586,10 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
|
||||
log_debug("recovery.conf: %s", line);
|
||||
|
||||
/* recovery_min_apply_delay = ... (optional) */
|
||||
if (*runtime_options.recovery_min_apply_delay)
|
||||
if (*config_file_options.recovery_min_apply_delay)
|
||||
{
|
||||
maxlen_snprintf(line, "recovery_min_apply_delay = %s\n",
|
||||
runtime_options.recovery_min_apply_delay);
|
||||
config_file_options.recovery_min_apply_delay);
|
||||
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@
|
||||
# at least the number of standbys which will connect
|
||||
# to the primary.
|
||||
|
||||
#recovery_min_apply_delay= # Ff provided, "recovery_min_apply_delay" in recovery.conf
|
||||
# will be set to this value.
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Logging settings
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user