standby switchover: check remote's registered repmgr.conf

Check the demotion candidate's registered repmgr.conf file can be found.

If the configuration file has been deleted or moved, previously the
resulting error message would have been a confusing reference to
an incorrectly configured data directory; by explicitly checking for the
expected configuration file, we can make troubleshooting easier.

Original patch by laixiong <yin.zhb@gmail.com> (GitHub #615), modified
by Ian Barwick.
This commit is contained in:
laixiong
2019-12-16 22:03:04 +08:00
committed by Ian Barwick
parent 9cf4616af1
commit cb7bbda021

View File

@@ -3760,6 +3760,44 @@ do_standby_switchover(void)
}
termPQExpBuffer(&command_output);
/*
* Check if the expected remote repmgr.conf file exists
*/
initPQExpBuffer(&remote_command_str);
appendPQExpBuffer(&remote_command_str,
"test -f %s && echo 1 || echo 0",
remote_node_record.config_file);
initPQExpBuffer(&command_output);
command_success = remote_command(remote_host,
runtime_options.remote_user,
remote_command_str.data,
config_file_options.ssh_options,
&command_output);
termPQExpBuffer(&remote_command_str);
if (command_success == false || command_output.data[0] == '0')
{
log_error(_("expected configuration file not found on the demotion candiate \"%s\" (ID: %i)"),
remote_node_record.node_name,
remote_node_record.node_id);
log_detail(_("registered configuration file is \"%s\""),
remote_node_record.config_file);
log_hint(_("ensure the configuration file is in the expected location, or re-register \"%s\" to update the configuration file location"),
remote_node_record.node_name);
PQfinish(remote_conn);
PQfinish(local_conn);
termPQExpBuffer(&command_output);
exit(ERR_BAD_CONFIG);
}
/*
* Sanity-check remote "data_directory" is correctly configured in repmgr.conf.
*