mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
node check: handle --upstream option when node is primary
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
Server role: OK (node is primary)
|
Server role: OK (node is primary)
|
||||||
Replication lag: OK (N/A - node is primary)
|
Replication lag: OK (N/A - node is primary)
|
||||||
WAL archiving: OK (0 pending files)
|
WAL archiving: OK (0 pending files)
|
||||||
|
Upstream connection: OK (N/A - is primary)
|
||||||
Downstream servers: OK (2 of 2 downstream nodes attached)
|
Downstream servers: OK (2 of 2 downstream nodes attached)
|
||||||
Replication slots: OK (node has no physical replication slots)
|
Replication slots: OK (node has no physical replication slots)
|
||||||
Missing replication slots: OK (node has no missing physical replication slots)</programlisting>
|
Missing replication slots: OK (node has no missing physical replication slots)</programlisting>
|
||||||
|
|||||||
@@ -1358,7 +1358,6 @@ do_node_check_upstream(PGconn *conn, OutputMode mode, t_node_info *node_info, Ch
|
|||||||
|
|
||||||
CheckStatus status = CHECK_STATUS_OK;
|
CheckStatus status = CHECK_STATUS_OK;
|
||||||
|
|
||||||
|
|
||||||
if (mode == OM_CSV && list_output == NULL)
|
if (mode == OM_CSV && list_output == NULL)
|
||||||
{
|
{
|
||||||
log_error(_("--csv output not provided with --upstream option"));
|
log_error(_("--csv output not provided with --upstream option"));
|
||||||
@@ -1366,36 +1365,48 @@ do_node_check_upstream(PGconn *conn, OutputMode mode, t_node_info *node_info, Ch
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_node_record(conn, node_info->upstream_node_id, &upstream_node_info) != RECORD_FOUND)
|
|
||||||
{
|
|
||||||
log_error(_("no record found for upstream node %i"), node_info->upstream_node_id);
|
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_BAD_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
initPQExpBuffer(&details);
|
initPQExpBuffer(&details);
|
||||||
|
|
||||||
upstream_conn = establish_db_connection(upstream_node_info.conninfo, true);
|
if (get_node_record(conn, node_info->upstream_node_id, &upstream_node_info) != RECORD_FOUND)
|
||||||
|
|
||||||
/* check our node is connected */
|
|
||||||
if (is_downstream_node_attached(upstream_conn, config_file_options.node_name) != NODE_ATTACHED)
|
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details,
|
if (get_recovery_type(conn) == RECTYPE_STANDBY)
|
||||||
_("node \"%s\" (ID: %i) is not attached to expected upstream node \"%s\" (ID: %i)"),
|
{
|
||||||
node_info->node_name,
|
appendPQExpBuffer(&details,
|
||||||
node_info->node_id,
|
_("node \"%s\" (ID: %i) is a standby but no upstream record found"),
|
||||||
upstream_node_info.node_name,
|
node_info->node_name,
|
||||||
upstream_node_info.node_id);
|
node_info->node_id);
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendPQExpBufferStr(&details,
|
||||||
|
_("N/A - node is primary"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details,
|
upstream_conn = establish_db_connection(upstream_node_info.conninfo, true);
|
||||||
_("node \"%s\" (ID: %i) is attached to expected upstream node \"%s\" (ID: %i)"),
|
|
||||||
node_info->node_name,
|
/* check our node is connected */
|
||||||
node_info->node_id,
|
if (is_downstream_node_attached(upstream_conn, config_file_options.node_name) != NODE_ATTACHED)
|
||||||
upstream_node_info.node_name,
|
{
|
||||||
upstream_node_info.node_id);
|
appendPQExpBuffer(&details,
|
||||||
|
_("node \"%s\" (ID: %i) is not attached to expected upstream node \"%s\" (ID: %i)"),
|
||||||
|
node_info->node_name,
|
||||||
|
node_info->node_id,
|
||||||
|
upstream_node_info.node_name,
|
||||||
|
upstream_node_info.node_id);
|
||||||
|
status = CHECK_STATUS_CRITICAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendPQExpBuffer(&details,
|
||||||
|
_("node \"%s\" (ID: %i) is attached to expected upstream node \"%s\" (ID: %i)"),
|
||||||
|
node_info->node_name,
|
||||||
|
node_info->node_id,
|
||||||
|
upstream_node_info.node_name,
|
||||||
|
upstream_node_info.node_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
|
|||||||
Reference in New Issue
Block a user