mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
standby switchover: add hint for diagnosing remote DB connection failure
Output a command, which when excuted on the local node (promotion candidate) will attempt to remotely connect to the demotion candidate and display both the connection message encountered and the connection parameters used. This is useful for corner-cases where the connection normally succeeds if a particular environment variable (e.g. PGPORT) is normally set, but is not set in the environment where SSH is executed.
This commit is contained in:
43
sysutils.c
43
sysutils.c
@@ -118,28 +118,13 @@ remote_command(const char *host, const char *user, const char *command, const ch
|
||||
{
|
||||
FILE *fp;
|
||||
PQExpBufferData ssh_command;
|
||||
PQExpBufferData ssh_host;
|
||||
|
||||
char output[MAXLEN] = "";
|
||||
|
||||
initPQExpBuffer(&ssh_host);
|
||||
|
||||
if (*user != '\0')
|
||||
{
|
||||
appendPQExpBuffer(&ssh_host, "%s@", user);
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&ssh_host, host);
|
||||
|
||||
initPQExpBuffer(&ssh_command);
|
||||
|
||||
appendPQExpBuffer(&ssh_command,
|
||||
"ssh -o Batchmode=yes %s %s %s",
|
||||
ssh_options,
|
||||
ssh_host.data,
|
||||
command);
|
||||
|
||||
termPQExpBuffer(&ssh_host);
|
||||
make_remote_command(host, user, command, ssh_options, &ssh_command);
|
||||
|
||||
log_debug("remote_command():\n %s", ssh_command.data);
|
||||
|
||||
@@ -187,6 +172,32 @@ remote_command(const char *host, const char *user, const char *command, const ch
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
make_remote_command(const char *host, const char *user, const char *command, const char *ssh_options, PQExpBufferData *ssh_command)
|
||||
{
|
||||
PQExpBufferData ssh_host;
|
||||
|
||||
initPQExpBuffer(&ssh_host);
|
||||
|
||||
if (*user != '\0')
|
||||
{
|
||||
appendPQExpBuffer(&ssh_host, "%s@", user);
|
||||
}
|
||||
|
||||
appendPQExpBufferStr(&ssh_host, host);
|
||||
|
||||
|
||||
appendPQExpBuffer(ssh_command,
|
||||
"ssh -o Batchmode=yes %s %s %s",
|
||||
ssh_options,
|
||||
ssh_host.data,
|
||||
command);
|
||||
|
||||
termPQExpBuffer(&ssh_host);
|
||||
|
||||
}
|
||||
|
||||
|
||||
pid_t
|
||||
disable_wal_receiver(PGconn *conn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user