mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 00:46:29 +00:00
Add %v, %u and %t parameters to "failover_validation_command"
These indicate: - the number of visible nodes sharing the current upstream - the number of nodes on the current upstream - the total number of nodes in the entire repmgr cluster. This allows the failover_validation_command to be used to perform more thorough validations, including cross-referencing external cluster management state (e.g. if managed by kubernetes). GitHub #651.
This commit is contained in:
committed by
Ian Barwick
parent
f1bdb09512
commit
73e8373337
31
dbutils.c
31
dbutils.c
@@ -2907,6 +2907,37 @@ get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||
return success;
|
||||
}
|
||||
|
||||
bool
|
||||
get_all_nodes_count(PGconn *conn, int *count)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
bool success = true;
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBufferStr(&query,
|
||||
" SELECT count(*) "
|
||||
" FROM repmgr.nodes n ");
|
||||
|
||||
log_verbose(LOG_DEBUG, "get_all_nodes_count():\n%s", query.data);
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_all_nodes_count(): unable to execute query"));
|
||||
success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
*count = atoi(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
||||
|
||||
Reference in New Issue
Block a user