From 7593fc6ae628a191e9a1ae215d66fb1e43d8e386 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 29 Mar 2022 23:47:12 -0400 Subject: [PATCH] bugfix --- source/libs/nodes/src/nodesUtilFuncs.c | 25 ++++++++++++++++++---- source/libs/planner/src/planLogicCreater.c | 2 +- source/libs/planner/src/planPhysiCreater.c | 6 +++++- source/libs/planner/src/planSpliter.c | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 18874d7c5b..fdfef6434b 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -481,8 +481,7 @@ void nodesDestroyNode(SNodeptr pNode) { SVnodeModifLogicNode* pLogicNode = (SVnodeModifLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); destroyVgDataBlockArray(pLogicNode->pDataBlocks); - taosMemoryFreeClear(pLogicNode->pVgDataBlocks->pData); - taosMemoryFreeClear(pLogicNode->pVgDataBlocks); + // pVgDataBlocks is weak reference break; } case QUERY_NODE_LOGIC_PLAN_EXCHANGE: @@ -512,6 +511,7 @@ void nodesDestroyNode(SNodeptr pNode) { SLogicSubplan* pSubplan = (SLogicSubplan*)pNode; nodesDestroyList(pSubplan->pChildren); nodesDestroyNode(pSubplan->pNode); + nodesClearList(pSubplan->pParents); taosMemoryFreeClear(pSubplan->pVgroupList); break; } @@ -591,11 +591,28 @@ void nodesDestroyNode(SNodeptr pNode) { nodesDestroyList(pSubplan->pChildren); nodesDestroyNode(pSubplan->pNode); nodesDestroyNode(pSubplan->pDataSink); + nodesClearList(pSubplan->pParents); break; } - case QUERY_NODE_PHYSICAL_PLAN: - nodesDestroyList(((SQueryPlan*)pNode)->pSubplans); + case QUERY_NODE_PHYSICAL_PLAN: { + SQueryPlan* pPlan = (SQueryPlan*)pNode; + if (NULL != pPlan->pSubplans) { + // only need to destroy the top-level subplans, because they will recurse to all the subplans below + bool first = true; + SNode* pElement = NULL; + FOREACH(pElement, pPlan->pSubplans) { + if (first) { + first = false; + nodesDestroyNode(pElement); + } else { + nodesClearList(((SNodeListNode*)pElement)->pNodeList); + taosMemoryFreeClear(pElement); + } + } + nodesClearList(pPlan->pSubplans); + } break; + } default: break; } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index bd4b6481f1..c0d7ff238e 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -692,7 +692,7 @@ static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpS if (NULL == pModif) { return TSDB_CODE_OUT_OF_MEMORY; } - pModif->pDataBlocks = pStmt->pDataBlocks; + TSWAP(pModif->pDataBlocks, pStmt->pDataBlocks, SArray*); pModif->msgType = getMsgType(pStmt->sqlNodeType); *pLogicNode = (SLogicNode*)pModif; return TSDB_CODE_SUCCESS; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 004597bccb..d5e35fa594 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1083,7 +1083,11 @@ static int32_t doCreatePhysiPlan(SPhysiPlanContext* pCxt, SQueryLogicPlan* pLogi static void destoryLocationHash(void* p) { SHashObj* pHash = *(SHashObj**)p; - // todo + SSlotIndex* pIndex = taosHashIterate(pHash, NULL); + while (NULL != pIndex) { + taosArrayDestroy(pIndex->pSlotIdsInfo); + pIndex = taosHashIterate(pHash, pIndex); + } taosHashCleanup(pHash); } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index df546c32be..3ce225abab 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -140,6 +140,7 @@ static int32_t stsSplit(SSplitContext* pCxt) { code = stsCreateExchangeNode(pCxt, pInfo->pSubplan, pInfo->pScan); } ++(pCxt->groupId); + taosMemoryFreeClear(pCxt->pInfo); return code; }