standby clone: check upstream connections after data copy operation

With long-running copy operations, it's possible the connection(s) to
the primary/source server may go away for some reason, so recheck
their availability before attempting to reuse.
This commit is contained in:
Ian Barwick
2019-02-26 14:33:54 +09:00
parent 23569a19b1
commit 39234afcbf
5 changed files with 44 additions and 1 deletions

View File

@@ -4272,6 +4272,25 @@ connection_ping(PGconn *conn)
}
ExecStatusType
connection_ping_reconnect(PGconn *conn)
{
ExecStatusType ping_result = connection_ping(conn);
if (PQstatus(conn) != CONNECTION_OK)
{
log_warning(_("connection error, attempting to reset"));
log_detail("%s", PQerrorMessage(conn));
PQreset(conn);
ping_result = connection_ping(conn);
}
log_verbose(LOG_DEBUG, "connection_ping_reconnect(): result is %s", PQresStatus(ping_result));
return ping_result;
}
/* ==================== */
/* monitoring functions */