From 9313b43cb1589a9334a4697eefd3618ea33f38a6 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 16 Aug 2018 16:14:14 +0900 Subject: [PATCH] repmgrd: fix PQExpBuffer handling in upstream failover handler Was sometimes leading to blank log lines. --- repmgrd-physical.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/repmgrd-physical.c b/repmgrd-physical.c index 9c14bee6..30b80e37 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -1858,8 +1858,6 @@ do_upstream_standby_failover(void) /* Close the connection to this server */ close_connection(&local_conn); - initPQExpBuffer(&event_details); - log_debug(_("standby follow command is:\n \"%s\""), config_file_options.follow_command); @@ -1873,6 +1871,8 @@ do_upstream_standby_failover(void) if (r != 0) { + initPQExpBuffer(&event_details); + appendPQExpBuffer(&event_details, _("unable to execute follow command:\n %s"), config_file_options.follow_command); @@ -1883,8 +1883,7 @@ do_upstream_standby_failover(void) * It may not possible to write to the event notification table but we * should be able to generate an external notification if required. */ - create_event_notification( - primary_conn, + create_event_notification(primary_conn, &config_file_options, local_node_info.node_id, "repmgrd_failover_follow", @@ -1926,6 +1925,8 @@ do_upstream_standby_failover(void) local_node_info.node_id, primary_node_info.node_id) == false) { + initPQExpBuffer(&event_details); + appendPQExpBuffer(&event_details, _("unable to set node %i's new upstream ID to %i"), local_node_info.node_id, @@ -1959,6 +1960,8 @@ do_upstream_standby_failover(void) local_node_info.upstream_node_id = primary_node_info.node_id; } + initPQExpBuffer(&event_details); + appendPQExpBuffer(&event_details, _("node %i is now following primary node %i"), local_node_info.node_id, @@ -1966,8 +1969,7 @@ do_upstream_standby_failover(void) log_notice("%s", event_details.data); - create_event_notification( - primary_conn, + create_event_notification(primary_conn, &config_file_options, local_node_info.node_id, "repmgrd_failover_follow",