From b4b9a12d615880adc51f383e943d7d4bbb47acec Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 14 Aug 2023 09:06:21 +0800 Subject: [PATCH] fix: memory issue --- source/libs/executor/src/dynqueryctrloperator.c | 1 + source/libs/executor/src/groupcacheoperator.c | 4 ++-- source/libs/executor/src/operator.c | 1 + source/libs/parser/inc/sql.y | 2 +- source/libs/planner/src/planOptimizer.c | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/dynqueryctrloperator.c b/source/libs/executor/src/dynqueryctrloperator.c index f041eb31a8..4fcf2024b0 100755 --- a/source/libs/executor/src/dynqueryctrloperator.c +++ b/source/libs/executor/src/dynqueryctrloperator.c @@ -373,6 +373,7 @@ static int32_t buildSingleTableScanOperatorParam(SOperatorParam** ppRes, int32_t taosArrayPush(pUidList, pUid); int32_t code = buildTableScanOperatorParam(ppRes, pUidList, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, true); + taosArrayDestroy(pUidList); if (code) { return code; } diff --git a/source/libs/executor/src/groupcacheoperator.c b/source/libs/executor/src/groupcacheoperator.c index c19b567acd..2243768dc0 100755 --- a/source/libs/executor/src/groupcacheoperator.c +++ b/source/libs/executor/src/groupcacheoperator.c @@ -121,8 +121,8 @@ static void freeGcBlockInList(void* p) { static void freeSGcDownstreamCtx(SGcDownstreamCtx* pCtx) { taosArrayDestroy(pCtx->pNewGrpList); - tSimpleHashCleanup(pCtx->pVgTbHash); taosHashCleanup(pCtx->pGrpHash); + tSimpleHashCleanup(pCtx->pVgTbHash); taosArrayDestroyEx(pCtx->pFreeBlock, freeGcBlockInList); taosHashCleanup(pCtx->pSessions); @@ -1180,7 +1180,7 @@ static int32_t initGroupCacheExecInfo(SOperatorInfo* pOperator) { static void freeRemoveGroupCacheData(void* p) { SGroupCacheData* pGroup = p; - if (pGroup->vgId > 0) { + if (pGroup->vgId > 0 && pGroup->needCache) { SGcFileCacheCtx* pFileCtx = &pGroup->pVgCtx->fileCtx; if (pGroup->fileId >= 0) { SGroupCacheFileInfo* pFileInfo = taosHashGet(pFileCtx->pCacheFile, &pGroup->fileId, sizeof(pGroup->fileId)); diff --git a/source/libs/executor/src/operator.c b/source/libs/executor/src/operator.c index b32dd1990f..19d6bd2475 100644 --- a/source/libs/executor/src/operator.c +++ b/source/libs/executor/src/operator.c @@ -754,6 +754,7 @@ int32_t optrDefaultNotifyFn(struct SOperatorInfo* pOperator, SOperatorParam* pPa if (TSDB_CODE_SUCCESS != code) { break; } + pOperator->pDownstreamNotifyParams[i] = NULL; } } } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index ae577cd4ee..b5e14d1bfb 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -1026,7 +1026,7 @@ query_specification(A) ::= %type hint_opt { SQueryHint } %destructor hint_opt { } hint_opt(A) ::= . { A.withHint = false; } -hint_opt(A) ::= NO_BATCH_SCAN. { A.withHint = true; A.batchScan = false; } +hint_opt(A) ::= NO_BATCH_SCAN NK_LP NK_RP. { A.withHint = true; A.batchScan = false; } %type set_quantifier_opt { bool } %destructor set_quantifier_opt { } diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 2e2a00476e..757484ad41 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -3338,7 +3338,7 @@ static int32_t stbJoinOptCreateGroupCacheNode(SNodeList* pChildren, SLogicNode** //pGrpCache->node.dynamicOp = true; pGrpCache->grpColsMayBeNull = false; pGrpCache->grpByUid = true; - pGrpCache->batchFetch = true; + pGrpCache->batchFetch = false; pGrpCache->node.pChildren = pChildren; pGrpCache->node.pTargets = nodesMakeList(); if (NULL == pGrpCache->node.pTargets) { @@ -3444,7 +3444,7 @@ static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pPrev, SLogicNode* p } pDynCtrl->qType = DYN_QTYPE_STB_HASH; - pDynCtrl->stbJoin.batchFetch = true; + pDynCtrl->stbJoin.batchFetch = false; memcpy(pDynCtrl->stbJoin.srcScan, srcScan, sizeof(pDynCtrl->stbJoin.srcScan)); if (TSDB_CODE_SUCCESS == code) {