repmgrd: fix PQExpBuffer handling in upstream failover handler

Was sometimes leading to blank log lines.
This commit is contained in:
Ian Barwick
2018-08-16 16:14:14 +09:00
parent 5aeb1b0589
commit 9313b43cb1

View File

@@ -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",