repmgrd: handle case where upstream is no longer primary

If the upstream comes back on line (e.g. after a switchover), and its
status is no longer primary, restart monitoring to ensure the correct
primary (potentially the current node) is being monitored.
This commit is contained in:
Ian Barwick
2018-10-18 16:50:13 +09:00
parent 8bec4946bc
commit 0842560a88

View File

@@ -778,6 +778,16 @@ monitor_streaming_standby(void)
if (upstream_node_info.type == PRIMARY)
{
primary_conn = upstream_conn;
if (get_recovery_type(primary_conn) != RECTYPE_PRIMARY)
{
log_notice(_("current upstream node \"%s\" (node ID: %i) is not primary, restarting monitoring"),
upstream_node_info.node_name, upstream_node_info.node_id);
PQfinish(upstream_conn);
upstream_conn = NULL;
termPQExpBuffer(&event_details);
return;
}
}
initPQExpBuffer(&event_details);