mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 16:16:29 +00:00
repmgrd: improve log output
- emit explicit startup NOTICE - emit NOTICE when falling back to degraded monitoring on a primary node - improve log message and event notification details when monitoring a former primary which has been reconnected as a standby
This commit is contained in:
@@ -280,6 +280,7 @@ monitor_streaming_primary(void)
|
|||||||
|
|
||||||
monitoring_state = MS_DEGRADED;
|
monitoring_state = MS_DEGRADED;
|
||||||
INSTR_TIME_SET_CURRENT(degraded_monitoring_start);
|
INSTR_TIME_SET_CURRENT(degraded_monitoring_start);
|
||||||
|
log_notice(_("unable to connect to local node, falling back to degraded monitoring"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -326,20 +327,19 @@ monitor_streaming_primary(void)
|
|||||||
{
|
{
|
||||||
local_node_info.node_status = NODE_STATUS_UP;
|
local_node_info.node_status = NODE_STATUS_UP;
|
||||||
|
|
||||||
initPQExpBuffer(&event_details);
|
|
||||||
|
|
||||||
/* check to see if the node has been restored as a standby */
|
/* check to see if the node has been restored as a standby */
|
||||||
if (get_recovery_type(local_conn) == RECTYPE_STANDBY)
|
if (get_recovery_type(local_conn) == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
PGconn *new_primary_conn;
|
PGconn *new_primary_conn;
|
||||||
|
|
||||||
|
initPQExpBuffer(&event_details);
|
||||||
|
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBuffer(&event_details,
|
||||||
_("reconnected to node after %i seconds, node is now a standby, switching to standby monitoring"),
|
_("reconnected to node after %i seconds, node is now a standby, switching to standby monitoring"),
|
||||||
degraded_monitoring_elapsed);
|
degraded_monitoring_elapsed);
|
||||||
log_notice("%s", event_details.data);
|
log_notice("%s", event_details.data);
|
||||||
termPQExpBuffer(&event_details);
|
termPQExpBuffer(&event_details);
|
||||||
|
|
||||||
|
|
||||||
primary_node_id = UNKNOWN_NODE_ID;
|
primary_node_id = UNKNOWN_NODE_ID;
|
||||||
|
|
||||||
new_primary_conn = get_primary_connection_quiet(local_conn, &primary_node_id, NULL);
|
new_primary_conn = get_primary_connection_quiet(local_conn, &primary_node_id, NULL);
|
||||||
@@ -392,10 +392,15 @@ monitor_streaming_primary(void)
|
|||||||
if (resume_monitoring == true)
|
if (resume_monitoring == true)
|
||||||
{
|
{
|
||||||
monitoring_state = MS_NORMAL;
|
monitoring_state = MS_NORMAL;
|
||||||
|
log_notice(_("former primary has been restored as standby after %i seconds, updating node record and resuming monitoring"),
|
||||||
|
degraded_monitoring_elapsed);
|
||||||
|
|
||||||
|
initPQExpBuffer(&event_details);
|
||||||
|
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBuffer(&event_details,
|
||||||
_("former primary has been restored as standby after %i seconds, updating node record and resuming monitoring"),
|
_("node restored as standby after %i seconds, monitoring connection to upstream node %i"),
|
||||||
degraded_monitoring_elapsed);
|
degraded_monitoring_elapsed,
|
||||||
|
local_node_info.upstream_node_id);
|
||||||
|
|
||||||
create_event_notification(new_primary_conn,
|
create_event_notification(new_primary_conn,
|
||||||
&config_file_options,
|
&config_file_options,
|
||||||
@@ -403,7 +408,8 @@ monitor_streaming_primary(void)
|
|||||||
"repmgrd_standby_reconnect",
|
"repmgrd_standby_reconnect",
|
||||||
true,
|
true,
|
||||||
event_details.data);
|
event_details.data);
|
||||||
log_notice("%s", event_details.data);
|
|
||||||
|
|
||||||
termPQExpBuffer(&event_details);
|
termPQExpBuffer(&event_details);
|
||||||
|
|
||||||
PQfinish(new_primary_conn);
|
PQfinish(new_primary_conn);
|
||||||
@@ -429,6 +435,7 @@ monitor_streaming_primary(void)
|
|||||||
{
|
{
|
||||||
monitoring_state = MS_NORMAL;
|
monitoring_state = MS_NORMAL;
|
||||||
|
|
||||||
|
initPQExpBuffer(&event_details);
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBuffer(&event_details,
|
||||||
_("reconnected to primary node after %i seconds, resuming monitoring"),
|
_("reconnected to primary node after %i seconds, resuming monitoring"),
|
||||||
degraded_monitoring_elapsed);
|
degraded_monitoring_elapsed);
|
||||||
@@ -469,7 +476,7 @@ loop:
|
|||||||
|
|
||||||
if (monitoring_state == MS_DEGRADED)
|
if (monitoring_state == MS_DEGRADED)
|
||||||
{
|
{
|
||||||
log_detail(_("waiting for primary to reappear"));
|
log_detail(_("waiting for the node to become available"));
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTR_TIME_SET_CURRENT(log_status_interval_start);
|
INSTR_TIME_SET_CURRENT(log_status_interval_start);
|
||||||
@@ -2384,18 +2391,20 @@ do_election(void)
|
|||||||
|
|
||||||
if (config_file_options.failover == FAILOVER_MANUAL)
|
if (config_file_options.failover == FAILOVER_MANUAL)
|
||||||
{
|
{
|
||||||
log_notice(_("this node is not configured for automatic failover so will not be considered as promotion candidate"));
|
log_notice(_("this node is not configured for automatic failover so will not be considered as promotion candidate, and will not follow the new primary"));
|
||||||
|
log_detail(_("\"failover\" is set to \"manual\" in repmgr.conf"));
|
||||||
|
log_hint(_("manually execute \"repmgr standby follow\" to have this node follow the new primary"));
|
||||||
|
|
||||||
return ELECTION_LOST;
|
return ELECTION_NOT_CANDIDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* node priority is set to zero - don't ever become a candidate */
|
/* node priority is set to zero - don't become a candidate, and lose by default */
|
||||||
if (local_node_info.priority <= 0)
|
if (local_node_info.priority <= 0)
|
||||||
{
|
{
|
||||||
log_notice(_("this node's priority is %i so will not be considered as an automatic promotion candidate"),
|
log_notice(_("this node's priority is %i so will not be considered as an automatic promotion candidate"),
|
||||||
local_node_info.priority);
|
local_node_info.priority);
|
||||||
|
|
||||||
return ELECTION_NOT_CANDIDATE;
|
return ELECTION_LOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get all active nodes attached to upstream, excluding self */
|
/* get all active nodes attached to upstream, excluding self */
|
||||||
|
|||||||
@@ -255,6 +255,8 @@ main(int argc, char **argv)
|
|||||||
strncpy(config_file_options.log_level, cli_log_level, MAXLEN);
|
strncpy(config_file_options.log_level, cli_log_level, MAXLEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_notice(_("repmgrd (repmgr %s) starting up"), REPMGR_VERSION);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* -m/--monitoring-history, if provided, will override repmgr.conf's
|
* -m/--monitoring-history, if provided, will override repmgr.conf's
|
||||||
* monitoring_history; this is for backwards compatibility as it's
|
* monitoring_history; this is for backwards compatibility as it's
|
||||||
|
|||||||
Reference in New Issue
Block a user