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:
Ian Barwick
2015-04-14 13:09:02 +09:00
parent 2ad4f68700
commit 68e3a9d7ab

View File

@@ -1619,25 +1619,12 @@ 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; PQExpBufferData details;
initPQExpBuffer(&details); initPQExpBuffer(&details);
appendPQExpBuffer(&details, appendPQExpBuffer(&details,
@@ -1645,6 +1632,7 @@ do_standby_promote(void)
options.node); options.node);
log_notice(_("STANDBY PROMOTE successful. You should REINDEX any hash indexes you have.\n")); log_notice(_("STANDBY PROMOTE successful. You should REINDEX any hash indexes you have.\n"));
/* Log the event */ /* Log the event */
create_event_record(conn, create_event_record(conn,
&options, &options,
@@ -1652,9 +1640,7 @@ do_standby_promote(void)
"standby_promote", "standby_promote",
true, true,
details.data); details.data);
}
PQfinish(old_master_conn);
PQfinish(conn); PQfinish(conn);
return; return;