mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Improve promotion failure handling
Exit with error; don't attempt to write event log as master connection will not be valid at this point.
This commit is contained in:
48
repmgr.c
48
repmgr.c
@@ -1619,42 +1619,28 @@ do_standby_promote(void)
|
|||||||
|
|
||||||
if (promote_sucess == false)
|
if (promote_sucess == false)
|
||||||
{
|
{
|
||||||
PQExpBufferData details;
|
|
||||||
initPQExpBuffer(&details);
|
|
||||||
appendPQExpBuffer(&details,
|
|
||||||
"Node %i could not be promoted to master",
|
|
||||||
options.node);
|
|
||||||
|
|
||||||
create_event_record(old_master_conn,
|
|
||||||
&options,
|
|
||||||
options.node,
|
|
||||||
"standby_promote",
|
|
||||||
false,
|
|
||||||
details.data);
|
|
||||||
/* XXX exit with error? */
|
|
||||||
log_err(_(retval == 1 ?
|
log_err(_(retval == 1 ?
|
||||||
"STANDBY PROMOTE failed, this is still a standby node.\n" :
|
"STANDBY PROMOTE failed, this is still a standby node.\n" :
|
||||||
"connection to node lost!\n"));
|
"connection to node lost!\n"));
|
||||||
}
|
exit(ERR_FAILOVER_FAIL);
|
||||||
else
|
|
||||||
{
|
|
||||||
PQExpBufferData details;
|
|
||||||
initPQExpBuffer(&details);
|
|
||||||
appendPQExpBuffer(&details,
|
|
||||||
"Node %i was successfully promoted to master",
|
|
||||||
options.node);
|
|
||||||
|
|
||||||
log_notice(_("STANDBY PROMOTE successful. You should REINDEX any hash indexes you have.\n"));
|
|
||||||
/* Log the event */
|
|
||||||
create_event_record(conn,
|
|
||||||
&options,
|
|
||||||
options.node,
|
|
||||||
"standby_promote",
|
|
||||||
true,
|
|
||||||
details.data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQfinish(old_master_conn);
|
PQExpBufferData details;
|
||||||
|
initPQExpBuffer(&details);
|
||||||
|
appendPQExpBuffer(&details,
|
||||||
|
"Node %i was successfully promoted to master",
|
||||||
|
options.node);
|
||||||
|
|
||||||
|
log_notice(_("STANDBY PROMOTE successful. You should REINDEX any hash indexes you have.\n"));
|
||||||
|
|
||||||
|
/* Log the event */
|
||||||
|
create_event_record(conn,
|
||||||
|
&options,
|
||||||
|
options.node,
|
||||||
|
"standby_promote",
|
||||||
|
true,
|
||||||
|
details.data);
|
||||||
|
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user