From 58b675a5d7379233cd27981cf1d877485d61938a Mon Sep 17 00:00:00 2001 From: Yihao Deng Date: Thu, 1 Feb 2024 10:15:56 +0000 Subject: [PATCH 1/5] change error code --- source/libs/transport/src/transCli.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 15b35030d3..b6942655a9 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -2515,7 +2515,7 @@ int transReleaseCliHandle(void* handle) { SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle); if (pThrd == NULL) { - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } STransMsg tmsg = {.info.handle = handle, .info.ahandle = (void*)0x9527}; @@ -2535,7 +2535,7 @@ int transReleaseCliHandle(void* handle) { if (0 != transAsyncSend(pThrd->asyncPool, &cmsg->q)) { destroyCmsg(cmsg); - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } return 0; } @@ -2544,7 +2544,7 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); if (pTransInst == NULL) { transFreeMsg(pReq->pCont); - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); @@ -2577,7 +2577,7 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran if (0 != transAsyncSend(pThrd->asyncPool, &(cliMsg->q))) { destroyCmsg(cliMsg); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); return 0; @@ -2589,7 +2589,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs if (pTransInst == NULL) { transFreeMsg(pReq->pCont); taosMemoryFree(pTransRsp); - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); @@ -2627,6 +2627,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); if (ret != 0) { destroyCmsg(cliMsg); + ret = TSDB_CODE_RPC_BROKEN_LINK; goto _RETURN; } tsem_wait(sem); @@ -2661,7 +2662,7 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr if (pTransInst == NULL) { transFreeMsg(pReq->pCont); taosMemoryFree(pTransMsg); - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); @@ -2698,6 +2699,7 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); if (ret != 0) { destroyCmsg(cliMsg); + ret = TSDB_CODE_RPC_BROKEN_LINK; goto _RETURN; } @@ -2726,7 +2728,7 @@ _RETURN: int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); if (pTransInst == NULL) { - return -1; + return TSDB_CODE_RPC_BROKEN_LINK; } SCvtAddr cvtAddr = {0}; @@ -2750,7 +2752,6 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { if (transAsyncSend(thrd->asyncPool, &(cliMsg->q)) != 0) { destroyCmsg(cliMsg); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return -1; } } transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); From 963bb20ce3fc0bdbe192124e59a177a68d2af3d9 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 1 Feb 2024 19:11:50 +0800 Subject: [PATCH 2/5] coverage: metaIdx.c comment no use funciton --- source/dnode/vnode/src/meta/metaIdx.c | 2 ++ source/dnode/vnode/src/meta/metaOpen.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/dnode/vnode/src/meta/metaIdx.c b/source/dnode/vnode/src/meta/metaIdx.c index efa06d2d1f..dc62ab2b9f 100644 --- a/source/dnode/vnode/src/meta/metaIdx.c +++ b/source/dnode/vnode/src/meta/metaIdx.c @@ -62,6 +62,7 @@ int metaOpenIdx(SMeta *pMeta) { return 0; } +#ifdef BUILD_NO_CALL void metaCloseIdx(SMeta *pMeta) { /* TODO */ #if 0 if (pMeta->pIdx) { @@ -114,3 +115,4 @@ int metaRemoveTableFromIdx(SMeta *pMeta, tb_uid_t uid) { // TODO return 0; } +#endif \ No newline at end of file diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 8cab17c417..c09253dd6a 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -273,7 +273,9 @@ static void metaCleanup(SMeta **ppMeta) { if (pMeta) { if (pMeta->pEnv) metaAbort(pMeta); if (pMeta->pCache) metaCacheClose(pMeta); +#ifdef BUILD_NO_CALL if (pMeta->pIdx) metaCloseIdx(pMeta); +#endif if (pMeta->pStreamDb) tdbTbClose(pMeta->pStreamDb); if (pMeta->pNcolIdx) tdbTbClose(pMeta->pNcolIdx); if (pMeta->pBtimeIdx) tdbTbClose(pMeta->pBtimeIdx); From ad16d1ed388558f4271ccb6d0bafe70fad78e61f Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 2 Feb 2024 09:14:20 +0800 Subject: [PATCH 3/5] fix: comment checkStreamCorrect again --- tests/army/enterprise/s3/s3_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/army/enterprise/s3/s3_basic.py b/tests/army/enterprise/s3/s3_basic.py index 976ad85747..e7bc188ca5 100644 --- a/tests/army/enterprise/s3/s3_basic.py +++ b/tests/army/enterprise/s3/s3_basic.py @@ -128,7 +128,7 @@ class TDTestCase(TBase): self.checkInsertCorrect() # check stream correct and drop stream - self.checkStreamCorrect() + #self.checkStreamCorrect() # drop stream self.dropStream(self.sname) From 5d80d9d41cc0dc9230825a5859295c0e9b1698da Mon Sep 17 00:00:00 2001 From: Yihao Deng Date: Fri, 2 Feb 2024 01:45:36 +0000 Subject: [PATCH 4/5] change error code --- source/util/src/tworker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index c4b3271c65..3e591c7d7f 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -89,7 +89,7 @@ static void *tQWorkerThreadFp(SQueueWorker *worker) { if (qinfo.timestamp != 0) { int64_t cost = taosGetTimestampUs() - qinfo.timestamp; if (cost > QUEUE_THRESHOLD) { - uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost); + uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost / QUEUE_THRESHOLD); } } @@ -210,7 +210,7 @@ static void *tAutoQWorkerThreadFp(SQueueWorker *worker) { if (qinfo.timestamp != 0) { int64_t cost = taosGetTimestampUs() - qinfo.timestamp; if (cost > QUEUE_THRESHOLD) { - uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost); + uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost / QUEUE_THRESHOLD); } } @@ -357,7 +357,7 @@ static void *tWWorkerThreadFp(SWWorker *worker) { if (qinfo.timestamp != 0) { int64_t cost = taosGetTimestampUs() - qinfo.timestamp; if (cost > QUEUE_THRESHOLD) { - uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost); + uWarn("worker:%s,message has been queued for too long, cost: %" PRId64 "s", pool->name, cost / QUEUE_THRESHOLD); } } From 948845ea3516b8ca2b5839d031d53e26b9c2bbb0 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 2 Feb 2024 10:38:09 +0800 Subject: [PATCH 5/5] fix: join order by not work issue --- source/libs/planner/src/planOptimizer.c | 58 +++++++++-------- tests/script/tsim/query/join_order.sim | 85 +++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 28 deletions(-) diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index af9ec93f65..cda1614612 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1455,28 +1455,25 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL SLogicNode* pLeft = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 0); SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pJoin->node.pChildren, 1); SScanLogicNode* pScan = NULL; + SLogicNode* pChild = NULL; + SNode** pChildPos = NULL; + EOrder targetOrder = 0; + SSHashObj* pTables = NULL; if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pLeft) && ((SScanLogicNode*)pLeft)->node.outputTsOrder != SCAN_ORDER_BOTH) { pScan = (SScanLogicNode*)pLeft; + pChild = pRight; + pChildPos = &pJoin->node.pChildren->pTail->pNode; + targetOrder = pScan->node.outputTsOrder; } else if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pRight) && ((SScanLogicNode*)pRight)->node.outputTsOrder != SCAN_ORDER_BOTH) { pScan = (SScanLogicNode*)pRight; - } - - if (NULL != pScan) { - switch (pScan->node.outputTsOrder) { - case SCAN_ORDER_ASC: - pScan->scanSeq[0] = 0; - pScan->scanSeq[1] = 1; - pScan->node.outputTsOrder = ORDER_DESC; - goto _return; - case SCAN_ORDER_DESC: - pScan->scanSeq[0] = 1; - pScan->scanSeq[1] = 0; - pScan->node.outputTsOrder = ORDER_ASC; - goto _return; - default: - break; - } + pChild = pLeft; + pChildPos = &pJoin->node.pChildren->pHead->pNode; + targetOrder = pScan->node.outputTsOrder; + } else { + pChild = pRight; + pChildPos = &pJoin->node.pChildren->pTail->pNode; + targetOrder = pLeft->outputTsOrder; } if (QUERY_NODE_OPERATOR != nodeType(pJoin->pPrimKeyEqCond)) { @@ -1490,16 +1487,15 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL } SNode* pOrderByNode = NULL; - SSHashObj* pLeftTables = NULL; - collectTableAliasFromNodes(nodesListGetNode(pJoin->node.pChildren, 0), &pLeftTables); - - if (NULL != tSimpleHashGet(pLeftTables, ((SColumnNode*)pOp->pLeft)->tableAlias, strlen(((SColumnNode*)pOp->pLeft)->tableAlias))) { + + collectTableAliasFromNodes((SNode*)pChild, &pTables); + if (NULL != tSimpleHashGet(pTables, ((SColumnNode*)pOp->pLeft)->tableAlias, strlen(((SColumnNode*)pOp->pLeft)->tableAlias))) { pOrderByNode = pOp->pLeft; - } else if (NULL != tSimpleHashGet(pLeftTables, ((SColumnNode*)pOp->pRight)->tableAlias, strlen(((SColumnNode*)pOp->pRight)->tableAlias))) { + } else if (NULL != tSimpleHashGet(pTables, ((SColumnNode*)pOp->pRight)->tableAlias, strlen(((SColumnNode*)pOp->pRight)->tableAlias))) { pOrderByNode = pOp->pRight; } - tSimpleHashCleanup(pLeftTables); + tSimpleHashCleanup(pTables); if (NULL == pOrderByNode) { return TSDB_CODE_PLAN_INTERNAL_ERROR; @@ -1510,7 +1506,13 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL return TSDB_CODE_OUT_OF_MEMORY; } - pSort->node.outputTsOrder = (ORDER_ASC == pLeft->outputTsOrder) ? ORDER_DESC : ORDER_ASC; + pSort->node.outputTsOrder = targetOrder; + pSort->node.pTargets = nodesCloneList(pChild->pTargets); + if (NULL == pSort->node.pTargets) { + nodesDestroyNode((SNode *)pSort); + return TSDB_CODE_OUT_OF_MEMORY; + } + pSort->groupSort = false; SOrderByExprNode* pOrder = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); if (NULL == pOrder) { @@ -1519,7 +1521,7 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL } nodesListMakeAppend(&pSort->pSortKeys, (SNode*)pOrder); - pOrder->order = (ORDER_ASC == pLeft->outputTsOrder) ? ORDER_DESC : ORDER_ASC; + pOrder->order = targetOrder; pOrder->pExpr = nodesCloneNode(pOrderByNode); pOrder->nullOrder = (ORDER_ASC == pOrder->order) ? NULL_ORDER_FIRST : NULL_ORDER_LAST; if (!pOrder->pExpr) { @@ -1527,9 +1529,9 @@ static int32_t sortForJoinOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL return TSDB_CODE_OUT_OF_MEMORY; } - pLeft->pParent = (SLogicNode*)pSort; - nodesListMakeAppend(&pSort->node.pChildren, (SNode*)pLeft); - pJoin->node.pChildren->pHead->pNode = (SNode*)pSort; + pChild->pParent = (SLogicNode*)pSort; + nodesListMakeAppend(&pSort->node.pChildren, (SNode*)pChild); + *pChildPos = (SNode*)pSort; pSort->node.pParent = (SLogicNode*)pJoin;; _return: diff --git a/tests/script/tsim/query/join_order.sim b/tests/script/tsim/query/join_order.sim index bd772ff407..534ab5d631 100644 --- a/tests/script/tsim/query/join_order.sim +++ b/tests/script/tsim/query/join_order.sim @@ -47,5 +47,90 @@ sql select a.*,b.* from (select * from tba1 order by ts desc) a, (select * from if $rows != 4 then return -1 endi +sql select a.*,b.* from (select * from tba1 order by ts desc) a, (select * from tba1 order by ts) b where a.ts=b.ts order by a.ts; +if $rows != 4 then + return -1 +endi +if $data00 != @23-11-17 16:29:00.000@ then + return -1 +endi +sql select a.*,b.* from (select * from tba1 order by ts desc) a, (select * from tba1 order by ts) b where a.ts=b.ts order by a.ts desc; +if $rows != 4 then + return -1 +endi +if $data00 != @23-11-17 16:29:04.000@ then + return -1 +endi +sql select a.*,b.* from (select * from tba1 order by ts) a, (select * from tba1 order by ts) b where a.ts=b.ts order by a.ts; +if $rows != 4 then + return -1 +endi +if $data00 != @23-11-17 16:29:00.000@ then + return -1 +endi +sql select a.*,b.* from (select * from tba1 order by ts) a, (select * from tba1 order by ts) b where a.ts=b.ts order by a.ts desc; +if $rows != 4 then + return -1 +endi +if $data00 != @23-11-17 16:29:04.000@ then + return -1 +endi +sql select a.*,b.* from (select * from tba1 order by ts limit 2) a, (select * from tba1 order by ts desc limit 2) b where a.ts=b.ts order by a.ts desc; +if $rows != 0 then + return -1 +endi +sql select a.*,b.* from (select * from tba1 order by ts limit 3) a, (select * from tba1 order by ts desc limit 3) b where a.ts=b.ts order by a.ts desc; +if $rows != 2 then + return -1 +endi +if $data00 != @23-11-17 16:29:03.000@ then + return -1 +endi + +sql select a.*,b.* from (select * from tba1 order by ts limit 3) a, (select * from tba1 order by ts desc limit 3) b where a.ts=b.ts order by a.ts; +if $rows != 2 then + return -1 +endi +if $data00 != @23-11-17 16:29:02.000@ then + return -1 +endi + +sql select a.*,b.* from tba1 a, (select * from tba1 order by ts desc limit 3) b where a.ts=b.ts order by a.ts; +if $rows != 3 then + return -1 +endi +if $data00 != @23-11-17 16:29:02.000@ then + return -1 +endi +sql select a.*,b.* from tba1 a, (select * from tba1 order by ts limit 3) b where a.ts=b.ts order by a.ts desc limit 2; +if $rows != 2 then + return -1 +endi +if $data00 != @23-11-17 16:29:03.000@ then + return -1 +endi + +sql select a.*,b.* from (select * from tba1 order by ts limit 3) a, tba1 b where a.ts=b.ts order by a.ts desc; +if $rows != 3 then + return -1 +endi +if $data00 != @23-11-17 16:29:03.000@ then + return -1 +endi +sql select a.*,b.* from (select * from tba1 order by ts desc limit 3) a, tba1 b where a.ts=b.ts order by a.ts desc; +if $rows != 3 then + return -1 +endi +if $data00 != @23-11-17 16:29:04.000@ then + return -1 +endi + +sql select a.*,b.* from (select * from tba1 order by ts desc limit 3) a, tba1 b where a.ts=b.ts order by a.ts; +if $rows != 3 then + return -1 +endi +if $data00 != @23-11-17 16:29:02.000@ then + return -1 +endi system sh/exec.sh -n dnode1 -s stop -x SIGINT