From 90cba78f5215b9a76081d810e6e850eae31afabd Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 17 Apr 2018 10:27:25 +0900 Subject: [PATCH] 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. --- repmgrd-physical.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/repmgrd-physical.c b/repmgrd-physical.c index c3d7656f..3c79c9f6 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -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