hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hubertzh...@apache.org
Subject incubator-hawq git commit: HAWQ-652. Slicemap in dispatch is mismatched when run multiple query in one session.
Date Mon, 11 Apr 2016 11:33:07 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master cad586c95 -> 69e8dddbc


HAWQ-652. Slicemap in dispatch is mismatched when run multiple query in one session.


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

Branch: refs/heads/master
Commit: 69e8dddbc3d03b40759cc582525a351feba19a27
Parents: cad586c
Author: hzhang2 <zhanghuan929@163.com>
Authored: Mon Apr 11 19:32:35 2016 +0800
Committer: hzhang2 <zhanghuan929@163.com>
Committed: Mon Apr 11 19:32:35 2016 +0800

----------------------------------------------------------------------
 src/backend/cdb/cdbdispatchresult.c | 18 ++++++------
 src/backend/cdb/dispatcher.c        | 28 ++++++++++++++-----
 src/backend/cdb/dispatcher_mgt.c    | 47 +-------------------------------
 src/include/cdb/dispatcher_mgt.h    | 16 ++++++++++-
 4 files changed, 46 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/69e8dddb/src/backend/cdb/cdbdispatchresult.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbdispatchresult.c b/src/backend/cdb/cdbdispatchresult.c
index d97dda5..c70c43f 100644
--- a/src/backend/cdb/cdbdispatchresult.c
+++ b/src/backend/cdb/cdbdispatchresult.c
@@ -150,10 +150,9 @@ cdbdisp_makeResult(struct CdbDispatchResults           *meleeResults,
         }
         else
         {
-            if (si->resultBegin > meleeIndex)
-                si->resultBegin = meleeIndex;
-            if (si->resultEnd <= meleeIndex)
-                si->resultEnd = meleeIndex + 1;
+            Assert(si->resultBegin <= meleeIndex);
+            Assert(si->resultEnd <= meleeIndex);
+            si->resultEnd = meleeIndex + 1;
         }
     }
 
@@ -685,10 +684,11 @@ cdbdisp_makeDispatchResults(int     resultCapacity,
                             int     sliceCapacity,
                             bool    cancelOnError)
 {
-    CdbDispatchResults *results = palloc0(sizeof(*results));
-    int     nbytes = resultCapacity * sizeof(results->resultArray[0]);
+    CdbDispatchResults *results = (CdbDispatchResults*) palloc0(sizeof(CdbDispatchResults));
+    int     nbytes = resultCapacity * sizeof(CdbDispatchResult);
+
+    results->resultArray = (CdbDispatchResult*) palloc0(nbytes);
 
-    results->resultArray = palloc0(nbytes);
     results->resultCapacity = resultCapacity;
     results->resultCount = 0;
     results->iFirstError = -1;
@@ -699,8 +699,8 @@ cdbdisp_makeDispatchResults(int     resultCapacity,
     results->sliceCapacity = sliceCapacity;
     if (sliceCapacity > 0)
     {
-        nbytes = sliceCapacity * sizeof(results->sliceMap[0]);
-        results->sliceMap = palloc0(nbytes);
+        nbytes = sliceCapacity * sizeof(CdbDispatchResults_SliceInfo);
+        results->sliceMap = (CdbDispatchResults_SliceInfo*) palloc0(nbytes);
     }
 
     return results;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/69e8dddb/src/backend/cdb/dispatcher.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/dispatcher.c b/src/backend/cdb/dispatcher.c
index 67530fd..634c52a 100644
--- a/src/backend/cdb/dispatcher.c
+++ b/src/backend/cdb/dispatcher.c
@@ -928,19 +928,22 @@ dispatcher_split_logical_tasks_for_statemet_or_node(DispatchData *data)
 static bool
 dispatcher_bind_executor(DispatchData *data)
 {
-	int		i,
-			j;
+	int		i, j;
 	struct QueryExecutor	*executor;
 	QueryExecutorIterator	iterator;
 	List		*concurrent_connect_executors = NIL;
 	ListCell	*lc;
-	bool		ret;
+	bool		ret = true;
+	bool    bindExecutorError = false;
 
 	dispmgt_init_query_executor_iterator(data->query_executor_team, &iterator);
 	for (i = 0; i < data->job.used_slices_num; i++)
 	{
 		DispatchSlice	*slice = &data->job.slices[i];
 
+		if (bindExecutorError)
+		  break;
+
 		for (j = 0; j < slice->tasks_num; j++)
 		{
 			DispatchTask	*task = &slice->tasks[j];
@@ -963,6 +966,11 @@ dispatcher_bind_executor(DispatchData *data)
 			    concurrent_connect_executors = lappend(concurrent_connect_executors,
                                                  info);
 			    data->num_of_new_connected_executors++;
+			    if (!executormgr_bind_executor_task(data, executor, info->desc, task, slice))
+			    {
+			      bindExecutorError = true;
+			      break;
+			    }
 			  }
 			  continue;
 			}
@@ -975,8 +983,10 @@ dispatcher_bind_executor(DispatchData *data)
 											   ""); // tableName
 #endif
 
-			if (!executormgr_bind_executor_task(data, executor, desc, task, slice))
-				return false;
+			if (!executormgr_bind_executor_task(data, executor, desc, task, slice)) {
+			  bindExecutorError = true;
+			  break;
+			}
 			data->num_of_cached_executors++;
 		}
 	}
