mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
repmgr standby promote: add detail about an existing master
This commit is contained in:
@@ -1053,6 +1053,8 @@ do_standby_promote(void)
|
|||||||
bool success;
|
bool success;
|
||||||
PQExpBufferData details;
|
PQExpBufferData details;
|
||||||
|
|
||||||
|
int existing_master_id = UNKNOWN_NODE_ID;
|
||||||
|
|
||||||
log_info(_("connecting to standby database"));
|
log_info(_("connecting to standby database"));
|
||||||
conn = establish_db_connection(config_file_options.conninfo, true);
|
conn = establish_db_connection(config_file_options.conninfo, true);
|
||||||
|
|
||||||
@@ -1082,12 +1084,23 @@ do_standby_promote(void)
|
|||||||
|
|
||||||
|
|
||||||
/* we also need to check if there isn't any master already */
|
/* we also need to check if there isn't any master already */
|
||||||
current_master_conn = get_master_connection(conn, NULL, NULL);
|
current_master_conn = get_master_connection(conn, &existing_master_id, NULL);
|
||||||
|
|
||||||
if (PQstatus(current_master_conn) == CONNECTION_OK)
|
if (PQstatus(current_master_conn) == CONNECTION_OK)
|
||||||
{
|
{
|
||||||
log_error(_("this cluster already has an active master server"));
|
log_error(_("this cluster already has an active master server"));
|
||||||
// say which one as detail
|
|
||||||
|
if (existing_master_id != UNKNOWN_NODE_ID)
|
||||||
|
{
|
||||||
|
t_node_info master_rec;
|
||||||
|
|
||||||
|
get_node_record(conn, existing_master_id, &master_rec);
|
||||||
|
|
||||||
|
log_detail(_("current master is %s (node_id: %i)"),
|
||||||
|
master_rec.node_name,
|
||||||
|
existing_master_id);
|
||||||
|
}
|
||||||
|
|
||||||
PQfinish(current_master_conn);
|
PQfinish(current_master_conn);
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
exit(ERR_PROMOTION_FAIL);
|
exit(ERR_PROMOTION_FAIL);
|
||||||
|
|||||||
@@ -1262,8 +1262,6 @@ do_help(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the repmgr extension, and grant access for the repmgr
|
* Create the repmgr extension, and grant access for the repmgr
|
||||||
* user if not a superuser.
|
* user if not a superuser.
|
||||||
|
|||||||
Reference in New Issue
Block a user