Now STANDBY SWITCHOVER and STANDBY FOLLOW log an event notification on

success and also on some failures, precisely those when it makes sense
or it is reasonably possible to do so.
This commit is contained in:
Gianni Ciolli
2016-08-05 08:30:39 +02:00
committed by Ian Barwick
parent 59b1924d5b
commit abb16e4366

View File

@@ -2792,6 +2792,13 @@ do_standby_follow(void)
}
/* XXX add event record - possible move from repmgrd? */
create_event_record(master_conn,
&options,
options.node,
"standby_follow",
true,
NULL);
PQfinish(master_conn);
return;
@@ -3499,9 +3506,20 @@ do_standby_switchover(void)
if (query_result == -1)
{
log_err(_("unable to retrieve replication status for node %i\n"), remote_node_id);
PQExpBufferData event_details;
initPQExpBuffer(&event_details);
appendPQExpBuffer(&event_details,
_("unable to retrieve replication status for node %i"),
remote_node_id);
log_err("%s\n", event_details.data);
create_event_record(local_conn,
&options,
options.node,
"standby_switchover",
false,
event_details.data);
termPQExpBuffer(&event_details);
PQfinish(local_conn);
exit(ERR_SWITCHOVER_FAIL);
}
@@ -3525,8 +3543,19 @@ do_standby_switchover(void)
* - backup
* - UNKNOWN
*/
log_err(_("node %i has unexpected replication state \"%s\"\n"),
remote_node_id, remote_node_replication_state);
PQExpBufferData event_details;
initPQExpBuffer(&event_details);
appendPQExpBuffer(&event_details,
_("node %i has unexpected replication state \"%s\""),
remote_node_id, remote_node_replication_state);
log_err("%s\n", event_details.data);
create_event_record(local_conn,
&options,
options.node,
"standby_switchover",
false,
event_details.data);
termPQExpBuffer(&event_details);
PQfinish(local_conn);
exit(ERR_SWITCHOVER_FAIL);
}
@@ -3583,6 +3612,13 @@ do_standby_switchover(void)
/* TODO: verify this node's record was updated correctly */
create_event_record(local_conn,
&options,
options.node,
"standby_switchover",
true,
NULL);
PQfinish(local_conn);
log_notice(_("switchover was successful\n"));