repmgrd: track status of local (standby) node

If the local node is not available, note the degraded monitoring status.
This commit is contained in:
Ian Barwick
2019-01-22 10:33:48 +09:00
parent 44cbb44500
commit b6fe91ebcd

View File

@@ -638,6 +638,9 @@ monitor_streaming_standby(void)
instr_time log_status_interval_start;
PQExpBufferData event_details;
MonitoringState local_monitoring_state = MS_NORMAL;
instr_time local_degraded_monitoring_start;
log_debug("monitor_streaming_standby()");
reset_node_voting_status();
@@ -1341,11 +1344,26 @@ loop:
termPQExpBuffer(&event_details);
}
if (local_monitoring_state == MS_NORMAL)
{
log_info("entering degraded monitoring for the local node");
local_monitoring_state = MS_DEGRADED;
INSTR_TIME_SET_CURRENT(local_degraded_monitoring_start);
}
}
else
{
int stored_local_node_id = repmgrd_get_local_node_id(local_conn);
if (local_monitoring_state == MS_DEGRADED)
{
log_info(_("connection to local node recovered after %i seconds"),
calculate_elapsed(local_degraded_monitoring_start));
local_monitoring_state = MS_NORMAL;
}
/*
* If the local node was restarted, we'll need to reinitialise values
* stored in shared memory.