mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
"standby promote": make timeout values configurable
This introduces following new configuration file parameters, which were previously hard-coded values: - promote_check_timeout - promote_check_interval Implements GitHub #387.
This commit is contained in:
16
configfile.c
16
configfile.c
@@ -303,7 +303,7 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
options->log_status_interval = DEFAULT_LOG_STATUS_INTERVAL;
|
||||
|
||||
/*-----------------------
|
||||
* standby action settings
|
||||
* standby clone settings
|
||||
*------------------------
|
||||
*/
|
||||
options->use_replication_slots = false;
|
||||
@@ -317,6 +317,13 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
options->use_primary_conninfo_password = false;
|
||||
memset(options->passfile, 0, sizeof(options->passfile));
|
||||
|
||||
/*-----------------------
|
||||
* standby promote settings
|
||||
*------------------------
|
||||
*/
|
||||
options->promote_check_timeout = DEFAULT_PROMOTE_CHECK_TIMEOUT;
|
||||
options->promote_check_interval = DEFAULT_PROMOTE_CHECK_INTERVAL;
|
||||
|
||||
/*-----------------
|
||||
* repmgrd settings
|
||||
*-----------------
|
||||
@@ -506,6 +513,13 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
||||
else if (strcmp(name, "passfile") == 0)
|
||||
strncpy(options->passfile, value, sizeof(options->passfile));
|
||||
|
||||
/* standby promote settings */
|
||||
else if (strcmp(name, "promote_check_timeout") == 0)
|
||||
options->promote_check_timeout = repmgr_atoi(value, name, error_list, 1);
|
||||
|
||||
else if (strcmp(name, "promote_check_interval") == 0)
|
||||
options->promote_check_interval = repmgr_atoi(value, name, error_list, 1);
|
||||
|
||||
/* node check settings */
|
||||
else if (strcmp(name, "archive_ready_warning") == 0)
|
||||
options->archive_ready_warning = repmgr_atoi(value, name, error_list, 1);
|
||||
|
||||
@@ -82,7 +82,7 @@ typedef struct
|
||||
char log_file[MAXLEN];
|
||||
int log_status_interval;
|
||||
|
||||
/* standby action settings */
|
||||
/* standby clone settings */
|
||||
bool use_replication_slots;
|
||||
char pg_basebackup_options[MAXLEN];
|
||||
char restore_command[MAXLEN];
|
||||
@@ -92,6 +92,10 @@ typedef struct
|
||||
bool use_primary_conninfo_password;
|
||||
char passfile[MAXPGPATH];
|
||||
|
||||
/* standby promote settings */
|
||||
int promote_check_timeout;
|
||||
int promote_check_interval;
|
||||
|
||||
/* node check settings */
|
||||
int archive_ready_warning;
|
||||
int archive_ready_critical;
|
||||
@@ -159,6 +163,8 @@ typedef struct
|
||||
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
||||
/* standby action settings */ \
|
||||
false, "", "", { NULL, NULL }, "", false, false, "", \
|
||||
/* standby promote settings */ \
|
||||
DEFAULT_PROMOTE_CHECK_TIMEOUT, DEFAULT_PROMOTE_CHECK_INTERVAL, \
|
||||
/* node check settings */ \
|
||||
DEFAULT_ARCHIVE_READY_WARNING, DEFAULT_ARCHIVE_READY_CRITICAL, \
|
||||
DEFAULT_REPLICATION_LAG_WARNING, DEFAULT_REPLICATION_LAG_CRITICAL, \
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
by using <xref linkend="repmgr-standby-follow">; if <application>repmgrd</application>
|
||||
is active, it will handle this automatically.
|
||||
</para>
|
||||
<para>
|
||||
Note that &repmgr; will wait for up to <varname>promote_check_timeout</varname> seconds
|
||||
(default: 60 seconds) to verify that the standby has been promoted, and will
|
||||
check the promotion every <varname>promote_check_interval</varname> seconds (default: 1 second)
|
||||
(both values can be defined in <filename>repmgr.conf</filename>).
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
@@ -42,6 +48,7 @@
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
<refsect1>
|
||||
<title>Event notifications</title>
|
||||
<para>
|
||||
|
||||
@@ -43,6 +43,22 @@
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Options</title>
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--node-id</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<varname>node_id</varname> of the node to unregister (optional)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Event notifications</title>
|
||||
<para>
|
||||
|
||||
@@ -1877,10 +1877,8 @@ static void
|
||||
_do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
||||
{
|
||||
char script[MAXLEN];
|
||||
int r;
|
||||
int i,
|
||||
promote_check_timeout = 60,
|
||||
promote_check_interval = 2;
|
||||
int r,
|
||||
i;
|
||||
bool promote_success = false;
|
||||
PQExpBufferData details;
|
||||
|
||||
@@ -1927,8 +1925,7 @@ _do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
||||
exit(ERR_PROMOTION_FAIL);
|
||||
}
|
||||
|
||||
/* TODO: make these values configurable */
|
||||
for (i = 0; i < promote_check_timeout; i += promote_check_interval)
|
||||
for (i = 0; i < config_file_options.promote_check_timeout; i += config_file_options.promote_check_interval)
|
||||
{
|
||||
recovery_type = get_recovery_type(conn);
|
||||
|
||||
@@ -1937,7 +1934,7 @@ _do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
||||
promote_success = true;
|
||||
break;
|
||||
}
|
||||
sleep(promote_check_interval);
|
||||
sleep(config_file_options.promote_check_interval);
|
||||
}
|
||||
|
||||
if (promote_success == false)
|
||||
@@ -1956,6 +1953,7 @@ _do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
||||
}
|
||||
}
|
||||
|
||||
log_verbose(LOG_INFO, _("standby promoted to primary after %i second(s)"), i);
|
||||
|
||||
/* update node information to reflect new status */
|
||||
if (update_node_record_set_primary(conn, config_file_options.node_id) == false)
|
||||
|
||||
@@ -161,7 +161,7 @@ ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Standby clone settings
|
||||
# "standby clone" settings
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# These settings apply when cloning a standby ("repmgr standby clone").
|
||||
@@ -178,6 +178,20 @@ ssh_options='-q -o ConnectTimeout=10' # Options to append to "ssh"
|
||||
#restore_command='' # This will be placed in the recovery.conf
|
||||
# file generated by repmgr
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# "standby promote" settings
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# These settings apply when instructing a standby to promote itself to the
|
||||
# new primary ("repmgr standby promote").
|
||||
|
||||
#promote_check_timeout=60 # The length of time (in seconds) to wait
|
||||
# for the new primary to finish promoting
|
||||
#promote_check_interval=1 # The interval (in seconds) to check whether
|
||||
# the new primary has finished promoting
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Standby follow settings
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user