From aae019d18ab2dc2243faef1317394590251c2ceb Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 13 May 2022 00:32:02 +0800 Subject: [PATCH] fix(query): close read fd when finishing scanning data files. --- include/libs/function/function.h | 7 ------- source/dnode/vnode/inc/vnode.h | 1 + source/dnode/vnode/src/inc/tsdb.h | 1 - source/libs/executor/src/scanoperator.c | 12 +++++++++++- source/libs/function/src/texpr.c | 13 ------------- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 7d977b0d23..6141829a3f 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -222,13 +222,6 @@ enum { typedef struct tExprNode { int32_t nodeType; union { -// struct { -// int32_t optr; // binary operator -// void *info; // support filter operation on this expression only available for leaf node -// struct tExprNode *pLeft; // left child pointer -// struct tExprNode *pRight; // right child pointer -// } _node; - SSchema *pSchema;// column node struct SVariant *pVal; // value node diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index ebf49c644b..e7c41376c1 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -114,6 +114,7 @@ void tsdbResetReadHandle(tsdbReaderT queryHandle, SQueryTableDataCond *pCond) void tsdbDestroyTableGroup(STableGroupInfo *pGroupList); int32_t tsdbGetOneTableGroup(void *pMeta, uint64_t uid, TSKEY startKey, STableGroupInfo *pGroupInfo); int32_t tsdbGetTableGroupFromIdList(SVnode *pVnode, SArray *pTableIdList, STableGroupInfo *pGroupInfo); +void tsdbCleanupReadHandle(tsdbReaderT queryHandle); // tq diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index b8cbb2d997..052a13397f 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -99,7 +99,6 @@ int32_t tsdbInitSma(STsdb *pTsdb); int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg); int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid); int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg); -void tsdbCleanupReadHandle(tsdbReaderT queryHandle); typedef enum { TSDB_FILE_HEAD = 0, // .head TSDB_FILE_DATA, // .data diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index b3d915ab93..b39714c121 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -390,6 +390,16 @@ SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode) { return interval; } +static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) { + STableScanInfo* pTableScanInfo = (STableScanInfo*)param; + taosMemoryFree(pTableScanInfo->pResBlock); + tsdbCleanupReadHandle(pTableScanInfo->dataReader); + + if (pTableScanInfo->pColMatchInfo != NULL) { + taosArrayDestroy(pTableScanInfo->pColMatchInfo); + } +} + SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) { STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); @@ -436,7 +446,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pOperator->numOfExprs = numOfCols; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, NULL, NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, destroyTableScanOperatorInfo, NULL, NULL, NULL); static int32_t cost = 0; diff --git a/source/libs/function/src/texpr.c b/source/libs/function/src/texpr.c index 83e41b199e..b91af2d157 100644 --- a/source/libs/function/src/texpr.c +++ b/source/libs/function/src/texpr.c @@ -27,19 +27,6 @@ #include "tvariant.h" #include "tdef.h" -//static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLeft, const tExprNode *pRight) { -// if (pLeft->nodeType == TEXPR_COL_NODE) { -// // if left node is the primary column,return true -// return (strcmp(primaryColumnName, pLeft->pSchema->name) == 0) ? 1 : 0; -// } else { -// // if any children have query on primary key, their parents are also keep this value -// return ((pLeft->nodeType == TEXPR_BINARYEXPR_NODE && pLeft->_node.hasPK == 1) || -// (pRight->nodeType == TEXPR_BINARYEXPR_NODE && pRight->_node.hasPK == 1)) == true -// ? 1 -// : 0; -// } -//} - static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)); void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) {