mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
repmgr: improve "repmgr standby switchover" log output
Particularly in --dry-run mode it's useful to get a confirmation that various prerequisites are met.
This commit is contained in:
@@ -1785,6 +1785,27 @@ do_standby_switchover(void)
|
|||||||
|
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PQExpBufferData msg;
|
||||||
|
initPQExpBuffer(&msg);
|
||||||
|
|
||||||
|
appendPQExpBuffer(&msg,
|
||||||
|
_("SSH connection to host \"%s\" succeeded"),
|
||||||
|
remote_host);
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info("%s", msg.data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, "%s", msg.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
termPQExpBuffer(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* check archive/replication status */
|
/* check archive/replication status */
|
||||||
{
|
{
|
||||||
@@ -1822,7 +1843,10 @@ do_standby_switchover(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
termPQExpBuffer(&command_output);
|
termPQExpBuffer(&command_output);
|
||||||
if (status == CHECK_STATUS_UNKNOWN)
|
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case CHECK_STATUS_UNKNOWN:
|
||||||
{
|
{
|
||||||
if (runtime_options.force == false)
|
if (runtime_options.force == false)
|
||||||
{
|
{
|
||||||
@@ -1838,9 +1862,10 @@ do_standby_switchover(void)
|
|||||||
log_warning(_("unable to check number of pending archive files on demotion candidate \"%s\""),
|
log_warning(_("unable to check number of pending archive files on demotion candidate \"%s\""),
|
||||||
remote_node_record.node_name);
|
remote_node_record.node_name);
|
||||||
log_notice(_("-F/--force set, continuing with switchover"));
|
log_notice(_("-F/--force set, continuing with switchover"));
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (status == CHECK_STATUS_CRITICAL)
|
break;
|
||||||
|
|
||||||
|
case CHECK_STATUS_CRITICAL:
|
||||||
{
|
{
|
||||||
if (runtime_options.force == false)
|
if (runtime_options.force == false)
|
||||||
{
|
{
|
||||||
@@ -1861,7 +1886,9 @@ do_standby_switchover(void)
|
|||||||
files, threshold);
|
files, threshold);
|
||||||
log_notice(_("-F/--force set, continuing with switchover"));
|
log_notice(_("-F/--force set, continuing with switchover"));
|
||||||
}
|
}
|
||||||
else if (status == CHECK_STATUS_WARNING)
|
break;
|
||||||
|
|
||||||
|
case CHECK_STATUS_WARNING:
|
||||||
{
|
{
|
||||||
log_warning(_("number of pending archive files on demotion candidate \"%s\" is warning"),
|
log_warning(_("number of pending archive files on demotion candidate \"%s\" is warning"),
|
||||||
remote_node_record.node_name);
|
remote_node_record.node_name);
|
||||||
@@ -1869,10 +1896,49 @@ do_standby_switchover(void)
|
|||||||
files, threshold);
|
files, threshold);
|
||||||
log_hint(_("PostgreSQL will not shut down until all files are archived"));
|
log_hint(_("PostgreSQL will not shut down until all files are archived"));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CHECK_STATUS_OK:
|
||||||
|
{
|
||||||
|
PQExpBufferData msg;
|
||||||
|
initPQExpBuffer(&msg);
|
||||||
|
|
||||||
|
appendPQExpBuffer(&msg,
|
||||||
|
_("%i pending archive files"),
|
||||||
|
files);
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info("%s", msg.data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, "%s", msg.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check replication lag */
|
termPQExpBuffer(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *msg = _("archive mode is \"off\"");
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info("%s", msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, "%s", msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* check replication lag on promotion candidate
|
||||||
|
* (TODO: check on all nodes attached to demotion candidate)
|
||||||
|
*/
|
||||||
lag_seconds = get_replication_lag_seconds(local_conn);
|
lag_seconds = get_replication_lag_seconds(local_conn);
|
||||||
|
|
||||||
log_debug("lag is %i ", lag_seconds);
|
log_debug("lag is %i ", lag_seconds);
|
||||||
@@ -1919,6 +1985,27 @@ do_standby_switchover(void)
|
|||||||
log_warning(_("unable to check replication lag on local node"));
|
log_warning(_("unable to check replication lag on local node"));
|
||||||
log_notice(_("-F/--force set, continuing with switchover"));
|
log_notice(_("-F/--force set, continuing with switchover"));
|
||||||
}
|
}
|
||||||
|
/* replication lag is below warning threshold */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PQExpBufferData msg;
|
||||||
|
initPQExpBuffer(&msg);
|
||||||
|
|
||||||
|
appendPQExpBuffer(&msg,
|
||||||
|
_("replication lag on this standby is %i seconds"),
|
||||||
|
lag_seconds);
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info("%s", msg.data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, "%s", msg.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
termPQExpBuffer(&msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PQfinish(remote_conn);
|
PQfinish(remote_conn);
|
||||||
@@ -1927,20 +2014,34 @@ do_standby_switchover(void)
|
|||||||
/*
|
/*
|
||||||
* If --siblings-follow specified, get list and check they're reachable
|
* If --siblings-follow specified, get list and check they're reachable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (runtime_options.siblings_follow == true)
|
|
||||||
{
|
|
||||||
char host[MAXLEN] = "";
|
|
||||||
NodeInfoListCell *cell;
|
|
||||||
|
|
||||||
get_active_sibling_node_records(local_conn,
|
get_active_sibling_node_records(local_conn,
|
||||||
local_node_record.node_id,
|
local_node_record.node_id,
|
||||||
local_node_record.upstream_node_id,
|
local_node_record.upstream_node_id,
|
||||||
&sibling_nodes);
|
&sibling_nodes);
|
||||||
|
|
||||||
|
if (runtime_options.siblings_follow == false)
|
||||||
|
{
|
||||||
|
if (sibling_nodes.node_count > 0)
|
||||||
|
{
|
||||||
|
log_warning(_("%i sibling nodes found, but option \"--siblings-follow\" not specified"),
|
||||||
|
sibling_nodes.node_count);
|
||||||
|
log_detail(_("these nodes will remain attached to the current primary"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char host[MAXLEN] = "";
|
||||||
|
NodeInfoListCell *cell;
|
||||||
|
|
||||||
log_verbose(LOG_INFO, _("%i active sibling nodes found"),
|
log_verbose(LOG_INFO, _("%i active sibling nodes found"),
|
||||||
sibling_nodes.node_count);
|
sibling_nodes.node_count);
|
||||||
|
|
||||||
|
if (sibling_nodes.node_count == 0)
|
||||||
|
{
|
||||||
|
log_warning(_("option \"--sibling-nodes\" specified, but no sibling nodes exist"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (cell = sibling_nodes.head; cell; cell = cell->next)
|
for (cell = sibling_nodes.head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
/* get host from node record */
|
/* get host from node record */
|
||||||
@@ -1989,9 +2090,22 @@ do_standby_switchover(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
log_detail(_("F/--force specified, proceeding anyway"));
|
log_detail(_("F/--force specified, proceeding anyway"));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *msg = _("all sibling nodes are reachable via SSH");
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info("%s", msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_verbose(LOG_INFO, "%s", msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PQfinish(local_conn);
|
PQfinish(local_conn);
|
||||||
|
|
||||||
@@ -2000,7 +2114,7 @@ do_standby_switchover(void)
|
|||||||
* Sanity checks completed - prepare for the switchover
|
* Sanity checks completed - prepare for the switchover
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log_detail(_("local node \"%s\" (ID: %i) will be promoted to primary; "
|
log_notice(_("local node \"%s\" (ID: %i) will be promoted to primary; "
|
||||||
"current primary \"%s\" (ID: %i) will be demoted to standby"),
|
"current primary \"%s\" (ID: %i) will be demoted to standby"),
|
||||||
local_node_record.node_name,
|
local_node_record.node_name,
|
||||||
local_node_record.node_id,
|
local_node_record.node_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user