Repository: incubator-hawq
Updated Branches:
  refs/heads/master e9c5dc3d7 -> 81caf811e


HAWQ-671. Fix coverity problem and refine debug log


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

Branch: refs/heads/master
Commit: 81caf811e0b67457d000627f529c8750ac8fd147
Parents: e9c5dc3
Author: YI JIN <[email protected]>
Authored: Thu Apr 14 18:31:46 2016 +1000
Committer: YI JIN <[email protected]>
Committed: Thu Apr 14 18:31:46 2016 +1000

----------------------------------------------------------------------
 src/backend/resourcemanager/resqueuemanager.c | 88 +++++++++++++---------
 1 file changed, 51 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/81caf811/src/backend/resourcemanager/resqueuemanager.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/resqueuemanager.c 
b/src/backend/resourcemanager/resqueuemanager.c
index d8b62c0..cf4dc1f 100644
--- a/src/backend/resourcemanager/resqueuemanager.c
+++ b/src/backend/resourcemanager/resqueuemanager.c
@@ -3846,27 +3846,34 @@ int addNewResourceToResourceManager(int32_t memorymb, 
double core)
        Assert( trunc(core) == core );
        uint32_t ratio = trunc(1.0 * memorymb / core);
        int32_t  ratioindex = getResourceQueueRatioIndex(ratio);
-       Assert( ratioindex >= 0 );
 
-       elog(RMLOG, "addNewResourceToResourceManager (%d MB, %lf CORE) "
-                           "plus (%d MB, %lf CORE)",
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core,
-                               memorymb,
-                               core);
-
-       
addResourceBundleData(&(PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated),
-                                                 memorymb,
-                                                 core);
-
-       elog(RMLOG, "addNewResourceToResourceManager leavs (%d MB, %lf CORE)",
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core);
-
-
-       /* New resource is added. Try to dispatch resource to queries. */
-       PQUEMGR->toRunQueryDispatch = true;
-       return FUNC_RETURN_OK;
+       if ( ratioindex >= 0 )
+       {
+               elog(RMLOG, "Allocated resource for ratio %d (%d MB, %lf CORE) 
plus "
+                                       "(%d MB, %lf CORE)",
+                                       ratio,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core,
+                                       memorymb,
+                                       core);
+
+               
addResourceBundleData(&(PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated),
+                                                         memorymb,
+                                                         core);
+
+               elog(RMLOG, "Current allocated resource for ratio %d (%d MB, 
%lf CORE)",
+                                       ratio,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core);
+
+               /* New resource is added. Try to dispatch resource to queries. 
*/
+               PQUEMGR->toRunQueryDispatch = true;
+               return FUNC_RETURN_OK;
+       }
+       else
+       {
+               return RESOURCEPOOL_NO_RATIO;
+       }
 }
 
 int minusResourceFromResourceManagerByBundle(ResourceBundle bundle)
@@ -3889,24 +3896,31 @@ int minusResourceFromResourceManager(int32_t memorymb, 
double core)
        Assert( trunc(core) == core );
        uint32_t ratio = trunc(1.0 * memorymb / core);
        int32_t  ratioindex = getResourceQueueRatioIndex(ratio);
-       Assert( ratioindex >= 0 );
-
-       elog(RMLOG, "minusResourceFromResourceManager (%d MB, %lf CORE) "
-                           "minus (%d MB, %lf CORE)",
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core,
-                               memorymb,
-                               core);
 
-       
minusResourceBundleData(&(PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated),
-                                                       memorymb,
-                                                       core);
-
-       elog(RMLOG, "minusResourceFromResourceManager leavs (%d MB, %lf CORE)",
-                           
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
-                               
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core);
-
-       return FUNC_RETURN_OK;
+       if ( ratioindex >= 0 )
+       {
+               elog(RMLOG, "Allocated resource for ratio %d (%d MB, %lf CORE) 
minus "
+                                       "(%d MB, %lf CORE)",
+                                       ratio,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core,
+                                       memorymb,
+                                       core);
+
+               
minusResourceBundleData(&(PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated),
+                                                               memorymb,
+                                                               core);
+
+               elog(RMLOG, "Current allocated resource for ratio %d (%d MB, 
%lf CORE)",
+                                       ratio,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.MemoryMB,
+                                       
PQUEMGR->RatioTrackers[ratioindex]->TotalAllocated.Core);
+               return FUNC_RETURN_OK;
+       }
+       else
+       {
+               return RESOURCEPOOL_NO_RATIO;
+       }
 }
 
 void returnAllocatedResourceToLeafQueue(DynResourceQueueTrack track,

Reply via email to