repmgr node rejoin: handle missing node record correctly

If a connection was provided for a database other than the "repmgr"
database, error was logged but execution continued, resulting in
the connection being finished twice.

Addresses GitHub #358.
This commit is contained in:
Ian Barwick
2018-01-03 15:17:01 +09:00
parent 9951a8e106
commit 5d8ec136e6

View File

@@ -1629,7 +1629,7 @@ do_node_rejoin(void)
/* check provided upstream connection */
upstream_conn = establish_db_connection_by_params(&source_conninfo, true);
/* sanity-checks for 9.3 */
/* sanity checks for 9.3 */
server_version_num = get_server_version(upstream_conn, NULL);
if (server_version_num < 90400)
@@ -1638,7 +1638,9 @@ do_node_rejoin(void)
if (get_primary_node_record(upstream_conn, &primary_node_record) == false)
{
log_error(_("unable to retrieve primary node record"));
log_hint(_("check the provided database connection string is for a \"repmgr\" database"));
PQfinish(upstream_conn);
exit(ERR_BAD_CONFIG);
}
PQfinish(upstream_conn);