From 0afe768d767b8f9e7db929abb73d5fe39b177848 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 19 Aug 2021 18:20:57 +0800 Subject: [PATCH 1/3] [TD-6228] fix tag condtion is too long error --- src/client/src/tscServer.c | 8 ++++---- src/client/src/tscUtil.c | 16 ++++++++++++++++ src/inc/taosmsg.h | 2 +- src/query/src/qExecutor.c | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index f8c072a239..953914c504 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -621,7 +621,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) { SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, clauseIndex); int32_t srcColListSize = (int32_t)(taosArrayGetSize(pQueryInfo->colList) * sizeof(SColumnInfo)); - + int32_t srcColFilterSize = tscGetColFilterSerializeLen(pQueryInfo); size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); int32_t exprSize = (int32_t)(sizeof(SSqlFuncMsg) * numOfExprs * 2); @@ -643,8 +643,8 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) { tableSerialize = totalTables * sizeof(STableIdInfo); } - return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize + tsBufSize + - tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen; + return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + srcColFilterSize + + exprSize + tsBufSize + tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen; } static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg, int32_t *succeed) { @@ -1099,7 +1099,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SCond *pCond = tsGetSTableQueryCond(pTagCond, pTableMeta->id.uid); if (pCond != NULL && pCond->cond != NULL) { - pQueryMsg->tagCondLen = htons(pCond->len); + pQueryMsg->tagCondLen = htonl(pCond->len); memcpy(pMsg, pCond->cond, pCond->len); pMsg += pCond->len; diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 773243891f..5e59f54c88 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2989,4 +2989,20 @@ STableMeta* tscTableMetaDup(STableMeta* pTableMeta) { return p; } +int32_t tscGetColFilterSerializeLen(SQueryInfo* pQueryInfo) { + int16_t numOfCols = (int16_t)taosArrayGetSize(pQueryInfo->colList); + int32_t len = 0; + + for(int32_t i = 0; i < numOfCols; ++i) { + SColumn* pCol = taosArrayGetP(pQueryInfo->colList, i); + for (int32_t j = 0; j < pCol->numOfFilters; ++j) { + SColumnFilterInfo *pColFilter = &pCol->filterInfo[j]; + len += sizeof(SColumnFilterInfo); + if (pColFilter->filterstr) { + len += (int32_t)pColFilter->len + 1; + } + } + } + return len; +} diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index d7ac7dd277..2d78210844 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -494,7 +494,7 @@ typedef struct { int16_t numOfCols; // the number of columns will be load from vnode SInterval interval; SSessionWindow sw; // session window - uint16_t tagCondLen; // tag length in current query + uint32_t tagCondLen; // tag length in current query uint32_t tbnameCondLen; // table name filter condition string length int16_t numOfGroupCols; // num of group by columns int16_t orderByIdx; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6b32508f07..f96d33f060 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6172,7 +6172,7 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { pQueryMsg->numOfCols = htons(pQueryMsg->numOfCols); pQueryMsg->numOfOutput = htons(pQueryMsg->numOfOutput); pQueryMsg->numOfGroupCols = htons(pQueryMsg->numOfGroupCols); - pQueryMsg->tagCondLen = htons(pQueryMsg->tagCondLen); + pQueryMsg->tagCondLen = htonl(pQueryMsg->tagCondLen); pQueryMsg->tsOffset = htonl(pQueryMsg->tsOffset); pQueryMsg->tsLen = htonl(pQueryMsg->tsLen); pQueryMsg->tsNumOfBlocks = htonl(pQueryMsg->tsNumOfBlocks); From d837e47cb6e9ec24925d9d50789484436306176e Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 19 Aug 2021 18:47:37 +0800 Subject: [PATCH 2/3] [TD-6228] fix tag condtion is too long error --- src/client/inc/tscUtil.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index 47b2865313..a26f03003e 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -301,6 +301,7 @@ uint32_t tscGetTableMetaMaxSize(); int32_t tscCreateTableMetaFromSTableMeta(STableMeta* pChild, const char* name, void* buf); STableMeta* tscTableMetaDup(STableMeta* pTableMeta); +int32_t tscGetColFilterSerializeLen(SQueryInfo* pQueryInfo); void* malloc_throw(size_t size); void* calloc_throw(size_t nmemb, size_t size); From 7c7f89a3eb7176313c15450fe4a0b84e85f0e4c3 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 19 Aug 2021 21:04:04 +0800 Subject: [PATCH 3/3] [TD-6228] fix tag condtion is too long error --- src/client/src/tscServer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 953914c504..599767803c 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -643,6 +643,12 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql, int32_t clauseIndex) { tableSerialize = totalTables * sizeof(STableIdInfo); } + + SCond* pCond = &pQueryInfo->tagCond.tbnameCond; + if (pCond->len > 0) { + srcColListSize += pCond->len; + } + return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + srcColFilterSize + exprSize + tsBufSize + tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen; }