diff --git a/repmgr-action-node.c b/repmgr-action-node.c index 7f26d929..74c7e1e9 100644 --- a/repmgr-action-node.c +++ b/repmgr-action-node.c @@ -2707,9 +2707,18 @@ do_node_control(void) if (runtime_options.enable_wal_receiver == true) { - wal_receiver_pid = enable_wal_receiver(conn); + wal_receiver_pid = enable_wal_receiver(conn, true); + + PQfinish(conn); + + if (wal_receiver_pid == UNKNOWN_PID) + exit(ERR_BAD_CONFIG); + + exit(SUCCESS); } + log_error(_("no option provided")); + PQfinish(conn); } diff --git a/repmgrd-physical.c b/repmgrd-physical.c index 2d4fc6cc..e9721568 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -2078,8 +2078,8 @@ do_primary_failover(void) /* Reenable WAL receiver, if disabled and node is not the promotion candidate */ if (config_file_options.standby_disconnect_on_failover == true && election_result != ELECTION_WON) { - // XXX check return value - enable_wal_receiver(local_conn); + /* adjust "wal_retrieve_retry_interval" but don't wait for WAL receiver to start */ + enable_wal_receiver(local_conn, false); } if (election_result == ELECTION_CANCELLED) diff --git a/sysutils.c b/sysutils.c index a1473fe8..7aa5687c 100644 --- a/sysutils.c +++ b/sysutils.c @@ -276,7 +276,7 @@ disable_wal_receiver(PGconn *conn) } pid_t -enable_wal_receiver(PGconn *conn) +enable_wal_receiver(PGconn *conn, bool wait_startup) { char buf[MAXLEN]; int wal_retrieve_retry_interval; @@ -326,6 +326,9 @@ enable_wal_receiver(PGconn *conn) wal_retrieve_retry_interval); } + if (wait_startup == false) + return UNKNOWN_PID; + for (i = 0; i < timeout; i++) { wal_receiver_pid = (pid_t)get_wal_receiver_pid(conn); diff --git a/sysutils.h b/sysutils.h index 4ddc3d36..6c046920 100644 --- a/sysutils.h +++ b/sysutils.h @@ -26,7 +26,7 @@ extern bool local_command_simple(const char *command, PQExpBufferData *outputbuf extern bool remote_command(const char *host, const char *user, const char *command, const char *ssh_options, PQExpBufferData *outputbuf); extern pid_t disable_wal_receiver(PGconn *conn); -extern pid_t enable_wal_receiver(PGconn *conn); +extern pid_t enable_wal_receiver(PGconn *conn, bool wait_startup); #endif /* _SYSUTILS_H_ */