From 5fa3660f85f44a32992f071127627bc3754a7841 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 12 Jul 2020 01:43:36 +0000 Subject: [PATCH] TD-816 --- src/inc/taoserror.h | 1 + src/query/src/qExecutor.c | 4 ++++ src/query/src/qast.c | 6 ++++-- src/tsdb/src/tsdbRead.c | 3 ++- src/util/inc/exception.h | 3 ++- src/util/src/exception.c | 3 +++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 07b55b6acb..3503e39d31 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -209,6 +209,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NO_DISKSPACE, 0, 0x0702, "query no d TAOS_DEFINE_ERROR(TSDB_CODE_QRY_OUT_OF_MEMORY, 0, 0x0703, "query out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_APP_ERROR, 0, 0x0704, "query app error") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUP_JOIN_KEY, 0, 0x0705, "query duplicated join key") +TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT, 0, 0x0706, "query tag conditon too many") // grant TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_EXPIRED, 0, 0x0800, "grant expired") diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1d9068be16..d1b336fb4b 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5370,6 +5370,7 @@ static int32_t buildAirthmeticExprFromMsg(SExprInfo *pArithExprInfo, SQueryTable pExprNode = exprTreeFromBinary(pArithExprInfo->base.arg[0].argValue.pz, pArithExprInfo->base.arg[0].argBytes); } CATCH( code ) { CLEANUP_EXECUTE(); + qError("qmsg:%p failed to create arithmetic expression string from:%s, reason: %s", pQueryMsg, pArithExprInfo->base.arg[0].argValue.pz, tstrerror(code)); return code; } END_TRY @@ -6104,6 +6105,9 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, vo code = tsdbQuerySTableByTagCond(tsdb, id->uid, tagCond, pQueryMsg->tagCondLen, pQueryMsg->tagNameRelType, tbnameCond, &tableGroupInfo, pGroupColIndex, numOfGroupByCols); if (code != TSDB_CODE_SUCCESS) { + if (code == TSDB_CODE_QRY_EXCEED_TAGS_LIMIT) { + qError("qmsg:%p failed to QueryStable, reason: %s", pQueryMsg, tstrerror(code)); + } goto _over; } } else { diff --git a/src/query/src/qast.c b/src/query/src/qast.c index ffd339f111..c5f4a9ce6c 100644 --- a/src/query/src/qast.c +++ b/src/query/src/qast.c @@ -962,10 +962,13 @@ static UNUSED_FUNC char* exception_strdup(const char* str) { static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { int32_t anchor = CLEANUP_GET_ANCHOR(); + if (CLEANUP_EXCEED_LIMIT()) { + THROW(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT); + return NULL; + } tExprNode* pExpr = exception_calloc(1, sizeof(tExprNode)); CLEANUP_PUSH_VOID_PTR_PTR(true, tExprNodeDestroy, pExpr, NULL); - pExpr->nodeType = tbufReadUint8(br); if (pExpr->nodeType == TSQL_NODE_VALUE) { @@ -995,7 +998,6 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) { pExpr->_node.hasPK = tbufReadUint8(br); pExpr->_node.pLeft = exprTreeFromBinaryImpl(br); pExpr->_node.pRight = exprTreeFromBinaryImpl(br); - assert(pExpr->_node.pLeft != NULL && pExpr->_node.pRight != NULL); } diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index c055a27c39..9e5da903b1 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -2217,7 +2217,8 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, const char* pT } CATCH( code ) { CLEANUP_EXECUTE(); - ret = code; + terrno = code; + goto _error; // TODO: more error handling } END_TRY diff --git a/src/util/inc/exception.h b/src/util/inc/exception.h index 52cd03d830..38f94bfe28 100644 --- a/src/util/inc/exception.h +++ b/src/util/inc/exception.h @@ -78,6 +78,7 @@ void cleanupPush_int_ptr ( bool failOnly, void* func, void* arg ); int32_t cleanupGetActionCount(); void cleanupExecuteTo( int32_t anchor, bool failed ); void cleanupExecute( SExceptionNode* node, bool failed ); +bool cleanupExceedLimit(); #define CLEANUP_PUSH_VOID_PTR_PTR( failOnly, func, arg1, arg2 ) cleanupPush_void_ptr_ptr( (failOnly), (void*)(func), (void*)(arg1), (void*)(arg2) ) #define CLEANUP_PUSH_VOID_PTR_BOOL( failOnly, func, arg1, arg2 ) cleanupPush_void_ptr_bool( (failOnly), (void*)(func), (void*)(arg1), (bool)(arg2) ) @@ -91,7 +92,7 @@ void cleanupExecute( SExceptionNode* node, bool failed ); #define CLEANUP_GET_ANCHOR() cleanupGetActionCount() #define CLEANUP_EXECUTE_TO( anchor, failed ) cleanupExecuteTo( (anchor), (failed) ) - +#define CLEANUP_EXCEED_LIMIT() cleanupExceedLimit() //////////////////////////////////////////////////////////////////////////////// // functions & macros for exception handling diff --git a/src/util/src/exception.c b/src/util/src/exception.c index e1f6516fe7..0b716b6aba 100644 --- a/src/util/src/exception.c +++ b/src/util/src/exception.c @@ -147,3 +147,6 @@ void cleanupExecuteTo( int32_t anchor, bool failed ) { void cleanupExecute( SExceptionNode* node, bool failed ) { doExecuteCleanup( node, 0, failed ); } +bool cleanupExceedLimit() { + return expList->numCleanupAction >= expList->maxCleanupAction; +} -- GitLab