hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odiache...@apache.org
Subject [16/38] incubator-hawq git commit: HAWQ-573. Fix Resource leak when cancel a query during calling a RPC to allocate resource.
Date Thu, 31 Mar 2016 00:24:09 GMT
HAWQ-573. Fix Resource leak when cancel a query during calling a RPC to allocate resource.


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

Branch: refs/heads/HAWQ-546
Commit: 3d7d07181cab5b4db9af04701ce3501367dc9b29
Parents: 673f930
Author: doli <doli@pivotal.io>
Authored: Wed Mar 23 10:46:10 2016 +0800
Committer: Oleksandr Diachenko <odiachenko@pivotal.io>
Committed: Wed Mar 30 17:23:28 2016 -0700

----------------------------------------------------------------------
 src/backend/tcop/pquery.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/3d7d0718/src/backend/tcop/pquery.c
----------------------------------------------------------------------
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index 99b6a1d..23b59a1 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -110,7 +110,7 @@ static int64 DoPortalRunFetch(Portal portal,
 				 DestReceiver *dest);
 static void DoPortalRewind(Portal portal);
 
-static void AddToGlobalQueryResources(QueryResource *resource);
+static void AddToGlobalQueryResources(int resourceId, QueryResourceLife life);
 
 static int compare_segment(const void *e1, const void *e2);
 /*
@@ -792,6 +792,7 @@ AllocateResource(QueryResourceLife   life,
 		elog(ERROR, "%s. (%d)", errorbuf, errorcode);
 	}
 
+	AddToGlobalQueryResources(resourceId, life);
 	/* Acquire resource. */
 	ret = acquireResourceFromRM(resourceId,
 								gp_session_id,
@@ -899,7 +900,6 @@ AllocateResource(QueryResourceLife   life,
 	 * appropriate place.
 	 */
 	gp_segments_for_planner = list_length(resource->segments);
-	AddToGlobalQueryResources(resource);
 
 	return resource;
 }
@@ -917,13 +917,13 @@ AutoFreeResource(QueryResource *resource)
 }
 
 static void
-AddToGlobalQueryResources(QueryResource *resource)
+AddToGlobalQueryResources(int resourceId, QueryResourceLife life)
 {
   ListCell *lc;
   QueryResourceItem *newItem;
   MemoryContext old;
 
-  if ((!resource) || (resource->life == QRL_NONE))
+  if (life == QRL_NONE)
   {
     return;
   }
@@ -931,7 +931,7 @@ AddToGlobalQueryResources(QueryResource *resource)
   foreach(lc, GlobalQueryResources)
   {
     QueryResourceItem *qri = lfirst(lc);
-    if(qri->resource_id == resource->resource_id)
+    if(qri->resource_id == resourceId)
     {
       /*
        * found, no need to add.
@@ -947,7 +947,7 @@ AddToGlobalQueryResources(QueryResource *resource)
   old = MemoryContextSwitchTo(TopMemoryContext);
   newItem = palloc(sizeof(QueryResourceItem));
   newItem->alive = true;
-  newItem->resource_id = resource->resource_id;
+  newItem->resource_id = resourceId;
   GlobalQueryResources = lappend(GlobalQueryResources, newItem);
   MemoryContextSwitchTo(old);
 }


Mime
View raw message