From d28518b41e2b211bdb8100425c61b37be73a656b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 6 Jul 2022 18:08:23 +0800 Subject: [PATCH 1/5] fix(query): set correct query time window. --- source/libs/executor/inc/executorimpl.h | 1 + source/libs/executor/src/executorimpl.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 9d77c9badd..d4476802ae 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -513,6 +513,7 @@ typedef struct SFillOperatorInfo { void** p; SSDataBlock* existNewGroupBlock; bool multigroupResult; + STimeWindow win; } SFillOperatorInfo; typedef struct SGroupbyOperatorInfo { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 25b61e15c3..9f7ba8c86c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3326,7 +3326,7 @@ static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo* pInfo, SResult SExecTaskInfo* pTaskInfo) { pInfo->totalInputRows = pInfo->existNewGroupBlock->info.rows; - int64_t ekey = Q_STATUS_EQUAL(pTaskInfo->status, TASK_COMPLETED) ? pTaskInfo->window.ekey + int64_t ekey = Q_STATUS_EQUAL(pTaskInfo->status, TASK_COMPLETED) ? pInfo->win.ekey : pInfo->existNewGroupBlock->info.window.ekey; taosResetFillInfo(pInfo->pFillInfo, getFillInfoStart(pInfo->pFillInfo)); @@ -3387,7 +3387,7 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) { // Fill the previous group data block, before handle the data block of new group. // Close the fill operation for previous group data block - taosFillSetStartInfo(pInfo->pFillInfo, 0, pTaskInfo->window.ekey); + taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey); } else { if (pBlock == NULL) { if (pInfo->totalInputRows == 0) { @@ -3395,7 +3395,7 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) { return NULL; } - taosFillSetStartInfo(pInfo->pFillInfo, 0, pTaskInfo->window.ekey); + taosFillSetStartInfo(pInfo->pFillInfo, 0, pInfo->win.ekey); } else { pInfo->totalInputRows += pBlock->info.rows; taosFillSetStartInfo(pInfo->pFillInfo, pBlock->info.rows, pBlock->info.window.ekey); @@ -3910,7 +3910,8 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t int32_t order = TSDB_ORDER_ASC; pInfo->pFillInfo = taosCreateFillInfo(order, w.skey, 0, capacity, numOfCols, pInterval, fillType, pColInfo, id); - pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES); + pInfo->win = win; + pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES); if (pInfo->pFillInfo == NULL || pInfo->p == NULL) { taosMemoryFree(pInfo->pFillInfo); taosMemoryFree(pInfo->p); From 5db0f7b1d8a0899ba0146953f241f876330e2206 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 6 Jul 2022 22:25:59 +0800 Subject: [PATCH 2/5] fix(query): fix memory leak. --- source/libs/executor/src/executorimpl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2b10936bb1..52c8960102 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1340,6 +1340,8 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) { extractQualifiedTupleByFilterResult(pBlock, rowRes, keep); blockDataUpdateTsWindow(pBlock, 0); + + taosMemoryFree(rowRes); } void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowRes, bool keep) { From 40121a9bc7d0c317b595d8322c20e55a1aa0a224 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 7 Jul 2022 09:54:03 +0800 Subject: [PATCH 3/5] test: adjust valgrind case --- tests/script/tsim/valgrind/basic1.sim | 5 ++--- tests/script/tsim/valgrind/checkError1.sim | 5 ++++- tests/script/tsim/valgrind/checkError2.sim | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/script/tsim/valgrind/basic1.sim b/tests/script/tsim/valgrind/basic1.sim index adcc92594b..5ca409baa2 100644 --- a/tests/script/tsim/valgrind/basic1.sim +++ b/tests/script/tsim/valgrind/basic1.sim @@ -35,7 +35,8 @@ sql alter dnode 1 'debugflag 143' print =============== step4: create show database sql create database d1 vgroups 1 sql show databases -sql show d1.vgroups +sql use d1 +sql show vgroups print =============== step5: create show stable sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) @@ -44,8 +45,6 @@ if $rows != 1 then return -1 endi - -goto _OVER print =============== step6: create show table sql create table ct1 using stb tags(1000) sql show tables diff --git a/tests/script/tsim/valgrind/checkError1.sim b/tests/script/tsim/valgrind/checkError1.sim index 654180f722..1bf9164f25 100644 --- a/tests/script/tsim/valgrind/checkError1.sim +++ b/tests/script/tsim/valgrind/checkError1.sim @@ -28,7 +28,10 @@ sql alter user u1 pass 'taosdata' sql drop user u1 sql_error alter user u2 sysinfo 0 -print =============== step3: +print =============== step3: create drop dnode +sql create dnode $hostname port 7200 +sql drop dnode 2 +sql alter dnode 1 'debugflag 143' print =============== stop system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/checkError2.sim b/tests/script/tsim/valgrind/checkError2.sim index b3d57d7fdb..aaa498221f 100644 --- a/tests/script/tsim/valgrind/checkError2.sim +++ b/tests/script/tsim/valgrind/checkError2.sim @@ -19,7 +19,17 @@ if $rows != 1 then endi print =============== step2: create db -sql create database db vgroups 1 +sql create database d1 vgroups 1 +sql show databases +sql use d1 +sql show vgroups + +print =============== step3: create show stable +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) +sql show stables +if $rows != 1 then + return -1 +endi _OVER: system sh/exec.sh -n dnode1 -s stop -x SIGINT @@ -29,7 +39,7 @@ print ----> start to check if there are ERRORS in vagrind log file for each dnod system_content sh/checkValgrind.sh -n dnode1 print cmd return result ----> [ $system_content ] -if $system_content <= 8 then +if $system_content <= 6 then return 0 endi From 7ac8e51a75fe5c2566777f0fbfd4c188fd267972 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 7 Jul 2022 09:58:47 +0800 Subject: [PATCH 4/5] fix: fix vnode memory issues --- source/dnode/vnode/src/vnd/vnodeSvr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index b3e9f53a5a..e438503780 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -281,8 +281,9 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("message in fetch queue is processing"); - if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG) - && !vnodeIsLeader(pVnode)) { + if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || + pMsg->msgType == TDMT_VND_TABLE_CFG) && + !vnodeIsLeader(pVnode)) { vnodeRedirectRpcMsg(pVnode, pMsg); return 0; } @@ -389,10 +390,14 @@ static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *p goto _err; } + taosMemoryFree(req.schemaRow.pSchema); + taosMemoryFree(req.schemaTag.pSchema); tDecoderClear(&coder); return 0; _err: + taosMemoryFree(req.schemaRow.pSchema); + taosMemoryFree(req.schemaTag.pSchema); tDecoderClear(&coder); return -1; } @@ -811,7 +816,8 @@ _exit: taosArrayDestroy(submitRsp.pArray); // TODO: the partial success scenario and the error case - // => If partial success, extract the success submitted rows and reconstruct a new submit msg, and push to level 1/level 2. + // => If partial success, extract the success submitted rows and reconstruct a new submit msg, and push to level + // 1/level 2. // TODO: refactor if ((terrno == TSDB_CODE_SUCCESS) && (pRsp->code == TSDB_CODE_SUCCESS)) { tdProcessRSmaSubmit(pVnode->pSma, pReq, STREAM_INPUT__DATA_SUBMIT); @@ -915,4 +921,4 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq _err: return code; -} \ No newline at end of file +} From 52587c67830ae05fb6ae363cf67f50f3f32ee33a Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 7 Jul 2022 10:30:00 +0800 Subject: [PATCH 5/5] test: adjust valgrind case --- tests/script/tsim/valgrind/basic1.sim | 3 ++- tests/script/tsim/valgrind/basic2.sim | 3 ++- tests/script/tsim/valgrind/checkError1.sim | 1 + tests/script/tsim/valgrind/checkError2.sim | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/script/tsim/valgrind/basic1.sim b/tests/script/tsim/valgrind/basic1.sim index 5ca409baa2..1827e8d3c0 100644 --- a/tests/script/tsim/valgrind/basic1.sim +++ b/tests/script/tsim/valgrind/basic1.sim @@ -1,5 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect @@ -33,7 +34,7 @@ sql drop dnode 2 sql alter dnode 1 'debugflag 143' print =============== step4: create show database -sql create database d1 vgroups 1 +sql create database d1 vgroups 1 buffer 3 sql show databases sql use d1 sql show vgroups diff --git a/tests/script/tsim/valgrind/basic2.sim b/tests/script/tsim/valgrind/basic2.sim index 8781acd698..a592d48d66 100644 --- a/tests/script/tsim/valgrind/basic2.sim +++ b/tests/script/tsim/valgrind/basic2.sim @@ -1,5 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect @@ -19,7 +20,7 @@ if $rows != 1 then endi print =============== step2: create db -sql create database db vgroups 1 +sql create database db vgroups 1 buffer 3 sql use db sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) diff --git a/tests/script/tsim/valgrind/checkError1.sim b/tests/script/tsim/valgrind/checkError1.sim index 1bf9164f25..edbb28de4b 100644 --- a/tests/script/tsim/valgrind/checkError1.sim +++ b/tests/script/tsim/valgrind/checkError1.sim @@ -1,5 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect diff --git a/tests/script/tsim/valgrind/checkError2.sim b/tests/script/tsim/valgrind/checkError2.sim index aaa498221f..31cd40cc15 100644 --- a/tests/script/tsim/valgrind/checkError2.sim +++ b/tests/script/tsim/valgrind/checkError2.sim @@ -1,5 +1,6 @@ system sh/stop_dnodes.sh system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c debugflag -v 131 system sh/exec.sh -n dnode1 -s start -v sql connect @@ -19,7 +20,7 @@ if $rows != 1 then endi print =============== step2: create db -sql create database d1 vgroups 1 +sql create database d1 vgroups 1 buffer 3 sql show databases sql use d1 sql show vgroups