mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
"standby switchover": sanity-check remote "repmgr" binary before proceeding
This commit is contained in:
@@ -292,8 +292,11 @@ do_standby_clone(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the replication user from the node's upstream record */
|
if (upstream_repluser[0] != '\0')
|
||||||
param_set(&recovery_conninfo, "user", upstream_repluser);
|
{
|
||||||
|
/* Write the replication user from the node's upstream record */
|
||||||
|
param_set(&recovery_conninfo, "user", upstream_repluser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1788,7 +1791,7 @@ do_standby_switchover(void)
|
|||||||
PQExpBufferData node_rejoin_options;
|
PQExpBufferData node_rejoin_options;
|
||||||
|
|
||||||
int r, i;
|
int r, i;
|
||||||
|
bool command_success = false;
|
||||||
bool shutdown_success = false;
|
bool shutdown_success = false;
|
||||||
XLogRecPtr remote_last_checkpoint_lsn = InvalidXLogRecPtr;
|
XLogRecPtr remote_last_checkpoint_lsn = InvalidXLogRecPtr;
|
||||||
ReplInfo replication_info = T_REPLINFO_INTIALIZER;
|
ReplInfo replication_info = T_REPLINFO_INTIALIZER;
|
||||||
@@ -1979,6 +1982,40 @@ do_standby_switchover(void)
|
|||||||
termPQExpBuffer(&msg);
|
termPQExpBuffer(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check remote repmgr binary can be found */
|
||||||
|
initPQExpBuffer(&remote_command_str);
|
||||||
|
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||||
|
|
||||||
|
appendPQExpBuffer(&remote_command_str, "--version");
|
||||||
|
initPQExpBuffer(&command_output);
|
||||||
|
command_success = remote_command(
|
||||||
|
remote_host,
|
||||||
|
runtime_options.remote_user,
|
||||||
|
remote_command_str.data,
|
||||||
|
&command_output);
|
||||||
|
|
||||||
|
termPQExpBuffer(&remote_command_str);
|
||||||
|
|
||||||
|
if (command_success == false)
|
||||||
|
{
|
||||||
|
log_error(_("unable to execute \"%s\" on \"%s\""),
|
||||||
|
progname(), remote_host);
|
||||||
|
|
||||||
|
if (strlen(command_output.data))
|
||||||
|
log_detail("%s", command_output.data);
|
||||||
|
|
||||||
|
termPQExpBuffer(&command_output);
|
||||||
|
PQfinish(remote_conn);
|
||||||
|
PQfinish(local_conn);
|
||||||
|
|
||||||
|
exit(ERR_BAD_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runtime_options.dry_run == true)
|
||||||
|
{
|
||||||
|
log_info(_("able to execute \"%s\" on remote host \"localhost\""), progname());
|
||||||
|
}
|
||||||
|
termPQExpBuffer(&command_output);
|
||||||
|
|
||||||
/* check archive/replication status */
|
/* check archive/replication status */
|
||||||
{
|
{
|
||||||
@@ -1991,7 +2028,6 @@ do_standby_switchover(void)
|
|||||||
{
|
{
|
||||||
int files = 0;
|
int files = 0;
|
||||||
int threshold = 0;
|
int threshold = 0;
|
||||||
bool command_success = false;
|
|
||||||
|
|
||||||
initPQExpBuffer(&remote_command_str);
|
initPQExpBuffer(&remote_command_str);
|
||||||
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
make_remote_repmgr_path(&remote_command_str, &remote_node_record);
|
||||||
|
|||||||
Reference in New Issue
Block a user