mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 00:26:30 +00:00
Fix query in is_active_bdr_node()
Boolean column was not being checked correctly. Also add detail output in "repmgr node role --check", where the function is called.
This commit is contained in:
@@ -4163,20 +4163,23 @@ is_active_bdr_node(PGconn *conn, const char *node_name)
|
|||||||
" SELECT COALESCE(s.active, TRUE) AS active"
|
" SELECT COALESCE(s.active, TRUE) AS active"
|
||||||
" FROM bdr.bdr_nodes n "
|
" FROM bdr.bdr_nodes n "
|
||||||
" LEFT JOIN pg_catalog.pg_replication_slots s "
|
" LEFT JOIN pg_catalog.pg_replication_slots s "
|
||||||
" ON slot_name=bdr.bdr_format_slot_name(n.node_sysid, n.node_timeline, n.node_dboid, (SELECT oid FROM pg_database WHERE datname = current_database())) "
|
" ON s.slot_name=bdr.bdr_format_slot_name(n.node_sysid, n.node_timeline, n.node_dboid, (SELECT oid FROM pg_catalog.pg_database WHERE datname = pg_catalog.current_database())) "
|
||||||
" WHERE node_name='%s' ",
|
" WHERE n.node_name='%s' ",
|
||||||
node_name);
|
node_name);
|
||||||
|
|
||||||
|
log_verbose(LOG_DEBUG, "is_active_bdr_node():\n %s", query.data);
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
|
|
||||||
|
/* we don't care if the query fails */
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) == 0)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) == 0)
|
||||||
{
|
{
|
||||||
is_active_bdr_node = false;
|
is_active_bdr_node = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
is_active_bdr_node = atoi(PQgetvalue(res, 0, 0)) == 1 ? true : false;
|
is_active_bdr_node = atobool(PQgetvalue(res, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|||||||
@@ -728,8 +728,7 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(
|
appendPQExpBuffer(&details,
|
||||||
&details,
|
|
||||||
_("node is primary"));
|
_("node is primary"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -754,8 +753,7 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
|||||||
if (is_bdr_db(conn, &output) == false)
|
if (is_bdr_db(conn, &output) == false)
|
||||||
{
|
{
|
||||||
status = CHECK_STATUS_CRITICAL;
|
status = CHECK_STATUS_CRITICAL;
|
||||||
appendPQExpBuffer(
|
appendPQExpBuffer(&details,
|
||||||
&details,
|
|
||||||
"%s", output.data);
|
"%s", output.data);
|
||||||
}
|
}
|
||||||
termPQExpBuffer(&output);
|
termPQExpBuffer(&output);
|
||||||
@@ -768,6 +766,11 @@ do_node_check_role(PGconn *conn, OutputMode mode, t_node_info *node_info, CheckS
|
|||||||
appendPQExpBuffer(&details,
|
appendPQExpBuffer(&details,
|
||||||
_("node is not an active BDR node"));
|
_("node is not an active BDR node"));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendPQExpBuffer(&details,
|
||||||
|
_("node is an active BDR node"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user