repmgrd: tweak event notifications on standby failure

The event notification was only being created if there was a valid
primary connection; it should be created in any case, so an event
notification script can be executed.
This commit is contained in:
Ian Barwick
2018-04-17 10:27:25 +09:00
parent cda952f1e4
commit 85ab2d94b7

View File

@@ -999,22 +999,21 @@ loop:
{
if (local_node_info.active == true)
{
bool success = true;
PQExpBufferData event_details;
initPQExpBuffer(&event_details);
local_node_info.active = false;
appendPQExpBuffer(&event_details,
_("unable to connect to local node \"%s\" (ID: %i), marking inactive"),
local_node_info.node_name,
local_node_info.node_id);
log_notice("%s", event_details.data);
if (PQstatus(primary_conn) == CONNECTION_OK)
{
PQExpBufferData event_details;
bool success = true;
initPQExpBuffer(&event_details);
local_node_info.active = false;
appendPQExpBuffer(&event_details,
_("unable to connect to local node \"%s\" (ID: %i), marking inactive"),
local_node_info.node_name,
local_node_info.node_id);
log_notice("%s", event_details.data);
if (update_node_record_set_active(primary_conn, local_node_info.node_id, false) == false)
{
success = false;
@@ -1022,16 +1021,16 @@ loop:
local_node_info.node_name,
local_node_info.node_id);
}
create_event_notification(primary_conn,
&config_file_options,
local_node_info.node_id,
"standby_failure",
success,
event_details.data);
termPQExpBuffer(&event_details);
}
create_event_notification(primary_conn,
&config_file_options,
local_node_info.node_id,
"standby_failure",
success,
event_details.data);
termPQExpBuffer(&event_details);
}
}
else