hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject incubator-hawq git commit: HAWQ-220. Add retry to connect postmaster when handle RUAlive message
Date Fri, 04 Dec 2015 07:05:20 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 74d6057ee -> 099717d29


HAWQ-220. Add retry to connect postmaster when handle RUAlive message


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/099717d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/099717d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/099717d2

Branch: refs/heads/master
Commit: 099717d29cbccaea3a5db8975c9fff4b141e74cb
Parents: 74d6057
Author: Wen Lin <wlin@pivotal.io>
Authored: Fri Dec 4 15:09:17 2015 +0800
Committer: Wen Lin <wlin@pivotal.io>
Committed: Fri Dec 4 15:09:17 2015 +0800

----------------------------------------------------------------------
 .../resourcemanager/requesthandler_RMSEG.c      | 34 ++++++++++++++------
 1 file changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/099717d2/src/backend/resourcemanager/requesthandler_RMSEG.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/requesthandler_RMSEG.c b/src/backend/resourcemanager/requesthandler_RMSEG.c
index 2d414b3..c96913d 100644
--- a/src/backend/resourcemanager/requesthandler_RMSEG.c
+++ b/src/backend/resourcemanager/requesthandler_RMSEG.c
@@ -226,19 +226,33 @@ bool handleRMSEGRequestRUAlive(void **arg)
 	int	libpqres = CONNECTION_OK;
 	PGconn *conn = NULL;
 	char conninfo[1024];
+	int retry = 5;
 
 	/* Check if can connect postmaster */
-	sprintf(conninfo, "options='-c gp_session_role=UTILITY' dbname=template1 port=%d connect_timeout=60",
seg_addr_port);
-	conn = PQconnectdb(conninfo);
-	if ((libpqres = PQstatus(conn)) != CONNECTION_OK) {
-		elog(LOG, "Segment postmaster is down, libpb conn result : %d, %s",
-				  libpqres,
-				  PQerrorMessage(conn));
-		/* Don't send IMAlive anymore */
-		DRMGlobalInstance->SendIMAlive = false;
+	sprintf(conninfo,
+			"options='-c gp_session_role=UTILITY' dbname=template1 port=%d connect_timeout=60",
+			seg_addr_port);
+	while (retry > 0) {
+		retry--;
+		conn = PQconnectdb(conninfo);
+		if ((libpqres = PQstatus(conn)) != CONNECTION_OK) {
+			if (retry == 0) {
+				elog(LOG, "Segment's postmaster is down, PQconnectdb result : %d, %s",
+						  libpqres,
+						  PQerrorMessage(conn));
+				/* Don't send IMAlive anymore */
+				DRMGlobalInstance->SendIMAlive = false;
+			}
+			else {
+				pg_usleep(500000);
+				continue;
+			}
+		}
+		else {
+			elog(DEBUG3, "Segment's postmaster is healthy.");
+			break;
+		}
 	}
-	else
-		elog(DEBUG3, "Segment postmaster is healthy.");
 
 	PQfinish(conn);
 


Mime
View raw message