repmgrd: ensure primary connection is reset if same as upstream

Addresses GitHub #633.
This commit is contained in:
Ian Barwick
2020-05-22 10:36:56 +09:00
parent a0d3fae7ab
commit cf60844c45
3 changed files with 42 additions and 7 deletions

View File

@@ -808,12 +808,11 @@ show_help(void)
bool
check_upstream_connection(PGconn **conn, const char *conninfo)
check_upstream_connection(PGconn **conn, const char *conninfo, PGconn **paired_conn)
{
/* Check the connection status twice in case it changes after reset */
bool twice = false;
log_debug("connection check type is \"%s\"",
print_connection_check_type(config_file_options.connection_check_type));
/*
@@ -862,7 +861,15 @@ check_upstream_connection(PGconn **conn, const char *conninfo)
*conn = PQconnectdb(conninfo);
if (PQstatus(*conn) == CONNECTION_OK)
{
if (paired_conn != NULL)
{
log_debug("resetting paired connection");
*paired_conn = *conn;
}
return true;
}
return false;
}
@@ -913,6 +920,12 @@ check_upstream_connection(PGconn **conn, const char *conninfo)
}
}
if (paired_conn != NULL)
{
log_debug("resetting paired connection");
*paired_conn = *conn;
}
return true;
}