hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esp...@apache.org
Subject [11/50] [abbrv] incubator-hawq git commit: HAWQ-1258. Segment resource manager does not switch back when it cannot resolve standby host name
Date Fri, 03 Feb 2017 09:00:13 GMT
HAWQ-1258. Segment resource manager does not switch back when it cannot resolve standby host
name


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

Branch: refs/heads/2.1.0.0-incubating
Commit: 2a7c20f2b5eff1563d3f2a7c8f7504bec2099bd3
Parents: ad71873
Author: Yi <yjin@pivotal.io>
Authored: Wed Jan 11 19:40:08 2017 +1100
Committer: Yi <yjin@pivotal.io>
Committed: Wed Jan 11 19:40:08 2017 +1100

----------------------------------------------------------------------
 .../resourcemanager/communication/rmcomm_RMSEG2RM.c      | 10 ++++++----
 src/backend/resourcemanager/include/dynrm.h              |  2 ++
 src/backend/resourcemanager/resourcemanager_RMSEG.c      | 11 +++++++++++
 src/backend/utils/misc/guc.c                             |  2 +-
 4 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2a7c20f2/src/backend/resourcemanager/communication/rmcomm_RMSEG2RM.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/communication/rmcomm_RMSEG2RM.c b/src/backend/resourcemanager/communication/rmcomm_RMSEG2RM.c
index 92946c8..4c93f78 100644
--- a/src/backend/resourcemanager/communication/rmcomm_RMSEG2RM.c
+++ b/src/backend/resourcemanager/communication/rmcomm_RMSEG2RM.c
@@ -107,8 +107,10 @@ int sendIMAlive(int  *errorcode,
 	if ( res != FUNC_RETURN_OK )
 	{
 		rm_pfree(AsyncCommContext, context);
-		elog(WARNING, "Fail to register asynchronous connection for sending "
-					  "IMAlive message. %d", res);
+		elog(LOG, "failed to register asynchronous connection for sending "
+			      "IMAlive message. %d", res);
+		/* Always switch if fail to register connection here. */
+		switchIMAliveSendingTarget();
 		return res;
 	}
 
@@ -140,7 +142,7 @@ void receivedIMAliveResponse(AsyncCommMessageHandlerContext  context,
 		 buffersize != sizeof(RPCResponseIMAliveData) ) {
 		elog(WARNING, "Segment's resource manager received wrong response for "
 					  "heart-beat request.");
-		DRMGlobalInstance->SendToStandby = !DRMGlobalInstance->SendToStandby;
+		switchIMAliveSendingTarget();
 	}
 	else
 	{
@@ -165,7 +167,7 @@ void sentIMAliveError(AsyncCommMessageHandlerContext context)
 	else
 		elog(WARNING, "Segment's resource manager sending IMAlive message "
 					  "switches from master to standby");
-	DRMGlobalInstance->SendToStandby = !DRMGlobalInstance->SendToStandby;
+	switchIMAliveSendingTarget();
 }
 
 void sentIMAliveCleanUp(AsyncCommMessageHandlerContext context)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2a7c20f2/src/backend/resourcemanager/include/dynrm.h
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/include/dynrm.h b/src/backend/resourcemanager/include/dynrm.h
index bd4a303..a6309c8 100644
--- a/src/backend/resourcemanager/include/dynrm.h
+++ b/src/backend/resourcemanager/include/dynrm.h
@@ -322,4 +322,6 @@ int  initializeSocketServer_RMSEG(void);
 int  MainHandlerLoop_RMSEG(void);
 
 void checkAndBuildFailedTmpDirList(void);
+
+void switchIMAliveTarget(void);
 #endif //DYNAMIC_RESOURCE_MANAGEMENT_H

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2a7c20f2/src/backend/resourcemanager/resourcemanager_RMSEG.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/resourcemanager_RMSEG.c b/src/backend/resourcemanager/resourcemanager_RMSEG.c
index f3042eb..f8afe5a 100644
--- a/src/backend/resourcemanager/resourcemanager_RMSEG.c
+++ b/src/backend/resourcemanager/resourcemanager_RMSEG.c
@@ -275,3 +275,14 @@ void checkAndBuildFailedTmpDirList(void)
 			  "directory, which costs " UINT64_FORMAT " us",
 			  endtime - starttime);
 }
+
+void switchIMAliveSendingTarget(void)
+{
+	/* We switch to standby server only when it is correctly set. */
+	if (pg_strcasecmp(standby_addr_host, "none") != 0)
+	{
+		DRMGlobalInstance->SendToStandby = !DRMGlobalInstance->SendToStandby;
+		elog(LOG, "segment will send heart-beat to %s from now on",
+				  DRMGlobalInstance->SendToStandby ? "standby" : "master");
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2a7c20f2/src/backend/utils/misc/guc.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index dccd599..fbf19cf 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -8200,7 +8200,7 @@ static struct config_string ConfigureNamesString[] =
 			NULL
 		},
 		&standby_addr_host,
-		"localhost", NULL, NULL
+		"none", NULL, NULL
 	},
 
 	{


Mime
View raw message