mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
repmgrd: avoid additional connection to local instance in do_master_failover()
This commit is contained in:
16
repmgrd.c
16
repmgrd.c
@@ -1412,9 +1412,6 @@ do_master_failover(void)
|
|||||||
PQfinish(node_conn);
|
PQfinish(node_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the connection to this server */
|
|
||||||
PQfinish(my_local_conn);
|
|
||||||
my_local_conn = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* determine which one is the best candidate to promote to master
|
* determine which one is the best candidate to promote to master
|
||||||
@@ -1469,6 +1466,10 @@ do_master_failover(void)
|
|||||||
{
|
{
|
||||||
PQExpBufferData event_details;
|
PQExpBufferData event_details;
|
||||||
|
|
||||||
|
/* Close the connection to this server */
|
||||||
|
PQfinish(my_local_conn);
|
||||||
|
my_local_conn = NULL;
|
||||||
|
|
||||||
initPQExpBuffer(&event_details);
|
initPQExpBuffer(&event_details);
|
||||||
/* wait */
|
/* wait */
|
||||||
sleep(5);
|
sleep(5);
|
||||||
@@ -1544,6 +1545,7 @@ do_master_failover(void)
|
|||||||
{
|
{
|
||||||
PGconn *new_master_conn;
|
PGconn *new_master_conn;
|
||||||
PQExpBufferData event_details;
|
PQExpBufferData event_details;
|
||||||
|
int master_node_id;
|
||||||
|
|
||||||
initPQExpBuffer(&event_details);
|
initPQExpBuffer(&event_details);
|
||||||
|
|
||||||
@@ -1554,10 +1556,6 @@ do_master_failover(void)
|
|||||||
* Check whether the primary reappeared while we were waiting, so we
|
* Check whether the primary reappeared while we were waiting, so we
|
||||||
* don't end up following the promotion candidate
|
* don't end up following the promotion candidate
|
||||||
*/
|
*/
|
||||||
my_local_conn = establish_db_connection(local_options.conninfo, false);
|
|
||||||
if (my_local_conn != NULL)
|
|
||||||
{
|
|
||||||
int master_node_id;
|
|
||||||
|
|
||||||
master_conn = get_master_connection(my_local_conn,
|
master_conn = get_master_connection(my_local_conn,
|
||||||
local_options.cluster_name,
|
local_options.cluster_name,
|
||||||
@@ -1574,7 +1572,6 @@ do_master_failover(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PQfinish(my_local_conn);
|
PQfinish(my_local_conn);
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX double-check the promotion candidate did become the new primary */
|
/* XXX double-check the promotion candidate did become the new primary */
|
||||||
|
|
||||||
@@ -1590,6 +1587,9 @@ do_master_failover(void)
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Close the connection to this server */
|
||||||
|
PQfinish(my_local_conn);
|
||||||
|
my_local_conn = NULL;
|
||||||
|
|
||||||
log_debug(_("executing follow command: \"%s\"\n"), local_options.follow_command);
|
log_debug(_("executing follow command: \"%s\"\n"), local_options.follow_command);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user