mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
Prevent multiple nodes being registered with the same name.
Fixes GitHub #192.
This commit is contained in:
25
repmgr.c
25
repmgr.c
@@ -1127,8 +1127,9 @@ do_standby_register(void)
|
||||
PGconn *master_conn;
|
||||
int ret;
|
||||
|
||||
|
||||
bool record_created;
|
||||
t_node_info node_record;
|
||||
int node_result;
|
||||
|
||||
log_info(_("connecting to standby database\n"));
|
||||
conn = establish_db_connection(options.conninfo, true);
|
||||
@@ -1185,6 +1186,28 @@ do_standby_register(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that an active node with the same node_name doesn't exist already
|
||||
*/
|
||||
|
||||
node_result = get_node_record_by_name(master_conn,
|
||||
options.cluster_name,
|
||||
options.node_name,
|
||||
&node_record);
|
||||
|
||||
if (node_result)
|
||||
{
|
||||
if (node_record.active == true)
|
||||
{
|
||||
log_err(_("Node %i exists already with node_name \"%s\""),
|
||||
node_record.node_id,
|
||||
options.node_name);
|
||||
PQfinish(master_conn);
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
record_created = create_node_record(master_conn,
|
||||
"standby register",
|
||||
options.node,
|
||||
|
||||
Reference in New Issue
Block a user