mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
cluster show/daemon status: report upstream node mismatches
When showing node information, check if the node's copy of its record shows a different upstream to the one expected according to the node where the command is executed. This helps visualise situations where the cluster is in an unexpected state, and provide a better idea of the actual state. For example, if a cluster has divided somehow and a set of nodes are following a new primary, when running "cluster show" etc., repmgr will now show the name of the primary those nodes are actually following, rather than the now outdated node name recorded on the other side of the split. A warning will also be issued about the situation.
This commit is contained in:
@@ -129,6 +129,8 @@ do_daemon_status(void)
|
||||
for (cell = nodes.head; cell; cell = cell->next)
|
||||
{
|
||||
int j;
|
||||
PQExpBufferData node_status;
|
||||
PQExpBufferData upstream;
|
||||
|
||||
repmgrd_info[i] = pg_malloc0(sizeof(RepmgrdInfo));
|
||||
repmgrd_info[i]->node_id = cell->node_info->node_id;
|
||||
@@ -229,15 +231,18 @@ do_daemon_status(void)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
PQExpBufferData node_status;
|
||||
initPQExpBuffer(&node_status);
|
||||
initPQExpBuffer(&node_status);
|
||||
initPQExpBuffer(&upstream);
|
||||
|
||||
(void)format_node_status(cell->node_info, &node_status, &warnings);
|
||||
snprintf(repmgrd_info[i]->pg_running_text, sizeof(cell->node_info->details),
|
||||
(void)format_node_status(cell->node_info, &node_status, &upstream, &warnings);
|
||||
snprintf(repmgrd_info[i]->pg_running_text, sizeof(cell->node_info->details),
|
||||
"%s", node_status.data);
|
||||
termPQExpBuffer(&node_status);
|
||||
}
|
||||
|
||||
snprintf(cell->node_info->upstream_node_name, sizeof(cell->node_info->upstream_node_name),
|
||||
"%s", upstream.data);
|
||||
|
||||
termPQExpBuffer(&node_status);
|
||||
termPQExpBuffer(&upstream);
|
||||
|
||||
PQfinish(cell->node_info->conn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user