From e05bab828402ebb874d39a591114e472937a4885 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 28 Aug 2017 14:50:08 +0900 Subject: [PATCH] "standby switchover": epxlictly confirm suitability for --pg-rewind If --force-rewind requested. --- repmgr-action-standby.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 0b67a3e7..f6e789a8 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -1766,6 +1766,7 @@ do_standby_switchover(void) if (runtime_options.force_rewind == true) { PQExpBufferData reason; + PQExpBufferData msg; initPQExpBuffer(&reason); @@ -1779,9 +1780,22 @@ do_standby_switchover(void) exit(ERR_BAD_CONFIG); } - termPQExpBuffer(&reason); + initPQExpBuffer(&msg); + appendPQExpBuffer(&msg, + _("pre-requisites for using pg_rewind are met")); + + if (runtime_options.dry_run == true) + { + log_info("%s", msg.data); + } + else + { + log_verbose(LOG_INFO, "%s", msg.data); + } + termPQExpBuffer(&msg); + get_datadir_configuration_files(remote_conn, &remote_config_files); } @@ -1960,8 +1974,6 @@ do_standby_switchover(void) log_debug("lag is %i ", lag_seconds); - termPQExpBuffer(&command_output); - if (lag_seconds >= config_file_options.replication_lag_critical) { if (runtime_options.force == false) @@ -2192,6 +2204,10 @@ do_standby_switchover(void) log_info(_("following shutdown command would be run on node \"%s\":\n \"%s\""), remote_node_record.node_name, shutdown_command); + + clear_node_info_list(&sibling_nodes); + key_value_list_free(&remote_config_files); + return; } @@ -2337,6 +2353,8 @@ do_standby_switchover(void) appendPQExpBuffer(&node_rejoin_options, " "); } + key_value_list_free(&remote_config_files); + initPQExpBuffer(&remote_command_str); make_remote_repmgr_path(&remote_command_str, &remote_node_record); @@ -2458,10 +2476,10 @@ do_standby_switchover(void) /* TODO: double-check all expected nodes are in pg_stat_replication and * entries in repmgr.nodes match */ - - clear_node_info_list(&sibling_nodes); } + clear_node_info_list(&sibling_nodes); + PQfinish(local_conn); log_notice(_("STANDBY SWITCHOVER is complete"));