mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
Gracefully fail when node has not been registered
This commit is contained in:
14
repmgrd.c
14
repmgrd.c
@@ -276,6 +276,13 @@ main(int argc, char **argv)
|
||||
|
||||
/* Retrieve record for this node from the database */
|
||||
node_info = get_node_info(my_local_conn, local_options.cluster_name, local_options.node);
|
||||
|
||||
if(node_info.node_id == -1)
|
||||
{
|
||||
log_err(_("Node %i is not registered\n"), local_options.node);
|
||||
terminate(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
log_debug("Node id is %i, upstream is %i\n", node_info.node_id, node_info.upstream_node_id);
|
||||
|
||||
/*
|
||||
@@ -2067,6 +2074,13 @@ get_node_info(PGconn *conn, char *cluster, int node_id)
|
||||
terminate(ERR_DB_QUERY);
|
||||
}
|
||||
|
||||
if (!PQntuples(res)) {
|
||||
log_warning(_("No record found record for node %i\n"), node_id);
|
||||
PQclear(res);
|
||||
node_info.node_id = -1;
|
||||
return node_info;
|
||||
}
|
||||
|
||||
node_info.node_id = atoi(PQgetvalue(res, 0, 0));
|
||||
node_info.upstream_node_id = atoi(PQgetvalue(res, 0, 1));
|
||||
strncpy(node_info.conninfo_str, PQgetvalue(res, 0, 2), MAXLEN);
|
||||
|
||||
Reference in New Issue
Block a user