From 5208655a35a3b755ca3114d47679c6835aee5c1d Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 25 Aug 2017 21:47:14 +0900 Subject: [PATCH] Parse "recovery_min_apply_delay" from recovery.conf --- configfile.c | 29 +++++++++++++++++------------ configfile.h | 4 ++-- doc/changes-in-repmgr4.md | 3 +++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/configfile.c b/configfile.c index 4df28b77..1a1d3b57 100644 --- a/configfile.c +++ b/configfile.c @@ -716,9 +716,8 @@ parse_recovery_conf(const char *data_dir, t_recovery_conf *conf) strncpy(conf->trigger_file, value, MAXLEN); else if (strcmp(name, "trigger_file") == 0) strncpy(conf->trigger_file, value, MAXLEN); - /* TODO: parse values */ - /*else if (strcmp(name, "recovery_min_apply_delay") == 0) - strncpy(conf->, value, MAXLEN);*/ + else if (strcmp(name, "recovery_min_apply_delay") == 0) + parse_time_unit_parameter(name, value, conf->recovery_min_apply_delay, NULL); } fclose(fp); @@ -794,10 +793,13 @@ parse_time_unit_parameter(const char *name, const char *value, char *dest, ItemL if (targ < 1) { - item_list_append_format( - errors, - _("invalid value provided for \"%s\""), - name); + if (errors != NULL) + { + item_list_append_format( + errors, + _("invalid value provided for \"%s\""), + name); + } return; } @@ -807,11 +809,14 @@ parse_time_unit_parameter(const char *name, const char *value, char *dest, ItemL 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; + if (errors != NULL) + { + item_list_append_format( + errors, + _("value provided for \"%s\" must be one of ms/s/min/h/d"), + name); + return; + } } } diff --git a/configfile.h b/configfile.h index afc2ef35..849d827c 100644 --- a/configfile.h +++ b/configfile.h @@ -204,7 +204,7 @@ typedef struct char primary_conninfo[MAXLEN]; char primary_slot_name[MAXLEN]; char trigger_file[MAXLEN]; - int recovery_min_apply_delay; + char recovery_min_apply_delay[MAXLEN]; } t_recovery_conf; #define T_RECOVERY_CONF_INITIALIZER { \ @@ -216,7 +216,7 @@ typedef struct RTA_PAUSE, \ /* standby server settings */ \ true, \ - "", "", "", 0 \ + "", "", "", "" \ } diff --git a/doc/changes-in-repmgr4.md b/doc/changes-in-repmgr4.md index 373dabc8..21546bfc 100644 --- a/doc/changes-in-repmgr4.md +++ b/doc/changes-in-repmgr4.md @@ -30,6 +30,9 @@ Changed command line options The value (defaults to the user in the conninfo string) will be stored in the repmgr metadata for use by standby clone/follow.. +- `--recovery-min-apply-delay` is now a configuration file parameter + `recovery_min_apply_delay, to ensure the setting does not get lost when + a standby follows a new upstream. ### repmgrd