mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +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;
|
options->log_status_interval = DEFAULT_LOG_STATUS_INTERVAL;
|
||||||
|
|
||||||
/*-----------------------
|
/*-----------------------
|
||||||
* standby action settings
|
* standby clone settings
|
||||||
*------------------------
|
*------------------------
|
||||||
*/
|
*/
|
||||||
options->use_replication_slots = false;
|
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;
|
options->use_primary_conninfo_password = false;
|
||||||
memset(options->passfile, 0, sizeof(options->passfile));
|
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
|
* repmgrd settings
|
||||||
*-----------------
|
*-----------------
|
||||||
@@ -506,6 +513,13 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
else if (strcmp(name, "passfile") == 0)
|
else if (strcmp(name, "passfile") == 0)
|
||||||
strncpy(options->passfile, value, sizeof(options->passfile));
|
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 */
|
/* node check settings */
|
||||||
else if (strcmp(name, "archive_ready_warning") == 0)
|
else if (strcmp(name, "archive_ready_warning") == 0)
|
||||||
options->archive_ready_warning = repmgr_atoi(value, name, error_list, 1);
|
options->archive_ready_warning = repmgr_atoi(value, name, error_list, 1);
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ typedef struct
|
|||||||
char log_file[MAXLEN];
|
char log_file[MAXLEN];
|
||||||
int log_status_interval;
|
int log_status_interval;
|
||||||
|
|
||||||
/* standby action settings */
|
/* standby clone settings */
|
||||||
bool use_replication_slots;
|
bool use_replication_slots;
|
||||||
char pg_basebackup_options[MAXLEN];
|
char pg_basebackup_options[MAXLEN];
|
||||||
char restore_command[MAXLEN];
|
char restore_command[MAXLEN];
|
||||||
@@ -92,6 +92,10 @@ typedef struct
|
|||||||
bool use_primary_conninfo_password;
|
bool use_primary_conninfo_password;
|
||||||
char passfile[MAXPGPATH];
|
char passfile[MAXPGPATH];
|
||||||
|
|
||||||
|
/* standby promote settings */
|
||||||
|
int promote_check_timeout;
|
||||||
|
int promote_check_interval;
|
||||||
|
|
||||||
/* node check settings */
|
/* node check settings */
|
||||||
int archive_ready_warning;
|
int archive_ready_warning;
|
||||||
int archive_ready_critical;
|
int archive_ready_critical;
|
||||||
@@ -159,6 +163,8 @@ typedef struct
|
|||||||
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
"", "", "", DEFAULT_LOG_STATUS_INTERVAL, \
|
||||||
/* standby action settings */ \
|
/* standby action settings */ \
|
||||||
false, "", "", { NULL, NULL }, "", false, false, "", \
|
false, "", "", { NULL, NULL }, "", false, false, "", \
|
||||||
|
/* standby promote settings */ \
|
||||||
|
DEFAULT_PROMOTE_CHECK_TIMEOUT, DEFAULT_PROMOTE_CHECK_INTERVAL, \
|
||||||
/* node check settings */ \
|
/* node check settings */ \
|
||||||
DEFAULT_ARCHIVE_READY_WARNING, DEFAULT_ARCHIVE_READY_CRITICAL, \
|
DEFAULT_ARCHIVE_READY_WARNING, DEFAULT_ARCHIVE_READY_CRITICAL, \
|
||||||
DEFAULT_REPLICATION_LAG_WARNING, DEFAULT_REPLICATION_LAG_CRITICAL, \
|
DEFAULT_REPLICATION_LAG_WARNING, DEFAULT_REPLICATION_LAG_CRITICAL, \
|
||||||
|
|||||||
@@ -26,6 +26,12 @@
|
|||||||
by using <xref linkend="repmgr-standby-follow">; if <application>repmgrd</application>
|
by using <xref linkend="repmgr-standby-follow">; if <application>repmgrd</application>
|
||||||
is active, it will handle this automatically.
|
is active, it will handle this automatically.
|
||||||
</para>
|
</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>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
@@ -42,6 +48,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Event notifications</title>
|
<title>Event notifications</title>
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -43,6 +43,22 @@
|
|||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</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>
|
<refsect1>
|
||||||
<title>Event notifications</title>
|
<title>Event notifications</title>
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -1877,10 +1877,8 @@ static void
|
|||||||
_do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
_do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
||||||
{
|
{
|
||||||
char script[MAXLEN];
|
char script[MAXLEN];
|
||||||
int r;
|
int r,
|
||||||
int i,
|
i;
|
||||||
promote_check_timeout = 60,
|
|
||||||
promote_check_interval = 2;
|
|
||||||
bool promote_success = false;
|
bool promote_success = false;
|
||||||
PQExpBufferData details;
|
PQExpBufferData details;
|
||||||
|
|
||||||
@@ -1927,8 +1925,7 @@ _do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
|||||||
exit(ERR_PROMOTION_FAIL);
|
exit(ERR_PROMOTION_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: make these values configurable */
|
for (i = 0; i < config_file_options.promote_check_timeout; i += config_file_options.promote_check_interval)
|
||||||
for (i = 0; i < promote_check_timeout; i += promote_check_interval)
|
|
||||||
{
|
{
|
||||||
recovery_type = get_recovery_type(conn);
|
recovery_type = get_recovery_type(conn);
|
||||||
|
|
||||||
@@ -1937,7 +1934,7 @@ _do_standby_promote_internal(PGconn *conn, const char *data_dir)
|
|||||||
promote_success = true;
|
promote_success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(promote_check_interval);
|
sleep(config_file_options.promote_check_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promote_success == false)
|
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 */
|
/* update node information to reflect new status */
|
||||||
if (update_node_record_set_primary(conn, config_file_options.node_id) == false)
|
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").
|
# 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
|
#restore_command='' # This will be placed in the recovery.conf
|
||||||
# file generated by repmgr
|
# 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
|
# Standby follow settings
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user