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 f8908d7e31
commit 90cba78f52

View File

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