"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:
Ian Barwick
2018-02-27 10:04:58 +09:00
parent a3f371b8c0
commit 63a11f8926
6 changed files with 65 additions and 10 deletions

View File

@@ -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)