@@ -990,8 +1000,12 @@ dispatcher_bind_executor(DispatchData *data)
 	if (concurrent_connect_executors == NIL)
 		return true;
 
-	ret = dispmgt_concurrent_connect(concurrent_connect_executors,
-										gp_connections_per_thread);
+	if (!bindExecutorError) {
+	  ret = dispmgt_concurrent_connect(concurrent_connect_executors,
+	                      gp_connections_per_thread);
+	} else {
+	  ret = false;
+	}
 
 	foreach(lc, concurrent_connect_executors)
 		dispmgt_free_preconnect_info(lfirst(lc));

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/69e8dddb/src/backend/cdb/dispatcher_mgt.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/dispatcher_mgt.c b/src/backend/cdb/dispatcher_mgt.c
index 7cf2573..8ed3402 100644
--- a/src/backend/cdb/dispatcher_mgt.c
+++ b/src/backend/cdb/dispatcher_mgt.c
@@ -62,28 +62,11 @@ typedef struct QueryExecutorGroupIterator
 	int		group_id;
 } QueryExecutorGroupIterator;
 
-/*
- * ConcurrentConnectExecutorInfo
- *	Used to create the executor concurrently.
- */
-typedef struct ConcurrentConnectExecutorInfo {
-	bool					is_writer;
-	bool					is_superuser;
-	struct QueryExecutor	*executor;
-	struct DispatchData		*data;
-	struct DispatchSlice	*slice;
-	struct DispatchTask		*task;
-
-	struct SegmentDatabaseDescriptor *desc;
-} ConcurrentConnectExecutorInfo;
-
-
 /* Iterate all of groups. */
 static void	dispmgt_init_query_executor_group_iterator(QueryExecutorTeam *team,
 							QueryExecutorGroupIterator *iterator);
 static QueryExecutorGroup *dispmgt_get_query_executor_group_iterator(
 							QueryExecutorGroupIterator *iterator);
-static bool dispmgt_bind_executor_task(List *executors);
 
 
 
@@ -535,9 +518,6 @@ dispmgt_concurrent_connect(List	*executors, int executors_num_per_thread)
 
 		workermgr_cancel_job(state);
 		/* We have to clean up the executors. */
-		foreach(lc, executors)
-			executormgr_free_executor(((ConcurrentConnectExecutorInfo *) lfirst(lc))->desc);
-
 		dispmgt_free_concurrent_connect_state(tasks);
 		workermgr_free_workermgr_state(state);
 
@@ -554,7 +534,7 @@ dispmgt_concurrent_connect(List	*executors, int executors_num_per_thread)
 	dispmgt_free_concurrent_connect_state(tasks);
 	workermgr_free_workermgr_state(state);
 
-	return dispmgt_bind_executor_task(executors);
+	return true;
 }
 
 ConcurrentConnectExecutorInfo *
@@ -584,29 +564,4 @@ dispmgt_free_preconnect_info(ConcurrentConnectExecutorInfo *info)
 	pfree(info);
 }
 
-/*
- * dispmgt_bind_executor_task
- */
-static bool
-dispmgt_bind_executor_task(List *executors)
-{
-	ListCell	*lc;
-	bool		has_error = false;
-
-	foreach(lc, executors)
-	{
-		ConcurrentConnectExecutorInfo	*info = lfirst(lc);
-
-		if (has_error)
-		{
-			executormgr_free_executor(info->desc);
-			continue;
-		}
-
-		if (!executormgr_bind_executor_task(info->data, info->executor, info->desc, info->task,
info->slice))
-			has_error = true;
-	}
-
-	return !has_error;
-}
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/69e8dddb/src/include/cdb/dispatcher_mgt.h
----------------------------------------------------------------------
diff --git a/src/include/cdb/dispatcher_mgt.h b/src/include/cdb/dispatcher_mgt.h
index e386a47..5e2b9a9 100644
--- a/src/include/cdb/dispatcher_mgt.h
+++ b/src/include/cdb/dispatcher_mgt.h
@@ -27,7 +27,6 @@ struct DispatchData;
 struct QueryExecutorTeam;
 struct QueryExecutor;
 struct WorkerMgrState;
-struct ConcurrentConnectExecutorInfo;
 struct Segment;
 struct DispatchSlice;
 struct DispatchTask;
@@ -41,6 +40,21 @@ typedef struct QueryExecutorIterator
 } QueryExecutorIterator;
 
 /*
+ * ConcurrentConnectExecutorInfo
+ *  Used to create the executor concurrently.
+ */
+typedef struct ConcurrentConnectExecutorInfo {
+  bool          is_writer;
+  bool          is_superuser;
+  struct QueryExecutor  *executor;
+  struct DispatchData   *data;
+  struct DispatchSlice  *slice;
+  struct DispatchTask   *task;
+
+  struct SegmentDatabaseDescriptor *desc;
+} ConcurrentConnectExecutorInfo;
+
+/*
  * QueryExecutorTeam/QueryExecutorGroup
  */
 typedef struct QueryExecutorGroup {


Mime
View raw message