mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-28 01:16:29 +00:00
fix: remove own node earlier if force is set
We have to remove our own node before we check for a new master if force is set; else master register would fail on the second time since there already is a master (ourselves), even if we specify -F
This commit is contained in:
25
repmgr.c
25
repmgr.c
@@ -565,18 +565,6 @@ do_master_register(void)
|
||||
PGconn *master_conn;
|
||||
int id;
|
||||
|
||||
/* Ensure there isn't any other master already registered */
|
||||
master_conn = getMasterConnection(conn, repmgr_schema,
|
||||
options.cluster_name, &id,NULL);
|
||||
if (master_conn != NULL)
|
||||
{
|
||||
PQfinish(master_conn);
|
||||
log_warning(_("There is a master already in cluster %s\n"), options.cluster_name);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now register the master */
|
||||
if (runtime_options.force)
|
||||
{
|
||||
sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_nodes "
|
||||
@@ -593,6 +581,19 @@ do_master_register(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Ensure there isn't any other master already registered */
|
||||
master_conn = getMasterConnection(conn, repmgr_schema,
|
||||
options.cluster_name, &id,NULL);
|
||||
if (master_conn != NULL)
|
||||
{
|
||||
PQfinish(master_conn);
|
||||
log_warning(_("There is a master already in cluster %s\n"), options.cluster_name);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now register the master */
|
||||
|
||||
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes (id, cluster, name, conninfo, priority) "
|
||||
"VALUES (%d, '%s', '%s', '%s', %d)",
|
||||
repmgr_schema, options.node, options.cluster_name, options.node_name,
|
||||
|
||||
Reference in New Issue
Block a user