From b6a8619d40bbeca1dee9fd0de0e3ee5cd43cb851 Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Wed, 4 Sep 2024 10:00:14 +0800 Subject: [PATCH 01/32] enh:modify error code passing in libs/ --- source/libs/geometry/src/geomFunc.c | 8 ++-- source/libs/geometry/src/geosWrapper.c | 2 +- source/libs/index/src/index.c | 2 +- source/libs/index/src/indexCache.c | 8 ++-- source/libs/index/src/indexComm.c | 24 ++++++------ source/libs/index/src/indexFilter.c | 8 ++-- source/libs/index/src/indexTfile.c | 8 ++-- source/libs/index/src/indexUtil.c | 2 +- source/libs/nodes/src/nodesCloneFuncs.c | 4 +- source/libs/nodes/src/nodesCodeFuncs.c | 8 ++-- source/libs/nodes/src/nodesMsgFuncs.c | 2 +- source/libs/nodes/src/nodesUtilFuncs.c | 6 +-- source/libs/parser/src/parInsertSml.c | 14 +++---- source/libs/parser/src/parInsertSql.c | 10 ++--- source/libs/parser/src/parInsertStmt.c | 12 +++--- source/libs/parser/src/parInsertUtil.c | 14 +++---- source/libs/parser/src/parTranslater.c | 52 ++++++++++++------------- source/libs/parser/src/parUtil.c | 4 +- source/libs/parser/src/parser.c | 6 +-- 19 files changed, 97 insertions(+), 97 deletions(-) diff --git a/source/libs/geometry/src/geomFunc.c b/source/libs/geometry/src/geomFunc.c index 1752493dff..2ce2d92fa7 100644 --- a/source/libs/geometry/src/geomFunc.c +++ b/source/libs/geometry/src/geomFunc.c @@ -43,7 +43,7 @@ int32_t doMakePointFunc(double x, double y, unsigned char **output) { *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } @@ -74,7 +74,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) { // make a zero ending string inputGeom = taosMemoryCalloc(1, varDataLen(input) + 1); if (inputGeom == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } (void)memcpy(inputGeom, varDataVal(input), varDataLen(input)); @@ -83,7 +83,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) { *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } @@ -114,7 +114,7 @@ int32_t doAsTextFunc(unsigned char *input, char **output) { size_t size = strlen(outputWKT); *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } diff --git a/source/libs/geometry/src/geosWrapper.c b/source/libs/geometry/src/geosWrapper.c index 5eeea54715..13c5f7208e 100644 --- a/source/libs/geometry/src/geosWrapper.c +++ b/source/libs/geometry/src/geosWrapper.c @@ -96,7 +96,7 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData int32_t code = 0; char *wktPatternWithSpace = taosMemoryCalloc(4, 1024); if (NULL == wktPatternWithSpace) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)sprintf( diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 0d834a68cb..b2fd0afd68 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -112,7 +112,7 @@ int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { int code = TSDB_CODE_SUCCESS; SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex)); if (idx == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, END); + TAOS_CHECK_GOTO(terrno, NULL, END); } idx->lru = taosLRUCacheInit(opts->cacheSize, -1, .5); diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index a89cc47925..1b31c1e50b 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -137,7 +137,7 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt* CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); if (pCt == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pCt->colVal = term->colVal; @@ -206,7 +206,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); if (pCt == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pCt->colVal = term->colVal; @@ -584,7 +584,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // encode data CacheTerm* ct = taosMemoryCalloc(1, sizeof(CacheTerm)); if (ct == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } // set up key ct->colType = term->colType; @@ -594,7 +594,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { ct->colVal = (char*)taosMemoryCalloc(1, sizeof(char) * (term->nColVal + 1)); if (ct->colVal == NULL) { taosMemoryFree(ct); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(ct->colVal, term->colVal, term->nColVal); } diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 8dc63ed105..2c681a1df3 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -323,7 +323,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_TIMESTAMP: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int64_t*)src, *dst, -1); tlen = strlen(*dst); @@ -332,7 +332,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UTINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint8_t*)src, *dst, 1); tlen = strlen(*dst); @@ -340,7 +340,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_TINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int8_t*)src, *dst, 1); tlen = strlen(*dst); @@ -348,7 +348,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_SMALLINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int16_t*)src, *dst, -1); tlen = strlen(*dst); @@ -361,7 +361,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_INT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int32_t*)src, *dst, -1); tlen = strlen(*dst); @@ -369,7 +369,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint32_t*)src, *dst, 1); tlen = strlen(*dst); @@ -377,7 +377,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_BIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%" PRIu64, *(uint64_t*)src); tlen = strlen(*dst); @@ -385,7 +385,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UBIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint64_t*)src, *dst, 1); tlen = strlen(*dst); @@ -393,7 +393,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_FLOAT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%.9lf", *(float*)src); tlen = strlen(*dst); @@ -401,7 +401,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_DOUBLE: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%.9lf", *(double*)src); tlen = strlen(*dst); @@ -410,7 +410,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; @@ -422,7 +422,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 03474c0143..fa59fe23fe 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -197,7 +197,7 @@ static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) { } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(tv, pData, valLen); @@ -273,7 +273,7 @@ static int32_t sifInitParamValByCol(SNode *r, SNode *l, SIFParam *param, SIFCtx } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(tv, pData, valLen); @@ -373,7 +373,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam)); if (NULL == paramList) { - SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SIF_ERR_RET(terrno); } if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR && @@ -405,7 +405,7 @@ static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx * SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam)); if (tParams == NULL) { indexError("failed to calloc, nodeList: %p", nodeList); - SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SIF_ERR_RET(terrno); } SListCell *cell = nodeList->pHead; diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index 55a9bb06d9..405e899100 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -201,7 +201,7 @@ int32_t tfileReaderCreate(IFileCtx* ctx, TFileReader** pReader) { int32_t code = 0; TFileReader* reader = taosMemoryCalloc(1, sizeof(TFileReader)); if (reader == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } reader->ctx = ctx; reader->remove = false; @@ -609,7 +609,7 @@ int32_t tfileWriterCreate(IFileCtx* ctx, TFileHeader* header, TFileWriter** pWri int32_t code = 0; TFileWriter* tw = taosMemoryCalloc(1, sizeof(TFileWriter)); if (tw == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; indexError("index: %" PRIu64 " failed to alloc TFilerWriter since %s", header->suid, tstrerror(code)); return code; } @@ -661,7 +661,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { int32_t cap = 4 * 1024; char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (size_t i = 0; i < sz; i++) { @@ -1137,7 +1137,7 @@ static int32_t tfileGetFileList(const char* path, SArray** ppResult) { size_t len = strlen(path) + 1 + strlen(file) + 1; char* buf = taosMemoryCalloc(1, len); if (buf == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception); + TAOS_CHECK_GOTO(terrno, NULL, _exception); } sprintf(buf, "%s/%s", path, file); diff --git a/source/libs/index/src/indexUtil.c b/source/libs/index/src/indexUtil.c index 6a52b7b5a4..aca1ec37fe 100644 --- a/source/libs/index/src/indexUtil.c +++ b/source/libs/index/src/indexUtil.c @@ -44,7 +44,7 @@ int32_t iIntersection(SArray *in, SArray *out) { } MergeIndex *mi = taosMemoryCalloc(sz, sizeof(MergeIndex)); if (mi == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (int i = 0; i < sz; i++) { SArray *t = taosArrayGetP(in, i); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index e2c5b42e39..b76e4448d3 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -179,7 +179,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = pSrc->node.resType.bytes + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; @@ -188,7 +188,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = getJsonValueLen(pSrc->datum.p); pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1425df5c5a..74879a53af 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -4083,14 +4083,14 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_GEOMETRY: { pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } varDataSetLen(pNode->datum.p, pNode->node.resType.bytes - VARSTR_HEADER_SIZE); if (TSDB_DATA_TYPE_NCHAR == pNode->node.resType.type) { char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + VARSTR_HEADER_SIZE + 1); if (NULL == buf) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tjsonGetStringValue(pJson, jkValueDatum, buf); @@ -4112,12 +4112,12 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_JSON: { pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + 1); if (NULL == buf) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tjsonGetStringValue(pJson, jkValueDatum, buf); diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index b3568e914e..e71cfc47f8 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -952,7 +952,7 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) { } pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tlvDecodeBinary(pTlv, pNode->datum.p); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 1d6c19346a..d58ee8dbdd 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -120,7 +120,7 @@ static int32_t callocNodeChunk(SNodeAllocator* pAllocator, SNodeMemChunk** pOutC SNodeMemChunk* pNewChunk = taosMemoryCalloc(1, sizeof(SNodeMemChunk) + pAllocator->chunkSize); if (NULL == pNewChunk) { if (pOutChunk) *pOutChunk = NULL; - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pNewChunk->pBuf = (char*)(pNewChunk + 1); pNewChunk->availableSize = pAllocator->chunkSize; @@ -141,7 +141,7 @@ static int32_t callocNodeChunk(SNodeAllocator* pAllocator, SNodeMemChunk** pOutC static int32_t nodesCallocImpl(int32_t size, void** pOut) { if (NULL == g_pNodeAllocator) { *pOut = taosMemoryCalloc(1, size); - if (!*pOut) return TSDB_CODE_OUT_OF_MEMORY; + if (!*pOut) return terrno; return TSDB_CODE_SUCCESS; } @@ -180,7 +180,7 @@ void nodesFree(void* p) { static int32_t createNodeAllocator(int32_t chunkSize, SNodeAllocator** pAllocator) { *pAllocator = taosMemoryCalloc(1, sizeof(SNodeAllocator)); if (NULL == *pAllocator) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pAllocator)->chunkSize = chunkSize; int32_t code = callocNodeChunk(*pAllocator, NULL); diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index acd1851d76..23025dcab9 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -48,7 +48,7 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSchema* pSchema, bool isTag) { bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBoundInfo->numOfBound = 0; @@ -139,7 +139,7 @@ static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchem int32_t output = 0; void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output)) { @@ -240,7 +240,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 taosMemoryFree(tmp); } else { uError("SML smlBuildCol out of memory"); - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; } goto end; } @@ -253,7 +253,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 } char* pUcs4 = taosMemoryCalloc(1, size); if (NULL == pUcs4) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, size, &len)) { @@ -315,7 +315,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pCreateTblReq) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName, pTableMeta->tableInfo.numOfTags, @@ -323,7 +323,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1); if (pCreateTblReq->ctb.stbName == NULL){ - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } (void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen); @@ -400,7 +400,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc int32_t len = 0; char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE); if (NULL == pUcs4) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len)) { diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index a8db514ee3..b87a1aabd0 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -182,7 +182,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBoundInfo->numOfBound = 0; @@ -768,7 +768,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p } pStmt->pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pStmt->pCreateTblReq) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } insBuildCreateTbReq(pStmt->pCreateTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid, pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags, @@ -850,7 +850,7 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) { case TSDB_DATA_TYPE_NCHAR: pValue->datum.p = taosMemoryCalloc(1, pVal->nData + VARSTR_HEADER_SIZE); if (NULL == pValue->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pValue->datum.p, pVal->nData); memcpy(varDataVal(pValue->datum.p), pVal->pData, pVal->nData); @@ -1916,7 +1916,7 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod pStbRowsCxt->pCreateCtbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (pStbRowsCxt->pCreateCtbReq == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } if (code == TSDB_CODE_SUCCESS) { insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag, @@ -2319,7 +2319,7 @@ static void destroyStbRowsDataContext(SStbRowsDataContext* pStbRowsCxt) { static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDataContext** ppStbRowsCxt) { SStbRowsDataContext* pStbRowsCxt = taosMemoryCalloc(1, sizeof(SStbRowsDataContext)); if (!pStbRowsCxt) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tNameAssign(&pStbRowsCxt->stbName, &pStmt->targetTableName); int32_t code = collectUseTable(&pStbRowsCxt->stbName, pStmt->pTableNameHashObj); diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index 025459a8c9..c1a228d572 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -32,7 +32,7 @@ typedef struct SKvParam { int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData) { *pData = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == *pData) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SSubmitTbData* pNew = *pData; @@ -190,7 +190,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch int32_t output = 0; void* p = taosMemoryCalloc(1, colLen * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(bind[c].buffer, colLen, (TdUcs4*)(p), colLen * TSDB_NCHAR_SIZE, &output)) { @@ -224,7 +224,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch if (NULL == pDataBlock->pData->pCreateTbReq) { pDataBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pDataBlock->pData->pCreateTbReq) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } } @@ -465,7 +465,7 @@ int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSc if (fields) { *fields = taosMemoryCalloc(numOfBound, sizeof(TAOS_FIELD_E)); if (NULL == *fields) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SSchema* schema = &pSchema[boundColumns[0]]; @@ -572,7 +572,7 @@ int32_t qCloneStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, bool rese *pDst = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == *pDst) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } STableDataCxt* pNewCxt = (STableDataCxt*)*pDst; @@ -650,7 +650,7 @@ int32_t qRebuildStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, uint64_ if (rebuildCreateTb && NULL == pBlock->pData->pCreateTbReq) { pBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pBlock->pData->pCreateTbReq) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index b0581d2fd3..e77678fb69 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -188,7 +188,7 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { pInfo->hasBoundCols = false; pInfo->pColIndex = taosMemoryCalloc(numOfBound, sizeof(int16_t)); if (NULL == pInfo->pColIndex) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (int32_t i = 0; i < numOfBound; ++i) { pInfo->pColIndex[i] = i; @@ -230,7 +230,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat STableDataCxt* pTableCxt = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == pTableCxt) { *pOutput = NULL; - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = TSDB_CODE_SUCCESS; @@ -264,7 +264,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat if (TSDB_CODE_SUCCESS == code) { pTableCxt->pData = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == pTableCxt->pData) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } else { pTableCxt->pData->flags = (pCreateTbReq != NULL && NULL != *pCreateTbReq) ? SUBMIT_REQ_AUTO_CREATE_TABLE : 0; pTableCxt->pData->flags |= colMode ? SUBMIT_REQ_COLUMN_DATA_FORMAT : 0; @@ -300,7 +300,7 @@ static int32_t rebuildTableData(SSubmitTbData* pSrc, SSubmitTbData** pDst) { int32_t code = TSDB_CODE_SUCCESS; SSubmitTbData* pTmp = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == pTmp) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } else { pTmp->flags = pSrc->flags; pTmp->suid = pSrc->suid; @@ -477,12 +477,12 @@ static int32_t createVgroupDataCxt(STableDataCxt* pTableCxt, SHashObj* pVgroupHa SVgroupDataCxt** pOutput) { SVgroupDataCxt* pVgCxt = taosMemoryCalloc(1, sizeof(SVgroupDataCxt)); if (NULL == pVgCxt) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgCxt->pData = taosMemoryCalloc(1, sizeof(SSubmitReq2)); if (NULL == pVgCxt->pData) { insDestroyVgroupDataCxt(pVgCxt); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgCxt->vgId = pTableCxt->pMeta->vgId; @@ -840,7 +840,7 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList, } SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } if (TSDB_CODE_SUCCESS == code) { dst->numOfTables = taosArrayGetSize(src->pData->aSubmitTbData); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 6c86a6c12f..d79a880e72 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2928,7 +2928,7 @@ static int32_t rewriteQueryTimeFunc(STranslateContext* pCxt, int64_t val, SNode* char* pStr = taosMemoryCalloc(1, 20); if (NULL == pStr) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } snprintf(pStr, 20, "%" PRId64 "", val); int32_t code = rewriteFuncToValue(pCxt, &pStr, pNode); @@ -3768,7 +3768,7 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) { size_t vgroupNum = taosArrayGetSize(pVgs); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum); if (NULL == *pVgsInfo) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pVgsInfo)->numOfVgroups = vgroupNum; for (int32_t i = 0; i < vgroupNum; ++i) { @@ -3797,7 +3797,7 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) { size_t ndnode = taosArrayGetSize(pDnodes); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * ndnode); if (NULL == *pVgsInfo) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pVgsInfo)->numOfVgroups = ndnode; for (int32_t i = 0; i < ndnode; ++i) { @@ -3925,7 +3925,7 @@ static int32_t setSuperTableVgroupList(STranslateContext* pCxt, SName* pName, SR static int32_t setNormalTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { pRealTable->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (NULL == pRealTable->pVgroupList) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pRealTable->pVgroupList->numOfVgroups = 1; return getTableHashVgroupImpl(pCxt, pName, pRealTable->pVgroupList->vgroups); @@ -4033,7 +4033,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo } SVgroupsInfo* pVgpsInfo = taosMemoryCalloc(1, sizeof(int32_t) + sizeof(SVgroupInfo)); if (!pVgpsInfo) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } pVgpsInfo->numOfVgroups = 1; @@ -6346,7 +6346,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* const char* pTbName = taosArrayGetP(pInfo->aTbnames, k); char* pNewTbName = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1); if (!pNewTbName) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } if (NULL == taosArrayPush(pTbNames, &pNewTbName)) { @@ -8670,7 +8670,7 @@ static int32_t createRollupTableMeta(SCreateTableStmt* pStmt, int8_t precision, int32_t numOfField = LIST_LENGTH(pStmt->pCols) + LIST_LENGTH(pStmt->pTags); STableMeta* pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + numOfField * sizeof(SSchema)); if (NULL == pMeta) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pMeta->tableType = TSDB_SUPER_TABLE; pMeta->tableInfo.numOfTags = LIST_LENGTH(pStmt->pTags); @@ -9466,7 +9466,7 @@ static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pS static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { int32_t code = checkCreateSmaIndex(pCxt, pStmt); pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); - if (pStmt->pReq == NULL) code = TSDB_CODE_OUT_OF_MEMORY; + if (pStmt->pReq == NULL) code = terrno; if (TSDB_CODE_SUCCESS == code) { code = buildCreateSmaReq(pCxt, pStmt, pStmt->pReq); } @@ -11376,7 +11376,7 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) { *buf = taosMemoryCalloc(1, *len); if (*buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } TdFilePtr tfile = taosOpenFile(pName, O_RDONLY | O_BINARY); @@ -11636,7 +11636,7 @@ static int32_t translateShowVariables(STranslateContext* pCxt, SShowStmt* pStmt) static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateDatabaseStmt* pStmt) { pStmt->pCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pCfg) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SName name; @@ -11650,7 +11650,7 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) { pStmt->pDbCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pDbCfg) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pDbCfg); if (TSDB_CODE_SUCCESS == code) { @@ -12074,7 +12074,7 @@ static int32_t translateCreateTSMA(STranslateContext* pCxt, SCreateTSMAStmt* pSt SName useTbName = {0}; if (code == TSDB_CODE_SUCCESS) { pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); - if (!pStmt->pReq) return TSDB_CODE_OUT_OF_MEMORY; + if (!pStmt->pReq) return terrno; } if (code == TSDB_CODE_SUCCESS) { code = buildCreateTSMAReq(pCxt, pStmt, pStmt->pReq, &useTbName); @@ -12382,7 +12382,7 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t* *numOfCols = LIST_LENGTH(pProjections); *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SNode* pNode; @@ -12414,7 +12414,7 @@ static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) *numOfCols = 1; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE; @@ -12427,7 +12427,7 @@ static int32_t extractDescribeResultSchema(STableMeta* pMeta, int32_t* numOfCols if (pMeta && useCompress(pMeta->tableType)) *numOfCols = DESCRIBE_RESULT_COLS_COMPRESS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12467,7 +12467,7 @@ static int32_t extractShowCreateDatabaseResultSchema(int32_t* numOfCols, SSchema *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12485,7 +12485,7 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12503,7 +12503,7 @@ static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** p *numOfCols = SHOW_CREATE_VIEW_RESULT_COLS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12521,7 +12521,7 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS *numOfCols = 3; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12543,7 +12543,7 @@ static int32_t extractCompactDbResultSchema(int32_t* numOfCols, SSchema** pSchem *numOfCols = COMPACT_DB_RESULT_COLS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -13269,7 +13269,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* req.ntb.schemaRow.pSchema = taosMemoryCalloc(req.ntb.schemaRow.nCols, sizeof(SSchema)); if (NULL == req.name || NULL == req.ntb.schemaRow.pSchema) { tdDestroySVCreateTbReq(&req); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } if (pStmt->ignoreExists) { req.flags |= TD_CREATE_IF_NOT_EXISTS; @@ -13346,7 +13346,7 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFreeClear(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = pTbBatch->info; pVgData->pData = buf; @@ -14069,7 +14069,7 @@ static int32_t prepareReadCsvFile(STranslateContext* pCxt, SCreateSubTableFromFi { pCreateInfo = taosMemoryCalloc(1, sizeof(SCreateTbInfo)); if (NULL == pCreateInfo) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _ERR; } @@ -14379,7 +14379,7 @@ static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SA SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFreeClear(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = pTbBatch->info; pVgData->pData = buf; @@ -14829,7 +14829,7 @@ static int32_t serializeAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pSt SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFree(pMsg); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = vg; pVgData->pData = pMsg; @@ -14934,7 +14934,7 @@ static int32_t serializeFlushVgroup(SVgroupInfo* pVg, SArray* pBufArray) { SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFree(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = *pVg; pVgData->pData = buf; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 250e9385b4..5c4ced7004 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -463,7 +463,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi int32_t valLen = (int32_t)strlen(jsonValue); char* tmp = taosMemoryCalloc(1, valLen * TSDB_NCHAR_SIZE); if (!tmp) { - retCode = TSDB_CODE_OUT_OF_MEMORY; + retCode = terrno; goto end; } val.type = TSDB_DATA_TYPE_NCHAR; @@ -1039,7 +1039,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta) { *pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + pViewMeta->numOfCols * sizeof(SSchema)); if (NULL == *pMeta) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pMeta)->uid = pViewMeta->viewId; (*pMeta)->vgId = MNODE_HANDLE; diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index e96aaf52ed..17f62ac157 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -172,7 +172,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { case TSDB_DATA_TYPE_VARBINARY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); memcpy(varDataVal(pVal->datum.p), pParam->buffer, pVal->node.resType.bytes); @@ -182,7 +182,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { case TSDB_DATA_TYPE_GEOMETRY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes); @@ -192,7 +192,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { pVal->node.resType.bytes *= TSDB_NCHAR_SIZE; pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t output = 0; From ae57974b30d3bd75840328ed852fbe159e829c3d Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 6 Sep 2024 16:07:57 +0800 Subject: [PATCH 02/32] fix mem leak --- source/libs/stream/src/streamBackendRocksdb.c | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 4793a8951a..ced62ba82e 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -2112,11 +2112,15 @@ void destroyCompare(void* arg) { } int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { + int32_t code = 0; SStreamValue key = {.unixTimestamp = ttl, .len = vlen, .rawLen = vlen, .compress = 0, .data = (char*)(value)}; int32_t len = 0; char* dst = NULL; if (vlen > 512) { dst = taosMemoryCalloc(1, vlen + 128); + if (dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } int32_t dstCap = vlen + 128; int32_t compressedSize = LZ4_compress_default((char*)value, dst, vlen, dstCap); if (compressedSize < vlen) { @@ -2129,7 +2133,11 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { if (*dest == NULL) { size_t size = sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len; char* p = taosMemoryCalloc(1, size); - char* buf = p; + if (p == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exception; + } + char* buf = p; len += taosEncodeFixedI64((void**)&buf, key.unixTimestamp); len += taosEncodeFixedI32((void**)&buf, key.len); len += taosEncodeFixedI32((void**)&buf, key.rawLen); @@ -2151,6 +2159,9 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { taosMemoryFree(dst); return len; +_exception: + taosMemoryFree(dst); + return code; } /* @@ -2165,6 +2176,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) { char* pCompressData = NULL; char* pOutput = NULL; if (streamStateValueIsStale(p)) { + code = TSDB_CODE_INVALID_DATA_FMT; goto _EXCEPT; } @@ -2177,24 +2189,44 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) { if (vlen == (sizeof(key.unixTimestamp) + sizeof(key.len) + key.len)) { // compatiable with previous data p = taosDecodeBinary(p, (void**)&pOutput, key.len); + if (p == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _EXCEPT; + } + } else { p = taosDecodeFixedI32(p, &key.rawLen); p = taosDecodeFixedI8(p, &key.compress); if (vlen != (sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len)) { stError("vlen: %d, read len: %d", vlen, key.len); + code = TSDB_CODE_INVALID_DATA_FMT; goto _EXCEPT; } if (key.compress == 1) { p = taosDecodeBinary(p, (void**)&pCompressData, key.len); + if (p == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _EXCEPT; + } pOutput = taosMemoryCalloc(1, key.rawLen); + if (pOutput == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _EXCEPT; + } + int32_t rawLen = LZ4_decompress_safe(pCompressData, pOutput, key.len, key.rawLen); if (rawLen != key.rawLen) { stError("read invalid read, rawlen: %d, currlen: %d", key.rawLen, key.len); + code = TSDB_CODE_INVALID_DATA_FMT; goto _EXCEPT; } key.len = rawLen; } else { p = taosDecodeBinary(p, (void**)&pOutput, key.len); + if (p == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _EXCEPT; + } } } @@ -3179,6 +3211,7 @@ int streamStateGetCfIdx(SStreamState* pState, const char* funcName) { if (err != NULL) { idx = -1; stError("failed to open cf, %p %s_%s, reason:%s", pState, wrapper->idstr, funcName, err); + rocksdb_column_family_handle_destroy(cf); taosMemoryFree(err); } else { stDebug("succ to open cf, %p %s_%s", pState, wrapper->idstr, funcName); @@ -3224,7 +3257,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe int i = streamStateGetCfIdx(pState, funcname); \ if (i < 0) { \ stWarn("streamState failed to get cf name: %s", funcname); \ - code = -1; \ + code = TSDB_CODE_THIRDPARTY_ERROR; \ break; \ } \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ @@ -3241,7 +3274,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe if (err != NULL) { \ stError("streamState str: %s failed to write to %s, err: %s", toString, funcname, err); \ taosMemoryFree(err); \ - code = -1; \ + code = TSDB_CODE_THIRDPARTY_ERROR; \ } else { \ stTrace("streamState str:%s succ to write to %s, rowValLen:%d, ttlValLen:%d, %p", toString, funcname, vLen, \ ttlVLen, wrapper); \ @@ -3301,7 +3334,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe int i = streamStateGetCfIdx(pState, funcname); \ if (i < 0) { \ stWarn("streamState failed to get cf name: %s_%s", pState->pTdbState->idstr, funcname); \ - code = -1; \ + code = TSDB_CODE_THIRDPARTY_ERROR; \ break; \ } \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ @@ -3316,7 +3349,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe if (err != NULL) { \ stError("streamState str: %s failed to del from %s_%s, err: %s", toString, wrapper->idstr, funcname, err); \ taosMemoryFree(err); \ - code = -1; \ + code = TSDB_CODE_THIRDPARTY_ERROR; \ } else { \ stTrace("streamState str: %s succ to del from %s_%s", toString, wrapper->idstr, funcname); \ } \ From 9a06b6eb58944da6c35c7a9d26e1065fc9a11140 Mon Sep 17 00:00:00 2001 From: WANG Xu Date: Fri, 6 Sep 2024 18:11:32 +0800 Subject: [PATCH 03/32] docs: add browser version requirements --- docs/en/14-reference/01-components/07-explorer.md | 2 +- docs/zh/14-reference/01-components/07-explorer.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/14-reference/01-components/07-explorer.md b/docs/en/14-reference/01-components/07-explorer.md index 2a824c6d8f..c270dadb3b 100644 --- a/docs/en/14-reference/01-components/07-explorer.md +++ b/docs/en/14-reference/01-components/07-explorer.md @@ -4,7 +4,7 @@ sidebar_label: Taos-Explorer description: User guide about taosExplorer --- -taos-explorer is a web service which provides GUI based interactive database management tool. +taos-explorer is a web service which provides GUI based interactive database management tool. To ensure the best experience when accessing taosExplorer, please use Chrome version 79 or higher, Edge version 79 or higher. ## Install diff --git a/docs/zh/14-reference/01-components/07-explorer.md b/docs/zh/14-reference/01-components/07-explorer.md index 5a84490b81..6a8972deea 100644 --- a/docs/zh/14-reference/01-components/07-explorer.md +++ b/docs/zh/14-reference/01-components/07-explorer.md @@ -4,7 +4,7 @@ sidebar_label: taosExplorer toc_max_heading_level: 4 --- -taosExplorer 是一个为用户提供 TDengine 实例的可视化管理交互工具的 web 服务。本节主要讲述其安装和部署。它的各项功能都是基于简单易上手的图形界面,可以直接尝试,如果有需要也可以考高级功能和运维指南中的相关内容。 +taosExplorer 是一个为用户提供 TDengine 实例的可视化管理交互工具的 web 服务。本节主要讲述其安装和部署。它的各项功能都是基于简单易上手的图形界面,可以直接尝试,如果有需要也可以考高级功能和运维指南中的相关内容。为了确保访问 taosExplorer 的最佳体验,请使用 Chrome 79 及以上版本,或 Edge 79 及以上版本。 ## 安装 From 43c100b0261c7e6ce880dfaf1024bbab6fc907b5 Mon Sep 17 00:00:00 2001 From: Leo Xu <381899826@qq.com> Date: Mon, 9 Sep 2024 18:11:05 +0800 Subject: [PATCH 04/32] add flexify and S3azure case --- tests/army/storage/s3/azure.py | 86 +++++++ tests/army/storage/s3/s3Basic.py | 2 +- tests/army/storage/s3/s3azure.py | 391 +++++++++++++++++++++++++++++++ 3 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 tests/army/storage/s3/azure.py create mode 100644 tests/army/storage/s3/s3azure.py diff --git a/tests/army/storage/s3/azure.py b/tests/army/storage/s3/azure.py new file mode 100644 index 0000000000..a8b821a50f --- /dev/null +++ b/tests/army/storage/s3/azure.py @@ -0,0 +1,86 @@ +import requests +import hmac +import hashlib +import base64 +from datetime import datetime +from urllib.parse import urlparse, parse_qs +import xml.etree.ElementTree as ET + + +# Define a function to recursively convert XML into a dictionary +def xml_to_dict(element): + if len(element) == 0: + return element.text + result = {} + for child in element: + child_data = xml_to_dict(child) + if child.tag in result: + if isinstance(result[child.tag], list): + result[child.tag].append(child_data) + else: + result[child.tag] = [result[child.tag], child_data] + else: + result[child.tag] = child_data + return result + + +# Get the current time +def get_utc_now(): + return datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT') + + +class Azure: + def __init__(self, account_name, account_key, container_name): + self.account_name = account_name + self.account_key = account_key + self.container_name = container_name + + def blob_list(self): + url = f'https://{self.account_name}.blob.core.windows.net/{self.container_name}?comp=list&restype=container&timeout=20' + return self.console_get(url) + + def generate_signature(self, url): + date = get_utc_now() + version = '2021-08-06' + string_to_sign = (f"GET\n\n\n\n\n\n\n\n\n\n\n\n" + f"x-ms-date:{date}\n" + f"x-ms-version:{version}\n" + f"/{self.account_name}/{self.container_name}") + query_params = parse_qs(urlparse(url).query) + for param in query_params: + string_to_sign += "\n%s:%s" % (param, query_params[param][0]) + decoded_key = base64.b64decode(self.account_key) + signed_string = hmac.new(decoded_key, string_to_sign.encode('utf-8'), hashlib.sha256).digest() + signature = base64.b64encode(signed_string).decode('utf-8') + headers = { + 'x-ms-date': date, + 'x-ms-version': version, + 'Authorization': f'SharedKey {self.account_name}:{signature}' + } + return headers + + def console_get(self, url): + # Generate authorization header + headers = self.generate_signature(url) + # request + response = requests.get(url, headers=headers) + xml_data = response.text + # Parse XML data + root = ET.fromstring(xml_data) + + # Convert XML to Dictionary + data_dict = xml_to_dict(root) + return data_dict + + +if __name__ == '__main__': + # Set request parameters + account_name = 'fd2d01cd892f844eeaa2273' + account_key = '1234' + container_name = 'td-test' + + Azure = Azure(account_name, account_key, container_name) + result = Azure.blob_list() + # Print JSON data + for blob in result["Blobs"]["Blob"]: + print(blob["Name"]) diff --git a/tests/army/storage/s3/s3Basic.py b/tests/army/storage/s3/s3Basic.py index c86c8b0b8e..bc55fe6f5c 100644 --- a/tests/army/storage/s3/s3Basic.py +++ b/tests/army/storage/s3/s3Basic.py @@ -129,7 +129,7 @@ class TDTestCase(TBase): time.sleep(2) sc.dnodeStart(1) loop += 1 - # miggrate + # migrate self.migrateDbS3() # check can pass diff --git a/tests/army/storage/s3/s3azure.py b/tests/army/storage/s3/s3azure.py new file mode 100644 index 0000000000..8274db9354 --- /dev/null +++ b/tests/army/storage/s3/s3azure.py @@ -0,0 +1,391 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time +import random + +import taos +import frame +import frame.etool +import frame.eos +import frame.eutil +import requests + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.srvCtl import * +from frame import * +from frame.eos import * +from azure import Azure + +# +# 192.168.1.52 MINIO S3 +# + +''' +s3EndPoint http://192.168.1.52:9000 +s3AccessKey 'zOgllR6bSnw2Ah3mCNel:cdO7oXAu3Cqdb1rUdevFgJMi0LtRwCXdWKQx4bhX' +s3BucketName ci-bucket +s3UploadDelaySec 60 + +for test: +"s3AccessKey" : "fGPPyYjzytw05nw44ViA:vK1VcwxgSOykicx6hk8fL1x15uEtyDSFU3w4hTaZ" +"s3BucketName": "test-bucket" +''' + + +class TDTestCase(TBase): + def __init__(self): + self.fileName = "" # track the upload of S3 file + + account_name = 'fd2d01cd892f844eeaa2273' + url = "http://192.168.0.21/azure_account_key.txt" + response = requests.get(url) + account_key = response.text.strip() + container_name = 'td-test' + + self.azure_class = Azure(account_name, account_key, container_name) + + # index = eutil.cpuRand(20) + 1 + bucketName = "td-test" + updatecfgDict = { + "supportVnodes": "1000", + 's3EndPoint': 'http://192.168.1.49', + 's3AccessKey': 'FlIOwdr5HAnsMyEZ6FBwSPE5:87x1tZJll1SaK4hoiglC8zPRhDgbMeW6ufQqEt8', + 's3BucketName': f'{bucketName}', + 's3PageCacheSize': '10240', + "s3UploadDelaySec": "10", + 's3MigrateIntervalSec': '600', + 's3MigrateEnabled': '1' + } + + tdLog.info(f"assign bucketName is {bucketName}\n") + maxFileSize = (128 + 10) * 1014 * 1024 # add 10M buffer + + def insertData(self): + tdLog.info(f"insert data.") + # taosBenchmark run + json = etool.curFile(__file__, "s3Basic.json") + etool.benchMark(json=json) + + tdSql.execute(f"use {self.db}") + # come from s3_basic.json + self.childtable_count = 6 + self.insert_rows = 2000000 + self.timestamp_step = 100 + + def createStream(self, sname): + sql = f"create stream {sname} fill_history 1 into stm1 as select count(*) from {self.db}.{self.stb} interval(10s);" + tdSql.execute(sql) + + def migrateDbS3(self): + sql = f"s3migrate database {self.db}" + tdSql.execute(sql, show=True) + + def checkDataFile(self, lines, maxFileSize): + # ls -l + # -rwxrwxrwx 1 root root 41652224 Apr 17 14:47 vnode2/tsdb/v2f1974ver47.3.data + overCnt = 0 + for line in lines: + cols = line.split() + fileSize = int(cols[4]) + fileName = cols[8] + # print(f" filesize={fileSize} fileName={fileName} line={line}") + if fileSize > maxFileSize: + tdLog.info(f"error, {fileSize} over max size({maxFileSize}) {fileName}\n") + overCnt += 1 + self.fileName = fileName + else: + tdLog.info(f"{fileName}({fileSize}) check size passed.") + + return overCnt + + def checkUploadToS3(self): + rootPath = sc.clusterRootPath() + cmd = f"ls -l {rootPath}/dnode*/data/vnode/vnode*/tsdb/*.data" + tdLog.info(cmd) + loop = 0 + rets = [] + overCnt = 0 + while loop < 200: + time.sleep(3) + + # check upload to s3 + rets = eos.runRetList(cmd) + cnt = len(rets) + if cnt == 0: + overCnt = 0 + tdLog.info("All data file upload to server over.") + break + overCnt = self.checkDataFile(rets, self.maxFileSize) + if overCnt == 0: + uploadOK = True + tdLog.info(f"All data files({len(rets)}) size bellow {self.maxFileSize}, check upload to s3 ok.") + break + + tdLog.info(f"loop={loop} no upload {overCnt} data files wait 3s retry ...") + if loop == 3: + sc.dnodeStop(1) + time.sleep(2) + sc.dnodeStart(1) + loop += 1 + # migrate + self.migrateDbS3() + + # check can pass + if overCnt > 0: + tdLog.exit(f"s3 have {overCnt} files over size.") + + def doAction(self): + tdLog.info(f"do action.") + + self.flushDb(show=True) + # self.compactDb(show=True) + + # sleep 70s + self.migrateDbS3() + + # check upload to s3 + self.checkUploadToS3() + + def check_azure_exist(self): + result = self.azure_class.blob_list() + if not self.fileName: + tdLog.exit("cannot find S3 file") + datafile = self.fileName.split("/")[-1].split(".")[0] + for blob in result["Blobs"]["Blob"]: + if datafile in blob["Name"]: + tdLog.info("Successfully found the file %s in Azure" % self.fileName) + break + else: + tdLog.exit("failed found the file %s in Azure" % self.fileName) + + def check_azure_not_exist(self): + datafile = self.fileName.split("/")[-1].split(".")[0] + + result = self.azure_class.blob_list() + for blob in result["Blobs"]["Blob"]: + if datafile in blob["Name"]: + tdLog.exit("failed delete the file %s in Azure" % self.fileName) + break + else: + tdLog.info("Successfully delete the file %s in Azure" % self.fileName) + + def checkStreamCorrect(self): + sql = f"select count(*) from {self.db}.stm1" + count = 0 + for i in range(120): + tdSql.query(sql) + count = tdSql.getData(0, 0) + if count == 100000 or count == 100001: + return True + time.sleep(1) + + tdLog.exit(f"stream count is not expect . expect = 100000 or 100001 real={count} . sql={sql}") + + def checkCreateDb(self, keepLocal, chunkSize, compact): + # keyword + kw1 = kw2 = kw3 = "" + if keepLocal is not None: + kw1 = f"s3_keeplocal {keepLocal}" + if chunkSize is not None: + kw2 = f"s3_chunksize {chunkSize}" + if compact is not None: + kw3 = f"s3_compact {compact}" + + sql = f" create database db1 vgroups 1 duration 1h {kw1} {kw2} {kw3}" + tdSql.execute(sql, show=True) + # sql = f"select name,s3_keeplocal,s3_chunksize,s3_compact from information_schema.ins_databases where name='db1';" + sql = f"select * from information_schema.ins_databases where name='db1';" + tdSql.query(sql) + # 29 30 31 -> chunksize keeplocal compact + if chunkSize is not None: + tdSql.checkData(0, 29, chunkSize) + if keepLocal is not None: + keepLocalm = keepLocal * 24 * 60 + tdSql.checkData(0, 30, f"{keepLocalm}m") + if compact is not None: + tdSql.checkData(0, 31, compact) + sql = "drop database db1" + tdSql.execute(sql) + + def checkExcept(self): + # errors + sqls = [ + f"create database db2 s3_keeplocal -1", + f"create database db2 s3_keeplocal 0", + f"create database db2 s3_keeplocal 365001", + f"create database db2 s3_chunksize -1", + f"create database db2 s3_chunksize 0", + f"create database db2 s3_chunksize 900000000", + f"create database db2 s3_compact -1", + f"create database db2 s3_compact 100", + f"create database db2 duration 1d s3_keeplocal 1d" + ] + tdSql.errors(sqls) + + def checkBasic(self): + # create db + keeps = [1, 256, 1024, 365000, None] + chunks = [131072, 600000, 820000, 1048576, None] + comps = [0, 1, None] + + for keep in keeps: + for chunk in chunks: + for comp in comps: + self.checkCreateDb(keep, chunk, comp) + + # --checks3 + idx = 1 + taosd = sc.taosdFile(idx) + cfg = sc.dnodeCfgPath(idx) + cmd = f"{taosd} -c {cfg} --checks3" + + eos.exe(cmd) + # output, error = eos.run(cmd) + # print(lines) + + ''' + tips = [ + "put object s3test.txt: success", + "listing bucket ci-bucket: success", + "get object s3test.txt: success", + "delete object s3test.txt: success" + ] + pos = 0 + for tip in tips: + pos = output.find(tip, pos) + #if pos == -1: + # tdLog.exit(f"checks3 failed not found {tip}. cmd={cmd} output={output}") + ''' + + # except + self.checkExcept() + + # + def preDb(self, vgroups): + cnt = int(time.time()) % 2 + 1 + for i in range(cnt): + vg = eutil.cpuRand(9) + 1 + sql = f"create database predb vgroups {vg}" + tdSql.execute(sql, show=True) + sql = "drop database predb" + tdSql.execute(sql, show=True) + + # history + def insertHistory(self): + tdLog.info(f"insert history data.") + # taosBenchmark run + json = etool.curFile(__file__, "s3Basic1.json") + etool.benchMark(json=json) + + # come from s3_basic.json + self.insert_rows += self.insert_rows / 4 + self.timestamp_step = 50 + + # delete + def checkDelete(self): + # del 1000 rows + start = 1600000000000 + drows = 200 + for i in range(1, drows, 2): + sql = f"from {self.db}.{self.stb} where ts = {start + i * 500}" + tdSql.execute("delete " + sql, show=True) + tdSql.query("select * " + sql) + tdSql.checkRows(0) + + # delete all 500 step + self.flushDb() + self.compactDb() + self.insert_rows -= drows / 2 + sql = f"select count(*) from {self.db}.{self.stb}" + tdSql.checkAgg(sql, self.insert_rows * self.childtable_count) + + # delete 10W rows from 100000 + drows = 100000 + sdel = start + 100000 * self.timestamp_step + edel = start + 100000 * self.timestamp_step + drows * self.timestamp_step + sql = f"from {self.db}.{self.stb} where ts >= {sdel} and ts < {edel}" + tdSql.execute("delete " + sql, show=True) + tdSql.query("select * " + sql) + tdSql.checkRows(0) + + self.insert_rows -= drows + sql = f"select count(*) from {self.db}.{self.stb}" + tdSql.checkAgg(sql, self.insert_rows * self.childtable_count) + + # run + def run(self): + tdLog.debug(f"start to excute {__file__}") + self.sname = "stream1" + if eos.isArm64Cpu(): + tdLog.success(f"{__file__} arm64 ignore executed") + else: + + self.preDb(10) + + # insert data + self.insertData() + + # creat stream + self.createStream(self.sname) + + # check insert data correct + # self.checkInsertCorrect() + + # save + self.snapshotAgg() + + # do action + self.doAction() + # check azure data exist + self.check_azure_exist() + # check save agg result correct + self.checkAggCorrect() + + # check insert correct again + self.checkInsertCorrect() + + # check stream correct and drop stream + # self.checkStreamCorrect() + + # drop stream + self.dropStream(self.sname) + + # # insert history disorder data + # self.insertHistory() + # + # # checkBasic + # self.checkBasic() + + # self.checkInsertCorrect() + # self.snapshotAgg() + # self.doAction() + # self.checkAggCorrect() + # self.checkInsertCorrect(difCnt=self.childtable_count * 1499999) + # self.checkDelete() + # self.doAction() + + # drop database and free s3 file + self.dropDb() + # check azure data not exist + self.check_azure_not_exist() + + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From c65ad1287d1ddeca452b465ccbc298382a8c4a11 Mon Sep 17 00:00:00 2001 From: Leo Xu <381899826@qq.com> Date: Mon, 9 Sep 2024 18:13:12 +0800 Subject: [PATCH 05/32] alter flexify num 1 to 2 --- tests/army/storage/s3/s3azure.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/army/storage/s3/s3azure.py b/tests/army/storage/s3/s3azure.py index 8274db9354..43857cb7ca 100644 --- a/tests/army/storage/s3/s3azure.py +++ b/tests/army/storage/s3/s3azure.py @@ -63,8 +63,8 @@ class TDTestCase(TBase): bucketName = "td-test" updatecfgDict = { "supportVnodes": "1000", - 's3EndPoint': 'http://192.168.1.49', - 's3AccessKey': 'FlIOwdr5HAnsMyEZ6FBwSPE5:87x1tZJll1SaK4hoiglC8zPRhDgbMeW6ufQqEt8', + 's3EndPoint': 'http://192.168.1.49,http://192.168.1.49:81', + 's3AccessKey': 'FlIOwdr5HAnsMyEZ6FBwSPE5:87x1tZJll1SaK4hoiglC8zPRhDgbMeW6ufQqEt8,FlIOvHz0MePAf4KttYqfZM:Hve86EvB6KdvRPa5d1DG38jP6BSSSJC7IxYvSgEP', 's3BucketName': f'{bucketName}', 's3PageCacheSize': '10240', "s3UploadDelaySec": "10", @@ -161,7 +161,7 @@ class TDTestCase(TBase): # check upload to s3 self.checkUploadToS3() - def check_azure_exist(self): + def checkAzureDataExist(self): result = self.azure_class.blob_list() if not self.fileName: tdLog.exit("cannot find S3 file") @@ -173,7 +173,7 @@ class TDTestCase(TBase): else: tdLog.exit("failed found the file %s in Azure" % self.fileName) - def check_azure_not_exist(self): + def checkAzureDataNotExist(self): datafile = self.fileName.split("/")[-1].split(".")[0] result = self.azure_class.blob_list() @@ -352,7 +352,7 @@ class TDTestCase(TBase): # do action self.doAction() # check azure data exist - self.check_azure_exist() + self.checkAzureDataExist() # check save agg result correct self.checkAggCorrect() @@ -365,24 +365,10 @@ class TDTestCase(TBase): # drop stream self.dropStream(self.sname) - # # insert history disorder data - # self.insertHistory() - # - # # checkBasic - # self.checkBasic() - - # self.checkInsertCorrect() - # self.snapshotAgg() - # self.doAction() - # self.checkAggCorrect() - # self.checkInsertCorrect(difCnt=self.childtable_count * 1499999) - # self.checkDelete() - # self.doAction() - # drop database and free s3 file self.dropDb() # check azure data not exist - self.check_azure_not_exist() + self.checkAzureDataNotExist() tdLog.success(f"{__file__} successfully executed") From b57cd278278b11bf46cbe485844c8dce9356fab1 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 9 Sep 2024 18:20:00 +0800 Subject: [PATCH 06/32] enh: add block check --- include/common/tdatablock.h | 1 + source/common/src/tdatablock.c | 70 +++++++++++++++++++++++++++++ source/libs/executor/src/operator.c | 2 + 3 files changed, 73 insertions(+) diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 22a43012c5..1d280b5d6b 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -233,6 +233,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo); * @brief find how many rows already in order start from first row */ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo); +void blockDataCheck(const SSDataBlock* pDataBlock); int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload); int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index ea3e88919b..22bca726d7 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -2936,6 +2936,8 @@ int32_t buildCtbNameByGroupIdImpl(const char* stbFullName, uint64_t groupId, cha // return length of encoded data, return -1 if failed int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) { + blockDataCheck(pBlock); + int32_t dataLen = 0; // todo extract method @@ -3177,6 +3179,9 @@ int32_t blockDecode(SSDataBlock* pBlock, const char* pData, const char** pEndPos } *pEndPos = pStart; + + blockDataCheck(pBlock); + return code; } @@ -3386,3 +3391,68 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) { return nextRowIdx; } + +void blockDataCheck(const SSDataBlock* pDataBlock) { + if (NULL == pDataBlock || pDataBlock->info.rows == 0) { + return; + } + + ASSERT(pDataBlock->info.rows > 0); + + if (!pDataBlock->info.dataLoad) { + return; + } + + bool isVarType = false; + int32_t colLen = 0; + int32_t nextPos = 0; + int64_t checkRows = 0; + int64_t typeValue = 0; + int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); + for (int32_t i = 0; i < colNum; ++i) { + SColumnInfoData* pCol = (SColumnInfoData*)taosArrayGet(pDataBlock->pDataBlock, i); + isVarType = IS_VAR_DATA_TYPE(pCol->info.type); + checkRows = pDataBlock->info.rows; + + if (isVarType) { + ASSERT(pCol->varmeta.length); + } else { + ASSERT(pCol->nullbitmap); + } + + for (int64_t r = 0; r < checkRows; ++r) { + if (!colDataIsNull_s(pCol, r)) { + ASSERT(pCol->pData); + ASSERT(pCol->varmeta.length <= pCol->varmeta.allocLen); + + if (isVarType) { + ASSERT(pCol->varmeta.allocLen > 0); + ASSERT(pCol->varmeta.offset[r] < pCol->varmeta.length); + if (pCol->reassigned) { + ASSERT(pCol->varmeta.offset[r] >= 0); + } else { + ASSERT(pCol->varmeta.offset[r] == nextPos); + } + + colLen = varDataTLen(pCol->pData + pCol->varmeta.offset[r]); + ASSERT(colLen >= VARSTR_HEADER_SIZE); + ASSERT(colLen <= pCol->info.bytes); + + if (pCol->reassigned) { + ASSERT((pCol->varmeta.offset[r] + colLen) <= pCol->varmeta.length); + } else { + nextPos += colLen; + ASSERT(nextPos <= pCol->varmeta.length); + } + + typeValue = *(char*)(pCol->pData + pCol->varmeta.offset[r] + colLen - 1); + } else { + GET_TYPED_DATA(typeValue, int64_t, pCol->info.type, colDataGetNumData(pCol, r)); + } + } + } + } + + return; +} + diff --git a/source/libs/executor/src/operator.c b/source/libs/executor/src/operator.c index 6fe270161f..de478a146f 100644 --- a/source/libs/executor/src/operator.c +++ b/source/libs/executor/src/operator.c @@ -868,12 +868,14 @@ int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInpu SSDataBlock* getNextBlockFromDownstream(struct SOperatorInfo* pOperator, int32_t idx) { SSDataBlock* p = NULL; int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, true, &p); + blockDataCheck(p); return (code == 0)? p:NULL; } SSDataBlock* getNextBlockFromDownstreamRemain(struct SOperatorInfo* pOperator, int32_t idx) { SSDataBlock* p = NULL; int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, false, &p); + blockDataCheck(p); return (code == 0)? p:NULL; } From d199f852f5b383114587a98567b2822acd9484a3 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 9 Sep 2024 19:28:08 +0800 Subject: [PATCH 07/32] fix: check issue --- source/common/src/tdatablock.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 22bca726d7..840434a351 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -3415,11 +3415,12 @@ void blockDataCheck(const SSDataBlock* pDataBlock) { checkRows = pDataBlock->info.rows; if (isVarType) { - ASSERT(pCol->varmeta.length); + ASSERT(pCol->varmeta.offset); } else { ASSERT(pCol->nullbitmap); } - + + nextPos = 0; for (int64_t r = 0; r < checkRows; ++r) { if (!colDataIsNull_s(pCol, r)) { ASSERT(pCol->pData); From 4bc8db22fa747ca2f3376d3828e9d054c957c6a7 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 9 Sep 2024 19:54:56 +0800 Subject: [PATCH 08/32] enh: grant column length adaption --- include/common/tgrant.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/common/tgrant.h b/include/common/tgrant.h index f6b98cf844..1660cc6a1b 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -74,26 +74,26 @@ int32_t tGetMachineId(char **result); #ifdef TD_ENTERPRISE #define GRANTS_SCHEMA \ static const SSysDbTableSchema grantsSchema[] = { \ - {.name = "version", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "version", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "timeseries", .bytes = 43 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "dnodes", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "cpu_cores", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ } #else #define GRANTS_SCHEMA \ static const SSysDbTableSchema grantsSchema[] = { \ - {.name = "version", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "version", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "timeseries", .bytes = 43 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "dnodes", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "cpu_cores", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ } #endif // #define GRANT_CFG_ADD From e8123a9422d4de27b1537523d488f445e60c5197 Mon Sep 17 00:00:00 2001 From: wangjiaming0909 <604227650@qq.com> Date: Tue, 10 Sep 2024 11:13:31 +0800 Subject: [PATCH 09/32] fix tdb/client eating error codes caused creating tsma blocking --- source/client/src/clientImpl.c | 8 ++++++-- source/dnode/vnode/src/meta/metaQuery.c | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index b9a00f4434..d77b8dcbb7 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1068,6 +1068,7 @@ static int32_t createResultBlock(TAOS_RES* pRes, int32_t numOfRows, SSDataBlock* TAOS_ROW pRow = taos_fetch_row(pRes); if (NULL == pRow[0] || NULL == pRow[1] || NULL == pRow[2]) { tscError("invalid data from vnode"); + blockDataDestroy(*pBlock); return TSDB_CODE_TSC_INTERNAL_ERROR; } int64_t ts = *(int64_t*)pRow[0]; @@ -1102,8 +1103,11 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) { } SSDataBlock* pBlock = NULL; - if (TSDB_CODE_SUCCESS != createResultBlock(res, rowNum, &pBlock)) { - tscError("0x%" PRIx64 ", create result block failed,QID:0x%" PRIx64, pRequest->self, pRequest->requestId); + pRequest->code = createResultBlock(res, rowNum, &pBlock); + if (TSDB_CODE_SUCCESS != pRequest->code) { + tscError("0x%" PRIx64 ", create result block failed,QID:0x%" PRIx64 " %s", pRequest->self, pRequest->requestId, + tstrerror(pRequest->code)); + returnToUser(pRequest); return; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 725d16d86f..acee24e494 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -54,8 +54,8 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u STbDbKey tbDbKey = {.version = version, .uid = uid}; // query table.db - if (tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pReader->pBuf, &pReader->szBuf) < 0) { - return terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; + if ((code = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pReader->pBuf, &pReader->szBuf)) < 0) { + return terrno = (TSDB_CODE_NOT_FOUND == code ? TSDB_CODE_PAR_TABLE_NOT_EXIST : code); } // decode the entry @@ -98,8 +98,9 @@ int metaReaderGetTableEntryByUidCache(SMetaReader *pReader, tb_uid_t uid) { SMeta *pMeta = pReader->pMeta; SMetaInfo info; - if (metaGetInfo(pMeta, uid, &info, pReader) == TSDB_CODE_NOT_FOUND) { - return terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; + int32_t code = metaGetInfo(pMeta, uid, &info, pReader); + if (TSDB_CODE_SUCCESS != code) { + return terrno = (TSDB_CODE_NOT_FOUND == code ? TSDB_CODE_PAR_TABLE_NOT_EXIST : code); } return metaGetTableEntryByVersion(pReader, info.version, uid); @@ -1584,10 +1585,9 @@ int32_t metaGetInfo(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo, SMetaReader *pR } // search TDB - if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData) < 0) { + if ((code = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData)) < 0) { // not found if (!lock) metaULock(pMeta); - code = TSDB_CODE_NOT_FOUND; goto _exit; } From 51bee72807351202e5d325e8c0e200680cdb634c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 10 Sep 2024 12:58:08 +0800 Subject: [PATCH 10/32] fix(stream):not reset the failed checkpointId --- source/libs/stream/src/streamCheckpoint.c | 25 ++++++++++++++---- source/libs/stream/src/streamDispatch.c | 28 ++++++++++++++------- source/libs/stream/src/streamTask.c | 6 +++-- tests/script/tsim/stream/pauseAndResume.sim | 5 +++- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index e091d0f34b..242e12f591 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -235,6 +235,16 @@ int32_t streamProcessCheckpointTriggerBlock(SStreamTask* pTask, SStreamDataBlock return code; } + if (pActiveInfo->failedId >= checkpointId) { + stError("s-task:%s vgId:%d checkpointId:%" PRId64 " transId:%d, has been marked failed, failedId:%" PRId64 + "discard the checkpoint-trigger block", + id, vgId, checkpointId, transId, pActiveInfo->failedId); + streamMutexUnlock(&pTask->lock); + + streamFreeQitem((SStreamQueueItem*)pBlock); + return code; + } + if (pTask->chkInfo.checkpointId == checkpointId) { { // send checkpoint-ready msg to upstream SRpcMsg msg = {0}; @@ -531,15 +541,20 @@ int32_t streamTaskProcessCheckpointReadyRsp(SStreamTask* pTask, int32_t upstream } void streamTaskClearCheckInfo(SStreamTask* pTask, bool clearChkpReadyMsg) { + SActiveCheckpointInfo* pInfo = pTask->chkInfo.pActiveInfo; + pTask->chkInfo.startTs = 0; // clear the recorded start time streamTaskOpenAllUpstreamInput(pTask); // open inputQ for all upstream tasks - streamMutexLock(&pTask->chkInfo.pActiveInfo->lock); - streamTaskClearActiveInfo(pTask->chkInfo.pActiveInfo); + streamMutexLock(&pInfo->lock); + streamTaskClearActiveInfo(pInfo); if (clearChkpReadyMsg) { - streamClearChkptReadyMsg(pTask->chkInfo.pActiveInfo); + streamClearChkptReadyMsg(pInfo); } - streamMutexUnlock(&pTask->chkInfo.pActiveInfo->lock); + streamMutexUnlock(&pInfo->lock); + + stDebug("s-task:%s clear active checkpointInfo, failed checkpointId:%"PRId64", current checkpointId:%"PRId64, + pTask->id.idStr, pInfo->failedId, pTask->chkInfo.checkpointId); } int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, bool restored, SVUpdateCheckpointInfoReq* pReq) { @@ -669,7 +684,7 @@ void streamTaskSetFailedCheckpointId(SStreamTask* pTask) { stWarn("s-task:%s checkpoint-info is cleared now, not set the failed checkpoint info", pTask->id.idStr); } else { pInfo->failedId = pInfo->activeId; - stDebug("s-task:%s mark the checkpointId:%" PRId64 " (transId:%d) failed", pTask->id.idStr, pInfo->activeId, + stDebug("s-task:%s mark and set the failed checkpointId:%" PRId64 " (transId:%d)", pTask->id.idStr, pInfo->activeId, pInfo->transId); } } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 2a32a1d522..4926dcb69d 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -726,9 +726,10 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S } int32_t streamDispatchStreamBlock(SStreamTask* pTask) { - const char* id = pTask->id.idStr; - int32_t code = 0; - SStreamDataBlock* pBlock = NULL; + const char* id = pTask->id.idStr; + int32_t code = 0; + SStreamDataBlock* pBlock = NULL; + SActiveCheckpointInfo* pInfo = pTask->chkInfo.pActiveInfo; int32_t numOfElems = streamQueueGetNumOfItems(pTask->outputq.queue); if (numOfElems > 0) { @@ -746,10 +747,15 @@ int32_t streamDispatchStreamBlock(SStreamTask* pTask) { return 0; } - if (pTask->chkInfo.pActiveInfo->dispatchTrigger) { - stDebug("s-task:%s already send checkpoint-trigger, no longer dispatch any other data", id); - atomic_store_8(&pTask->outputq.status, TASK_OUTPUT_STATUS__NORMAL); - return 0; + if (pInfo->dispatchTrigger) { + if ((pInfo->activeId != 0) && (pInfo->failedId < pInfo->activeId)) { + stDebug("s-task:%s already send checkpoint-trigger, no longer dispatch any other data", id); + atomic_store_8(&pTask->outputq.status, TASK_OUTPUT_STATUS__NORMAL); + return 0; + } else { + stDebug("s-task:%s dispatch trigger set, and ignore since current active checkpointId:%" PRId64 " failed", id, + pInfo->activeId); + } } if (pTask->msgInfo.pData != NULL) { @@ -788,8 +794,10 @@ int32_t streamDispatchStreamBlock(SStreamTask* pTask) { if (type == STREAM_INPUT__CHECKPOINT_TRIGGER) { // outputQ should be empty here, otherwise, set the checkpoint failed due to the retrieve req happens if (streamQueueGetNumOfUnAccessedItems(pTask->outputq.queue) > 0) { - stError("s-task:%s items are still in outputQ due to downstream retrieve, failed to init trigger dispatch", - pTask->id.idStr); + stError( + "s-task:%s items are still in outputQ due to downstream retrieve, failed to init and discard " + "checkpoint-trigger dispatch", + pTask->id.idStr); streamTaskSetCheckpointFailed(pTask); clearBufferedDispatchMsg(pTask); continue; @@ -1478,6 +1486,8 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i int32_t numOfFailed = 0; bool triggerDispatchRsp = false; + taosMsleep(500); + // we only set the dispatch msg info for current checkpoint trans streamMutexLock(&pTask->lock); triggerDispatchRsp = (streamTaskGetStatus(pTask).state == TASK_STATUS__CK) && diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 6d8f90f7f6..355a586e52 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -1190,6 +1190,7 @@ void streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t c pTask->chkInfo.pActiveInfo->transId = transId; pTask->chkInfo.pActiveInfo->activeId = checkpointId; pTask->chkInfo.pActiveInfo->failedId = checkpointId; + stDebug("s-task:%s set failed checkpointId:%"PRId64, pTask->id.idStr, checkpointId); } int32_t streamTaskCreateActiveChkptInfo(SActiveCheckpointInfo** pRes) { @@ -1239,12 +1240,13 @@ void streamTaskDestroyActiveChkptInfo(SActiveCheckpointInfo* pInfo) { taosMemoryFree(pInfo); } +//NOTE: clear the checkpoint id, and keep the failed id void streamTaskClearActiveInfo(SActiveCheckpointInfo* pInfo) { - pInfo->activeId = 0; // clear the checkpoint id + pInfo->activeId = 0; pInfo->transId = 0; pInfo->allUpstreamTriggerRecv = 0; pInfo->dispatchTrigger = false; - pInfo->failedId = 0; +// pInfo->failedId = 0; taosArrayClear(pInfo->pDispatchTriggerList); taosArrayClear(pInfo->pCheckpointReadyRecvList); diff --git a/tests/script/tsim/stream/pauseAndResume.sim b/tests/script/tsim/stream/pauseAndResume.sim index c2998dea30..1f4caf5c03 100644 --- a/tests/script/tsim/stream/pauseAndResume.sim +++ b/tests/script/tsim/stream/pauseAndResume.sim @@ -109,7 +109,7 @@ endi print ===== idle for 70 sec for checkpoint gen sleep 70000 -print ===== idle 60 sec completed , continue +print ===== idle 70 sec completed , continue print ===== step 1 over @@ -127,9 +127,12 @@ sql create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 wate sql_error create stream streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s); sql create stream if not exists streams2 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 watermark 1d into streamt2 as select _wstart, count(*) c1, sum(a) c3 from t1 interval(10s); +print start to check stream status + sleep 1000 run tsim/stream/checkTaskStatus.sim +print pause stream2 sql pause stream streams2; sql insert into t1 values(1648791213001,1,12,3,1.0); From 81b0bdadc1c7b08b93aba2ab3b35c31c137f6298 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 10 Sep 2024 14:31:24 +0800 Subject: [PATCH 11/32] fix(stream): update the acceptcode for task epset update. --- source/dnode/mnode/impl/src/mndStreamUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndStreamUtil.c b/source/dnode/mnode/impl/src/mndStreamUtil.c index a405cdde0a..7cb02d1467 100644 --- a/source/dnode/mnode/impl/src/mndStreamUtil.c +++ b/source/dnode/mnode/impl/src/mndStreamUtil.c @@ -653,7 +653,7 @@ static int32_t doSetUpdateTaskAction(SMnode *pMnode, STrans *pTrans, SStreamTask return code; } - code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, TSDB_CODE_VND_INVALID_VGROUP_ID, 0); + code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, TSDB_CODE_VND_INVALID_VGROUP_ID, TSDB_CODE_VND_INVALID_VGROUP_ID); if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(pBuf); } From 568b18d4ed220339e01b0a3e953376b319452829 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 10 Sep 2024 14:34:53 +0800 Subject: [PATCH 12/32] fix(stream): update the acceptcode for task epset update. --- source/dnode/mnode/impl/src/mndStreamUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndStreamUtil.c b/source/dnode/mnode/impl/src/mndStreamUtil.c index 7cb02d1467..b2e35827af 100644 --- a/source/dnode/mnode/impl/src/mndStreamUtil.c +++ b/source/dnode/mnode/impl/src/mndStreamUtil.c @@ -653,7 +653,7 @@ static int32_t doSetUpdateTaskAction(SMnode *pMnode, STrans *pTrans, SStreamTask return code; } - code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, TSDB_CODE_VND_INVALID_VGROUP_ID, TSDB_CODE_VND_INVALID_VGROUP_ID); + code = setTransAction(pTrans, pBuf, len, TDMT_VND_STREAM_TASK_UPDATE, &epset, 0, TSDB_CODE_VND_INVALID_VGROUP_ID); if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(pBuf); } From f18c1d87101f2dad0f87eb2584d53db8eea843b7 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 10 Sep 2024 14:35:43 +0800 Subject: [PATCH 13/32] enh: error code handle --- source/dnode/vnode/src/inc/vnd.h | 6 +- source/dnode/vnode/src/inc/vnodeInt.h | 2 +- source/dnode/vnode/src/tsdb/tsdbCache.c | 4 +- source/dnode/vnode/src/tsdb/tsdbCommit2.c | 2 +- source/dnode/vnode/src/tsdb/tsdbFS2.c | 7 +- source/dnode/vnode/src/tsdb/tsdbFSet2.c | 6 +- source/dnode/vnode/src/tsdb/tsdbFSet2.h | 2 +- source/dnode/vnode/src/tsdb/tsdbMerge.c | 2 +- source/dnode/vnode/src/tsdb/tsdbMergeTree.c | 6 +- source/dnode/vnode/src/tsdb/tsdbSnapInfo.c | 6 +- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 4 +- source/dnode/vnode/src/tsdb/tsdbSttFileRW.c | 5 +- source/dnode/vnode/src/tsdb/tsdbSttFileRW.h | 10 +-- source/dnode/vnode/src/vnd/vnodeAsync.c | 84 +++++++++++---------- source/dnode/vnode/src/vnd/vnodeBufPool.c | 12 ++- source/dnode/vnode/src/vnd/vnodeCfg.c | 2 +- source/dnode/vnode/src/vnd/vnodeCommit.c | 24 ++++-- source/dnode/vnode/src/vnd/vnodeHash.c | 5 +- source/dnode/vnode/src/vnd/vnodeModule.c | 2 +- source/dnode/vnode/src/vnd/vnodeOpen.c | 6 +- source/dnode/vnode/src/vnd/vnodeSnapshot.c | 4 +- source/dnode/vnode/src/vnd/vnodeSvr.c | 6 +- 22 files changed, 106 insertions(+), 101 deletions(-) diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 1bc1eadca7..ff622d2dab 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -56,12 +56,12 @@ typedef enum { } EVAPriority; int32_t vnodeAsyncOpen(int32_t numOfThreads); -int32_t vnodeAsyncClose(); +void vnodeAsyncClose(); int32_t vnodeAChannelInit(int64_t async, SVAChannelID* channelID); int32_t vnodeAChannelDestroy(SVAChannelID* channelID, bool waitRunning); int32_t vnodeAsync(SVAChannelID* channelID, EVAPriority priority, int32_t (*execute)(void*), void (*complete)(void*), void* arg, SVATaskID* taskID); -int32_t vnodeAWait(SVATaskID* taskID); +void vnodeAWait(SVATaskID* taskID); int32_t vnodeACancel(SVATaskID* taskID); int32_t vnodeAsyncSetWorkers(int64_t async, int32_t numWorkers); @@ -95,7 +95,7 @@ struct SVBufPool { }; int32_t vnodeOpenBufPool(SVnode* pVnode); -int32_t vnodeCloseBufPool(SVnode* pVnode); +void vnodeCloseBufPool(SVnode* pVnode); void vnodeBufPoolReset(SVBufPool* pPool); void vnodeBufPoolAddToFreeList(SVBufPool* pPool); int32_t vnodeBufPoolRecycle(SVBufPool* pPool); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 4bcd5335f7..7b1f3716c4 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -593,7 +593,7 @@ struct SVHashTable { #define vHashNumEntries(ht) ((ht)->numEntries) int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*compare)(const void*, const void*)); -int32_t vHashDestroy(SVHashTable** ht); +void vHashDestroy(SVHashTable** ht); int32_t vHashPut(SVHashTable* ht, void* obj); int32_t vHashGet(SVHashTable* ht, const void* obj, void** retObj); int32_t vHashDrop(SVHashTable* ht, const void* obj); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index f11788bb47..3a3e20612e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -2153,7 +2153,7 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea uint64_t uid = uidList[j]; STableLoadInfo *pInfo = getTableLoadInfo(pReader, uid); if (!pInfo) { - (void)tTombBlockDestroy(&block); + tTombBlockDestroy(&block); TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } @@ -2225,7 +2225,7 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea } } - (void)tTombBlockDestroy(&block); + tTombBlockDestroy(&block); if (finished) { TAOS_RETURN(code); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 586a86bdb6..58ab8bca82 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -418,7 +418,7 @@ static int32_t tsdbCommitInfoDestroy(STsdb *pTsdb) { taosMemoryFree(info); } - TAOS_UNUSED(vHashDestroy(&pTsdb->commitInfo->ht)); + vHashDestroy(&pTsdb->commitInfo->ht); taosArrayDestroy(pTsdb->commitInfo->arr); pTsdb->commitInfo->arr = NULL; taosMemoryFreeClear(pTsdb->commitInfo); diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index ea9cb5f768..4ccda58903 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -252,7 +252,7 @@ static int32_t apply_commit(STFileSystem *fs) { if (fset1 && fset2) { if (fset1->fid < fset2->fid) { // delete fset1 - (void)tsdbTFileSetRemove(fset1); + tsdbTFileSetRemove(fset1); i1++; } else if (fset1->fid > fset2->fid) { // create new file set with fid of fset2->fid @@ -271,7 +271,7 @@ static int32_t apply_commit(STFileSystem *fs) { } } else if (fset1) { // delete fset1 - (void)tsdbTFileSetRemove(fset1); + tsdbTFileSetRemove(fset1); i1++; } else { // create new file set with fid of fset2->fid @@ -794,11 +794,10 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { return 0; } -int32_t tsdbEnableBgTask(STsdb *pTsdb) { +void tsdbEnableBgTask(STsdb *pTsdb) { (void)taosThreadMutexLock(&pTsdb->mutex); pTsdb->bgTaskDisabled = false; (void)taosThreadMutexUnlock(&pTsdb->mutex); - return 0; } int32_t tsdbCloseFS(STFileSystem **fs) { diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.c b/source/dnode/vnode/src/tsdb/tsdbFSet2.c index 8864968f63..5a07994678 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.c @@ -627,8 +627,8 @@ void tsdbTFileSetClear(STFileSet **fset) { } } -int32_t tsdbTFileSetRemove(STFileSet *fset) { - if (fset == NULL) return 0; +void tsdbTFileSetRemove(STFileSet *fset) { + if (fset == NULL) return; for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if (fset->farr[ftype] != NULL) { @@ -638,8 +638,6 @@ int32_t tsdbTFileSetRemove(STFileSet *fset) { } TARRAY2_DESTROY(fset->lvlArr, tsdbSttLvlRemove); - - return 0; } SSttLvl *tsdbTFileSetGetSttLvl(STFileSet *fset, int32_t level) { diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.h b/source/dnode/vnode/src/tsdb/tsdbFSet2.h index 25c998e945..24ae59e300 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.h @@ -43,7 +43,7 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset); int32_t tsdbTFileSetInitCopy(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset); int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset); void tsdbTFileSetClear(STFileSet **fset); -int32_t tsdbTFileSetRemove(STFileSet *fset); +void tsdbTFileSetRemove(STFileSet *fset); int32_t tsdbTFileSetFilteredInitDup(STsdb *pTsdb, const STFileSet *fset1, int64_t ever, STFileSet **fset, TFileOpArray *fopArr); diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index f14dc98658..a4965d49eb 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -204,7 +204,7 @@ static int32_t tsdbMergeFileSetBeginOpenReader(SMerger *merger) { TAOS_CHECK_GOTO(tsdbSttFileReaderOpen(fobj->fname, &config, &reader), &lino, _exit); if ((code = TARRAY2_APPEND(merger->sttReaderArr, reader))) { - (void)tsdbSttFileReaderClose(&reader); + tsdbSttFileReaderClose(&reader); TSDB_CHECK_CODE(code, lino, _exit); } } diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 1099218b73..3191ddb447 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -681,11 +681,7 @@ int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32 } void tLDataIterClose2(SLDataIter *pIter) { - int32_t code = tsdbSttFileReaderClose(&pIter->pReader); // always return 0 - if (code != 0) { - tsdbError("%" PRId64 " failed to close tsdb file reader, code:%s", pIter->cid, tstrerror(code)); - } - + tsdbSttFileReaderClose(&pIter->pReader); pIter->pReader = NULL; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c index 5e84c5ae25..d531179f97 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c @@ -355,7 +355,11 @@ static STsdbFSetPartList* tsdbSnapGetFSetPartList(STFileSystem* fs) { terrno = code; break; } - (void)TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn); + code = TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn); + if (code) { + terrno = code; + break; + } } (void)taosThreadMutexUnlock(&fs->tsdb->mutex); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 9dd3b371c6..6b9a959157 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -104,7 +104,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) { TSDB_CHECK_CODE(code, lino, _exit); if ((code = TARRAY2_APPEND(reader->sttReaderArr, sttReader))) { - TAOS_UNUSED(tsdbSttFileReaderClose(&sttReader)); + tsdbSttFileReaderClose(&sttReader); TSDB_CHECK_CODE(code, lino, _exit); } } @@ -449,7 +449,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** reader) { STsdb* tsdb = reader[0]->tsdb; - TAOS_UNUSED(tTombBlockDestroy(reader[0]->tombBlock)); + tTombBlockDestroy(reader[0]->tombBlock); tBlockDataDestroy(reader[0]->blockData); tsdbIterMergerClose(&reader[0]->dataIterMerger); diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index 2349d3adaf..3d9ea4ef69 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -93,12 +93,12 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(config->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); - (void)tsdbSttFileReaderClose(reader); + tsdbSttFileReaderClose(reader); } return code; } -int32_t tsdbSttFileReaderClose(SSttFileReader **reader) { +void tsdbSttFileReaderClose(SSttFileReader **reader) { if (reader[0]) { for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->local); ++i) { tBufferDestroy(reader[0]->local + i); @@ -110,7 +110,6 @@ int32_t tsdbSttFileReaderClose(SSttFileReader **reader) { taosMemoryFree(reader[0]); reader[0] = NULL; } - return 0; } // SSttFSegReader diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h index 1b0911617e..f0dc01b059 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.h @@ -40,7 +40,7 @@ typedef TARRAY2(SSttFileReader *) TSttFileReaderArray; // SSttFileReader int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *config, SSttFileReader **reader); -int32_t tsdbSttFileReaderClose(SSttFileReader **reader); +void tsdbSttFileReaderClose(SSttFileReader **reader); // SSttSegReader int32_t tsdbSttFileReadSttBlk(SSttFileReader *reader, const TSttBlkArray **sttBlkArray); @@ -71,10 +71,10 @@ int32_t tsdbSttFileWriteBlockData(SSttFileWriter *writer, SBlockData *pBlockData int32_t tsdbSttFileWriteTombRecord(SSttFileWriter *writer, const STombRecord *record); bool tsdbSttFileWriterIsOpened(SSttFileWriter *writer); -int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize, - int32_t encryptAlgorithm, char* encryptKey); -int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm, - char* encryptKey); +int32_t tsdbFileWriteSttBlk(STsdbFD *fd, const TSttBlkArray *sttBlkArray, SFDataPtr *ptr, int64_t *fileSize, + int32_t encryptAlgorithm, char *encryptKey); +int32_t tsdbFileWriteSttFooter(STsdbFD *fd, const SSttFooter *footer, int64_t *fileSize, int32_t encryptAlgorithm, + char *encryptKey); struct SSttFileWriterConfig { STsdb *tsdb; diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 26a998ce74..4d1e2b47f3 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -122,7 +122,7 @@ SVAsync *vnodeAsyncs[3]; #define MIN_ASYNC_ID 1 #define MAX_ASYNC_ID (sizeof(vnodeAsyncs) / sizeof(vnodeAsyncs[0]) - 1) -static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) { +static void vnodeAsyncTaskDone(SVAsync *async, SVATask *task) { int32_t ret; if (task->channel != NULL && task->channel->scheduled == task) { @@ -176,10 +176,9 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) { } else { (void)taosThreadCondBroadcast(&task->waitCond); } - return 0; } -static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) { +static void vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) { while (async->queue[0].next != &async->queue[0] || async->queue[1].next != &async->queue[1] || async->queue[2].next != &async->queue[2]) { for (int32_t i = 0; i < EVA_PRIORITY_MAX; i++) { @@ -193,11 +192,10 @@ static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) { .arg = task->arg, })); } - (void)vnodeAsyncTaskDone(async, task); + vnodeAsyncTaskDone(async, task); } } } - return 0; } static void *vnodeAsyncLoop(void *arg) { @@ -215,14 +213,14 @@ static void *vnodeAsyncLoop(void *arg) { // finish last running task if (worker->runningTask != NULL) { - (void)vnodeAsyncTaskDone(async, worker->runningTask); + vnodeAsyncTaskDone(async, worker->runningTask); worker->runningTask = NULL; } for (;;) { if (async->stop || worker->workerId >= async->numWorkers) { if (async->stop) { // cancel all tasks - (void)vnodeAsyncCancelAllTasks(async, cancelArray); + vnodeAsyncCancelAllTasks(async, cancelArray); } worker->state = EVA_WORKER_STATE_STOP; async->numLaunchWorkers--; @@ -269,7 +267,8 @@ static void *vnodeAsyncLoop(void *arg) { (void)taosThreadMutexUnlock(&async->mutex); // do run the task - (void)worker->runningTask->execute(worker->runningTask->arg); + int32_t code = worker->runningTask->execute(worker->runningTask->arg); + TAOS_UNUSED(code); } _exit: @@ -369,7 +368,7 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { } ret = vHashInit(&(*async)->taskTable, vnodeAsyncTaskHash, vnodeAsyncTaskCompare); if (ret != 0) { - (void)vHashDestroy(&(*async)->channelTable); + vHashDestroy(&(*async)->channelTable); (void)taosThreadMutexDestroy(&(*async)->mutex); (void)taosThreadCondDestroy(&(*async)->hasTask); taosMemoryFree(*async); @@ -418,29 +417,32 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) { (void)taosThreadMutexDestroy(&(*async)->mutex); (void)taosThreadCondDestroy(&(*async)->hasTask); - (void)vHashDestroy(&(*async)->channelTable); - (void)vHashDestroy(&(*async)->taskTable); + vHashDestroy(&(*async)->channelTable); + vHashDestroy(&(*async)->taskTable); taosMemoryFree(*async); *async = NULL; return 0; } -static int32_t vnodeAsyncLaunchWorker(SVAsync *async) { +static void vnodeAsyncLaunchWorker(SVAsync *async) { for (int32_t i = 0; i < async->numWorkers; i++) { if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) { continue; } else if (async->workers[i].state == EVA_WORKER_STATE_STOP) { - (void)taosThreadJoin(async->workers[i].thread, NULL); + TAOS_UNUSED(taosThreadJoin(async->workers[i].thread, NULL)); async->workers[i].state = EVA_WORKER_STATE_UINIT; } - (void)taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]); - async->workers[i].state = EVA_WORKER_STATE_ACTIVE; - async->numLaunchWorkers++; + int32_t ret = taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]); + if (ret) { + vError("failed to create worker thread since %s", tstrerror(ret)); + } else { + async->workers[i].state = EVA_WORKER_STATE_ACTIVE; + async->numLaunchWorkers++; + } break; } - return 0; } int32_t vnodeAsyncOpen(int32_t numOfThreads) { @@ -450,21 +452,25 @@ int32_t vnodeAsyncOpen(int32_t numOfThreads) { // vnode-commit code = vnodeAsyncInit(&vnodeAsyncs[1], "vnode-commit"); TSDB_CHECK_CODE(code, lino, _exit); - (void)vnodeAsyncSetWorkers(1, numOfThreads); + + code = vnodeAsyncSetWorkers(1, numOfThreads); + TSDB_CHECK_CODE(code, lino, _exit); // vnode-merge code = vnodeAsyncInit(&vnodeAsyncs[2], "vnode-merge"); TSDB_CHECK_CODE(code, lino, _exit); - (void)vnodeAsyncSetWorkers(2, numOfThreads); + + code = vnodeAsyncSetWorkers(2, numOfThreads); + TSDB_CHECK_CODE(code, lino, _exit); _exit: return code; } -int32_t vnodeAsyncClose() { - (void)vnodeAsyncDestroy(&vnodeAsyncs[1]); - (void)vnodeAsyncDestroy(&vnodeAsyncs[2]); - return 0; +void vnodeAsyncClose() { + int32_t ret; + ret = vnodeAsyncDestroy(&vnodeAsyncs[1]); + ret = vnodeAsyncDestroy(&vnodeAsyncs[2]); } int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*execute)(void *), void (*cancel)(void *), @@ -474,6 +480,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec return TSDB_CODE_INVALID_PARA; } + int32_t ret; int64_t id; SVAsync *async = vnodeAsyncs[channelID->async]; @@ -501,7 +508,8 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec SVAChannel channel = { .channelId = channelID->id, }; - (void)vHashGet(async->channelTable, &channel, (void **)&task->channel); + ret = vHashGet(async->channelTable, &channel, (void **)&task->channel); + TAOS_UNUSED(ret); if (task->channel == NULL) { (void)taosThreadMutexUnlock(&async->mutex); (void)taosThreadCondDestroy(&task->waitCond); @@ -513,7 +521,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec task->taskId = id = ++async->nextTaskId; // add task to hash table - int32_t ret = vHashPut(async->taskTable, task); + ret = vHashPut(async->taskTable, task); if (ret != 0) { (void)taosThreadMutexUnlock(&async->mutex); (void)taosThreadCondDestroy(&task->waitCond); @@ -539,7 +547,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec if (async->numIdleWorkers > 0) { (void)taosThreadCondSignal(&(async->hasTask)); } else if (async->numLaunchWorkers < async->numWorkers) { - (void)vnodeAsyncLaunchWorker(async); + vnodeAsyncLaunchWorker(async); } } else if (task->channel->scheduled->state == EVA_TASK_STATE_RUNNING || priority >= VATASK_PIORITY(task->channel->scheduled)) { @@ -579,11 +587,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec return 0; } -int32_t vnodeAWait(SVATaskID *taskID) { - if (taskID == NULL || taskID->async < MIN_ASYNC_ID || taskID->async > MAX_ASYNC_ID || taskID->id <= 0) { - return TSDB_CODE_INVALID_PARA; - } - +void vnodeAWait(SVATaskID *taskID) { SVAsync *async = vnodeAsyncs[taskID->async]; SVATask *task = NULL; SVATask task2 = { @@ -592,7 +596,7 @@ int32_t vnodeAWait(SVATaskID *taskID) { (void)taosThreadMutexLock(&async->mutex); - (void)vHashGet(async->taskTable, &task2, (void **)&task); + int32_t ret = vHashGet(async->taskTable, &task2, (void **)&task); if (task) { task->numWait++; (void)taosThreadCondWait(&task->waitCond, &async->mutex); @@ -605,8 +609,6 @@ int32_t vnodeAWait(SVATaskID *taskID) { } (void)taosThreadMutexUnlock(&async->mutex); - - return 0; } int32_t vnodeACancel(SVATaskID *taskID) { @@ -625,14 +627,14 @@ int32_t vnodeACancel(SVATaskID *taskID) { (void)taosThreadMutexLock(&async->mutex); - (void)vHashGet(async->taskTable, &task2, (void **)&task); + ret = vHashGet(async->taskTable, &task2, (void **)&task); if (task) { if (task->state == EVA_TASK_STATE_WAITTING) { cancel = task->cancel; arg = task->arg; task->next->prev = task->prev; task->prev->next = task->next; - (void)vnodeAsyncTaskDone(async, task); + vnodeAsyncTaskDone(async, task); } else { ret = TSDB_CODE_FAILED; } @@ -651,6 +653,7 @@ int32_t vnodeAsyncSetWorkers(int64_t asyncID, int32_t numWorkers) { if (asyncID < MIN_ASYNC_ID || asyncID > MAX_ASYNC_ID || numWorkers <= 0 || numWorkers > VNODE_ASYNC_MAX_WORKERS) { return TSDB_CODE_INVALID_PARA; } + int32_t ret; SVAsync *async = vnodeAsyncs[asyncID]; (void)taosThreadMutexLock(&async->mutex); async->numWorkers = numWorkers; @@ -725,12 +728,13 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { (void)taosThreadMutexLock(&async->mutex); - (void)vHashGet(async->channelTable, &channel2, (void **)&channel); + int32_t ret = vHashGet(async->channelTable, &channel2, (void **)&channel); + TAOS_UNUSED(ret); if (channel) { // unregister channel channel->next->prev = channel->prev; channel->prev->next = channel->next; - (void)vHashDrop(async->channelTable, channel); + ret = vHashDrop(async->channelTable, channel); async->numChannels--; // cancel all waiting tasks @@ -745,7 +749,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { .arg = task->arg, })); } - (void)vnodeAsyncTaskDone(async, task); + vnodeAsyncTaskDone(async, task); } } @@ -760,7 +764,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { .arg = channel->scheduled->arg, })); } - (void)vnodeAsyncTaskDone(async, channel->scheduled); + vnodeAsyncTaskDone(async, channel->scheduled); } taosMemoryFree(channel); } else { diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c index 35b3a87e00..eec4429403 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c @@ -58,7 +58,7 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu return 0; } -static int vnodeBufPoolDestroy(SVBufPool *pPool) { +static void vnodeBufPoolDestroy(SVBufPool *pPool) { vnodeBufPoolReset(pPool); if (pPool->lock) { (void)taosThreadSpinDestroy(pPool->lock); @@ -66,7 +66,6 @@ static int vnodeBufPoolDestroy(SVBufPool *pPool) { } (void)taosThreadMutexDestroy(&pPool->mutex); taosMemoryFree(pPool); - return 0; } int vnodeOpenBufPool(SVnode *pVnode) { @@ -77,7 +76,7 @@ int vnodeOpenBufPool(SVnode *pVnode) { int32_t code; if ((code = vnodeBufPoolCreate(pVnode, i, size, &pVnode->aBufPool[i]))) { vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno)); - (void)vnodeCloseBufPool(pVnode); + vnodeCloseBufPool(pVnode); return code; } @@ -90,16 +89,15 @@ int vnodeOpenBufPool(SVnode *pVnode) { return 0; } -int vnodeCloseBufPool(SVnode *pVnode) { +void vnodeCloseBufPool(SVnode *pVnode) { for (int32_t i = 0; i < VNODE_BUFPOOL_SEGMENTS; i++) { if (pVnode->aBufPool[i]) { - (void)vnodeBufPoolDestroy(pVnode->aBufPool[i]); + vnodeBufPoolDestroy(pVnode->aBufPool[i]); pVnode->aBufPool[i] = NULL; } } vDebug("vgId:%d, vnode buffer pool is closed", TD_VID(pVnode)); - return 0; } void vnodeBufPoolReset(SVBufPool *pPool) { @@ -234,7 +232,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) { vInfo("vgId:%d, buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id, pPool->node.size, size); - (void)vnodeBufPoolDestroy(pPool); + vnodeBufPoolDestroy(pPool); pPool = pNewPool; pVnode->aBufPool[pPool->id] = pPool; } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index d90badc34c..969b9b9363 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -351,7 +351,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (info == NULL) return -1; tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code); if (code) return code; - (void)tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); + code = tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code); if (code) return code; tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index d433498590..3564d90752 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -272,7 +272,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { int64_t lastCommitted = pInfo->info.state.committed; // wait last commit task - (void)vnodeAWait(&pVnode->commitTask); + vnodeAWait(&pVnode->commitTask); code = syncNodeGetConfig(pVnode->sync, &pVnode->config.syncCfg); TSDB_CHECK_CODE(code, lino, _exit); @@ -293,7 +293,8 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { code = vnodeSaveInfo(dir, &pInfo->info); TSDB_CHECK_CODE(code, lino, _exit); - (void)tsdbPreCommit(pVnode->pTsdb); + code = tsdbPreCommit(pVnode->pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); code = metaPrepareAsyncCommit(pVnode->pMeta); TSDB_CHECK_CODE(code, lino, _exit); @@ -395,10 +396,15 @@ _exit: return code; } -int vnodeSyncCommit(SVnode *pVnode) { - (void)vnodeAsyncCommit(pVnode); - (void)vnodeAWait(&pVnode->commitTask); - return 0; +int32_t vnodeSyncCommit(SVnode *pVnode) { + int32_t lino; + int32_t code = vnodeAsyncCommit(pVnode); + TSDB_CHECK_CODE(code, lino, _exit); + vnodeAWait(&pVnode->commitTask); + +_exit: + vError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code)); + return code; } static int vnodeCommitImpl(SCommitInfo *pInfo) { @@ -419,7 +425,8 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); - (void)syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed); + code = syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed); + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbCommitBegin(pVnode->pTsdb, pInfo); TSDB_CHECK_CODE(code, lino, _exit); @@ -456,7 +463,8 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { return -1; } - (void)syncEndSnapshot(pVnode->sync); + code = syncEndSnapshot(pVnode->sync); + TSDB_CHECK_CODE(code, lino, _exit); _exit: if (code) { diff --git a/source/dnode/vnode/src/vnd/vnodeHash.c b/source/dnode/vnode/src/vnd/vnodeHash.c index 1aab0e4783..c2b37c56a6 100644 --- a/source/dnode/vnode/src/vnd/vnodeHash.c +++ b/source/dnode/vnode/src/vnd/vnodeHash.c @@ -71,9 +71,9 @@ int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*com return 0; } -int32_t vHashDestroy(SVHashTable** ht) { +void vHashDestroy(SVHashTable** ht) { if (ht == NULL) { - return TSDB_CODE_INVALID_PARA; + return; } if (*ht) { @@ -81,7 +81,6 @@ int32_t vHashDestroy(SVHashTable** ht) { taosMemoryFree(*ht); (*ht) = NULL; } - return 0; } int32_t vHashPut(SVHashTable* ht, void* obj) { diff --git a/source/dnode/vnode/src/vnd/vnodeModule.c b/source/dnode/vnode/src/vnd/vnodeModule.c index 2a2d01ada8..781736edba 100644 --- a/source/dnode/vnode/src/vnd/vnodeModule.c +++ b/source/dnode/vnode/src/vnd/vnodeModule.c @@ -34,7 +34,7 @@ int vnodeInit(int nthreads, StopDnodeFp stopDnodeFp) { void vnodeCleanup() { if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return; - (void)vnodeAsyncClose(); + vnodeAsyncClose(); walCleanUp(); smaCleanUp(); } diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index bdc866500c..1f54fea27c 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -502,7 +502,7 @@ _err: if (pVnode->pTsdb) (void)tsdbClose(&pVnode->pTsdb); if (pVnode->pSma) (void)smaClose(pVnode->pSma); if (pVnode->pMeta) (void)metaClose(&pVnode->pMeta); - if (pVnode->freeList) (void)vnodeCloseBufPool(pVnode); + if (pVnode->freeList) vnodeCloseBufPool(pVnode); taosMemoryFree(pVnode); return NULL; @@ -517,7 +517,7 @@ void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); } void vnodeClose(SVnode *pVnode) { if (pVnode) { - (void)vnodeAWait(&pVnode->commitTask); + vnodeAWait(&pVnode->commitTask); (void)vnodeAChannelDestroy(&pVnode->commitChannel, true); vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); @@ -526,7 +526,7 @@ void vnodeClose(SVnode *pVnode) { if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); (void)smaClose(pVnode->pSma); if (pVnode->pMeta) metaClose(&pVnode->pMeta); - (void)vnodeCloseBufPool(pVnode); + vnodeCloseBufPool(pVnode); // destroy handle (void)tsem_destroy(&pVnode->syncSem); diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index fb0d0d5277..2a4c83c9ee 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -586,7 +586,7 @@ _exit: } extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb); -extern int32_t tsdbEnableBgTask(STsdb *pTsdb); +extern void tsdbEnableBgTask(STsdb *pTsdb); static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) { (void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); @@ -596,7 +596,7 @@ static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) { } static int32_t vnodeEnableBgTask(SVnode *pVnode) { - (void)tsdbEnableBgTask(pVnode->pTsdb); + tsdbEnableBgTask(pVnode->pTsdb); (void)vnodeAChannelInit(1, &pVnode->commitChannel); return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 1d8b48bf01..2604e2262f 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -2041,7 +2041,7 @@ _exit: } extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb); -extern int32_t tsdbEnableBgTask(STsdb *pTsdb); +extern void tsdbEnableBgTask(STsdb *pTsdb); static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) { bool walChanged = false; @@ -2143,10 +2143,10 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe if (req.sttTrigger > 1 && pVnode->config.sttTrigger > 1) { pVnode->config.sttTrigger = req.sttTrigger; } else { - (void)vnodeAWait(&pVnode->commitTask); + vnodeAWait(&pVnode->commitTask); (void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); pVnode->config.sttTrigger = req.sttTrigger; - (void)tsdbEnableBgTask(pVnode->pTsdb); + tsdbEnableBgTask(pVnode->pTsdb); } } From bb785ce53e01e2db0d0d549a531aed446620f50c Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Tue, 10 Sep 2024 14:47:42 +0800 Subject: [PATCH 14/32] fix(query):set scan flag info --- source/libs/executor/src/timewindowoperator.c | 4 ++-- source/libs/parser/src/parTranslater.c | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 59883d2b80..93b3759c47 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1082,7 +1082,7 @@ static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) { } pInfo->binfo.pRes->info.scanFlag = pBlock->info.scanFlag; - code = setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true); + code = setInputDataBlock(pSup, pBlock, order, pBlock->info.scanFlag, true); QUERY_CHECK_CODE(code, lino, _end); code = blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId); @@ -1567,7 +1567,7 @@ static int32_t doSessionWindowAggNext(SOperatorInfo* pOperator, SSDataBlock** pp QUERY_CHECK_CODE(code, lino, _end); } // the pDataBlock are always the same one, no need to call this again - code = setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true); + code = setInputDataBlock(pSup, pBlock, order, pBlock->info.scanFlag, true); QUERY_CHECK_CODE(code, lino, _end); code = blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 62943cb6d5..85c8491aa1 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2559,6 +2559,13 @@ static int32_t translateRepeatScanFunc(STranslateContext* pCxt, SFunctionNode* p return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s function is not supported in partition query", pFunc->functionName); } + + if (NULL != pSelect->pWindow) { + if (QUERY_NODE_EVENT_WINDOW == nodeType(pSelect->pWindow) || QUERY_NODE_COUNT_WINDOW == nodeType(pSelect->pWindow)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, + "%s function is not supported in count/event window", pFunc->functionName); + } + } return TSDB_CODE_SUCCESS; } From 08be2b98bc02bc8682a2d47b48e5766266c7939c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 10 Sep 2024 15:20:09 +0800 Subject: [PATCH 15/32] fix: coredump --- source/dnode/vnode/src/vnd/vnodeAsync.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 4d1e2b47f3..56968fd60e 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -588,6 +588,10 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec } void vnodeAWait(SVATaskID *taskID) { + if (taskID == NULL || taskID->async < MIN_ASYNC_ID || taskID->async > MAX_ASYNC_ID || taskID->id <= 0) { + return; + } + SVAsync *async = vnodeAsyncs[taskID->async]; SVATask *task = NULL; SVATask task2 = { From 529af8d20b4a738bc70189eac52fcfcf5bb6774c Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 10 Sep 2024 16:48:16 +0800 Subject: [PATCH 16/32] fix(tsdb/cache): comment mem's early ts block --- source/dnode/vnode/src/tsdb/tsdbCache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 2b76e8841d..d19a3b034d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -2691,12 +2691,14 @@ static int32_t getNextRowFromMem(void *iter, TSDBROW **ppRow, bool *pIgnoreEarli switch (state->state) { case SMEMNEXTROW_ENTER: { if (state->pMem != NULL) { + /* if (state->pMem->maxKey <= state->lastTs) { *ppRow = NULL; *pIgnoreEarlierTs = true; TAOS_RETURN(code); } + */ tsdbTbDataIterOpen(state->pMem, NULL, 1, &state->iter); TSDBROW *pMemRow = tsdbTbDataIterGet(&state->iter); From dc983b9a39a3b317d40caf12870b37fa59b6020c Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 10 Sep 2024 16:56:36 +0800 Subject: [PATCH 17/32] fix: add block data check --- include/common/tdatablock.h | 2 +- source/common/src/tdatablock.c | 13 +++++++++---- source/libs/executor/src/dynqueryctrloperator.c | 1 + source/libs/executor/src/executor.c | 5 +++++ source/libs/executor/src/executorInt.c | 2 ++ source/libs/executor/src/groupcacheoperator.c | 2 ++ source/libs/executor/src/mergejoinoperator.c | 8 ++++++-- source/libs/executor/src/mergeoperator.c | 2 ++ source/libs/executor/src/operator.c | 4 ++-- source/libs/executor/src/sortoperator.c | 5 ++++- 10 files changed, 34 insertions(+), 10 deletions(-) diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 1d280b5d6b..cbfd1efb84 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -233,7 +233,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo); * @brief find how many rows already in order start from first row */ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo); -void blockDataCheck(const SSDataBlock* pDataBlock); +void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk); int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload); int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 840434a351..6e4162268d 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -731,6 +731,10 @@ int32_t blockDataMergeNRows(SSDataBlock* pDest, const SSDataBlock* pSrc, int32_t } void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows) { + if (numOfRows == 0) { + return; + } + if (numOfRows >= pBlock->info.rows) { blockDataCleanup(pBlock); return; @@ -2936,7 +2940,7 @@ int32_t buildCtbNameByGroupIdImpl(const char* stbFullName, uint64_t groupId, cha // return length of encoded data, return -1 if failed int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) { - blockDataCheck(pBlock); + blockDataCheck(pBlock, false); int32_t dataLen = 0; @@ -3180,7 +3184,7 @@ int32_t blockDecode(SSDataBlock* pBlock, const char* pData, const char** pEndPos *pEndPos = pStart; - blockDataCheck(pBlock); + blockDataCheck(pBlock, false); return code; } @@ -3392,14 +3396,14 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) { return nextRowIdx; } -void blockDataCheck(const SSDataBlock* pDataBlock) { +void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) { if (NULL == pDataBlock || pDataBlock->info.rows == 0) { return; } ASSERT(pDataBlock->info.rows > 0); - if (!pDataBlock->info.dataLoad) { + if (!pDataBlock->info.dataLoad && !forceChk) { return; } @@ -3457,3 +3461,4 @@ void blockDataCheck(const SSDataBlock* pDataBlock) { return; } + diff --git a/source/libs/executor/src/dynqueryctrloperator.c b/source/libs/executor/src/dynqueryctrloperator.c index 44e8a3cb8a..aa0cc215df 100644 --- a/source/libs/executor/src/dynqueryctrloperator.c +++ b/source/libs/executor/src/dynqueryctrloperator.c @@ -528,6 +528,7 @@ static void seqJoinLaunchNewRetrieveImpl(SOperatorInfo* pOperator, SSDataBlock** qDebug("%s dynamic post task begin", GET_TASKID(pOperator->pTaskInfo)); code = pOperator->pDownstream[1]->fpSet.getNextExtFn(pOperator->pDownstream[1], pParam, ppRes); if (*ppRes && (code == 0)) { + blockDataCheck(*ppRes, false); pPost->isStarted = true; pStbJoin->execInfo.postBlkNum++; pStbJoin->execInfo.postBlkRows += (*ppRes)->info.rows; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 9e33a3d890..cca1895a85 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -692,8 +692,10 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo if (pTaskInfo->pOpParam && !pTaskInfo->paramSet) { pTaskInfo->paramSet = true; code = pTaskInfo->pRoot->fpSet.getNextExtFn(pTaskInfo->pRoot, pTaskInfo->pOpParam, &pRes); + blockDataCheck(pRes, false); } else { code = pTaskInfo->pRoot->fpSet.getNextFn(pTaskInfo->pRoot, &pRes); + blockDataCheck(pRes, false); } QUERY_CHECK_CODE(code, lino, _end); @@ -740,6 +742,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo } code = pTaskInfo->pRoot->fpSet.getNextFn(pTaskInfo->pRoot, &pRes); + blockDataCheck(pRes, false); QUERY_CHECK_CODE(code, lino, _end); } @@ -839,6 +842,8 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds) { qError("%s failed at line %d, code:%s %s", __func__, lino, tstrerror(code), GET_TASKID(pTaskInfo)); } + blockDataCheck(*pRes, false); + uint64_t el = (taosGetTimestampUs() - st); pTaskInfo->cost.elapsedTime += el; diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index 00138d6871..c8ec1e8fcc 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -617,6 +617,8 @@ int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* p code = TSDB_CODE_SUCCESS; _err: + blockDataCheck(pBlock, true); + colDataDestroy(p); taosMemoryFree(p); return code; diff --git a/source/libs/executor/src/groupcacheoperator.c b/source/libs/executor/src/groupcacheoperator.c index 1796aa7b64..990c9322b7 100644 --- a/source/libs/executor/src/groupcacheoperator.c +++ b/source/libs/executor/src/groupcacheoperator.c @@ -733,6 +733,8 @@ static FORCE_INLINE int32_t getBlkFromDownstreamOperator(struct SOperatorInfo* p } } + blockDataCheck(pBlock, false); + *ppRes = pBlock; return code; } diff --git a/source/libs/executor/src/mergejoinoperator.c b/source/libs/executor/src/mergejoinoperator.c index 90c2248c12..c29c49e280 100644 --- a/source/libs/executor/src/mergejoinoperator.c +++ b/source/libs/executor/src/mergejoinoperator.c @@ -474,8 +474,11 @@ int32_t mJoinCopyMergeMidBlk(SMJoinMergeCtx* pCtx, SSDataBlock** ppMid, SSDataBl pCtx->midRemains = false; } else { int32_t copyRows = pMore->info.capacity - pMore->info.rows; - MJ_ERR_RET(blockDataMergeNRows(pMore, pLess, pLess->info.rows - copyRows, copyRows)); - blockDataShrinkNRows(pLess, copyRows); + if (copyRows > 0) { + MJ_ERR_RET(blockDataMergeNRows(pMore, pLess, pLess->info.rows - copyRows, copyRows)); + blockDataShrinkNRows(pLess, copyRows); + } + pCtx->midRemains = true; } @@ -1742,6 +1745,7 @@ int32_t mJoinMainProcess(struct SOperatorInfo* pOperator, SSDataBlock** pResBloc if (pBlock && pBlock->info.rows > 0) { *pResBlock = pBlock; } + return code; } diff --git a/source/libs/executor/src/mergeoperator.c b/source/libs/executor/src/mergeoperator.c index 7357329ca6..c94a330dbc 100644 --- a/source/libs/executor/src/mergeoperator.c +++ b/source/libs/executor/src/mergeoperator.c @@ -66,6 +66,7 @@ static int32_t sortMergeloadNextDataBlock(void* param, SSDataBlock** ppBlock); int32_t sortMergeloadNextDataBlock(void* param, SSDataBlock** ppBlock) { SOperatorInfo* pOperator = (SOperatorInfo*)param; int32_t code = pOperator->fpSet.getNextFn(pOperator, ppBlock); + blockDataCheck(*ppBlock, false); return code; } @@ -524,6 +525,7 @@ int32_t doMultiwayMerge(SOperatorInfo* pOperator, SSDataBlock** pResBlock) { if ((*pResBlock) != NULL) { pOperator->resultInfo.totalRows += (*pResBlock)->info.rows; + blockDataCheck(*pResBlock, false); } else { setOperatorCompleted(pOperator); } diff --git a/source/libs/executor/src/operator.c b/source/libs/executor/src/operator.c index de478a146f..cb1149d8a3 100644 --- a/source/libs/executor/src/operator.c +++ b/source/libs/executor/src/operator.c @@ -868,14 +868,14 @@ int32_t setOperatorParams(struct SOperatorInfo* pOperator, SOperatorParam* pInpu SSDataBlock* getNextBlockFromDownstream(struct SOperatorInfo* pOperator, int32_t idx) { SSDataBlock* p = NULL; int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, true, &p); - blockDataCheck(p); + blockDataCheck(p, false); return (code == 0)? p:NULL; } SSDataBlock* getNextBlockFromDownstreamRemain(struct SOperatorInfo* pOperator, int32_t idx) { SSDataBlock* p = NULL; int32_t code = getNextBlockFromDownstreamImpl(pOperator, idx, false, &p); - blockDataCheck(p); + blockDataCheck(p, false); return (code == 0)? p:NULL; } diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 9b659ac761..27ae5e7281 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -328,7 +328,9 @@ static int32_t getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t loadNextDataBlock(void* param, SSDataBlock** ppBlock) { SOperatorInfo* pOperator = (SOperatorInfo*)param; - return pOperator->fpSet.getNextFn(pOperator, ppBlock); + int32_t code = pOperator->fpSet.getNextFn(pOperator, ppBlock); + blockDataCheck(*ppBlock, false); + return code; } // todo refactor: merged with fetch fp @@ -611,6 +613,7 @@ int32_t fetchNextGroupSortDataBlock(void* param, SSDataBlock** ppBlock) { QUERY_CHECK_CODE(code, lino, _end); if (block != NULL) { + blockDataCheck(block, false); if (block->info.id.groupId == grpSortOpInfo->currGroupId) { grpSortOpInfo->childOpStatus = CHILD_OP_SAME_GROUP; *ppBlock = block; From da990aa91d0fff22dc06f14214dbcddd9fa1f06e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 10 Sep 2024 17:20:32 +0800 Subject: [PATCH 18/32] fix(stream): fix syntax error. --- source/dnode/mnode/impl/src/mndStream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index ade8d541de..0c57f8466d 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -903,7 +903,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { _OVER: if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) { - mError("stream:%s, failed to create at line:%d since %s", createReq.name, lino, terrstr(code)); + mError("stream:%s, failed to create at line:%d since %s", createReq.name, lino, tstrerror(code)); } else { mDebug("stream:%s create stream completed", createReq.name); code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -1121,7 +1121,7 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre code = mndTransPrepare(pMnode, pTrans); if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) { - mError("failed to prepare checkpoint trans since %s", terrstr(code)); + mError("failed to prepare checkpoint trans since %s", tstrerror(code)); } else { code = TSDB_CODE_ACTION_IN_PROGRESS; } From 37355b8ae110026d6b05b56aa59cb847296bd300 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 10 Sep 2024 17:49:12 +0800 Subject: [PATCH 19/32] fix(test): update test cases. --- tests/script/tsim/stream/sliding.sim | 2 +- tests/system-test/1-insert/database_pre_suf.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/script/tsim/stream/sliding.sim b/tests/script/tsim/stream/sliding.sim index acf68e0286..b0f347fd14 100644 --- a/tests/script/tsim/stream/sliding.sim +++ b/tests/script/tsim/stream/sliding.sim @@ -608,7 +608,7 @@ $loop_count = 0 print step 7 loop4: -sleep 100 +sleep 1000 $loop_count = $loop_count + 1 if $loop_count == 10 then diff --git a/tests/system-test/1-insert/database_pre_suf.py b/tests/system-test/1-insert/database_pre_suf.py index 2bef94081e..29a6e27525 100755 --- a/tests/system-test/1-insert/database_pre_suf.py +++ b/tests/system-test/1-insert/database_pre_suf.py @@ -283,7 +283,8 @@ class TDTestCase: fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) - + + time.sleep(1) tdSql.query("select count(*) from stable_1;") tdSql.checkData(0,0,10*num_random*n) tdSql.query("select count(*) from hn_table_1_r;") @@ -291,6 +292,10 @@ class TDTestCase: # stream data check tdCom.check_stream_task_status(stream_name,vgroups,90) + print("sleep 30s") + time.sleep(30) + + print("check--------------------------------------------------------------------------") tdSql.query("select startts,wend,max_int from stream_max_stable_1 ;") tdSql.checkRows(20) tdSql.query("select sum(max_int) from stream_max_stable_1 ;") From 135f23c8b965e751024b7d8da00a3ecffe18e6f0 Mon Sep 17 00:00:00 2001 From: Jing Sima Date: Tue, 10 Sep 2024 16:29:19 +0800 Subject: [PATCH 20/32] fix:[TD-32000] fix indirect leak caused by using wrong array destroy function. --- source/libs/scalar/src/filter.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index ec48dd50ae..bb3133ea33 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1729,11 +1729,9 @@ EDealRes fltTreeToGroup(SNode *pNode, void *pContext) { return DEAL_RES_IGNORE_CHILD; } - ctx->code = TSDB_CODE_APP_ERROR; - fltError("invalid condition type, type:%d", node->condType); - return DEAL_RES_ERROR; + FLT_ERR_JRET(TSDB_CODE_APP_ERROR); } if (QUERY_NODE_OPERATOR == nType) { From 01bae36e82d59452978487700e463d5155a86428 Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Tue, 10 Sep 2024 18:42:00 +0800 Subject: [PATCH 21/32] enh:modify error code passing in libs/ --- source/libs/geometry/src/geomFunc.c | 8 ++-- source/libs/geometry/src/geosWrapper.c | 2 +- source/libs/index/src/index.c | 2 +- source/libs/index/src/indexCache.c | 8 ++-- source/libs/index/src/indexComm.c | 24 ++++++------ source/libs/index/src/indexFilter.c | 8 ++-- source/libs/index/src/indexTfile.c | 8 ++-- source/libs/index/src/indexUtil.c | 2 +- source/libs/nodes/src/nodesCloneFuncs.c | 4 +- source/libs/nodes/src/nodesCodeFuncs.c | 8 ++-- source/libs/nodes/src/nodesMsgFuncs.c | 2 +- source/libs/nodes/src/nodesUtilFuncs.c | 6 +-- source/libs/parser/src/parInsertSml.c | 14 +++---- source/libs/parser/src/parInsertSql.c | 10 ++--- source/libs/parser/src/parInsertStmt.c | 20 +++++----- source/libs/parser/src/parInsertUtil.c | 14 +++---- source/libs/parser/src/parTranslater.c | 50 ++++++++++++------------- source/libs/parser/src/parUtil.c | 4 +- source/libs/parser/src/parser.c | 12 +++--- 19 files changed, 103 insertions(+), 103 deletions(-) diff --git a/source/libs/geometry/src/geomFunc.c b/source/libs/geometry/src/geomFunc.c index 1752493dff..2ce2d92fa7 100644 --- a/source/libs/geometry/src/geomFunc.c +++ b/source/libs/geometry/src/geomFunc.c @@ -43,7 +43,7 @@ int32_t doMakePointFunc(double x, double y, unsigned char **output) { *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } @@ -74,7 +74,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) { // make a zero ending string inputGeom = taosMemoryCalloc(1, varDataLen(input) + 1); if (inputGeom == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } (void)memcpy(inputGeom, varDataVal(input), varDataLen(input)); @@ -83,7 +83,7 @@ int32_t doGeomFromTextFunc(const char *input, unsigned char **output) { *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } @@ -114,7 +114,7 @@ int32_t doAsTextFunc(unsigned char *input, char **output) { size_t size = strlen(outputWKT); *output = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); if (*output == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exit; } diff --git a/source/libs/geometry/src/geosWrapper.c b/source/libs/geometry/src/geosWrapper.c index 5eeea54715..13c5f7208e 100644 --- a/source/libs/geometry/src/geosWrapper.c +++ b/source/libs/geometry/src/geosWrapper.c @@ -96,7 +96,7 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData int32_t code = 0; char *wktPatternWithSpace = taosMemoryCalloc(4, 1024); if (NULL == wktPatternWithSpace) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)sprintf( diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 0d834a68cb..b2fd0afd68 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -112,7 +112,7 @@ int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { int code = TSDB_CODE_SUCCESS; SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex)); if (idx == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, END); + TAOS_CHECK_GOTO(terrno, NULL, END); } idx->lru = taosLRUCacheInit(opts->cacheSize, -1, .5); diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index a89cc47925..1b31c1e50b 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -137,7 +137,7 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt* CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); if (pCt == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pCt->colVal = term->colVal; @@ -206,7 +206,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); if (pCt == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pCt->colVal = term->colVal; @@ -584,7 +584,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // encode data CacheTerm* ct = taosMemoryCalloc(1, sizeof(CacheTerm)); if (ct == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } // set up key ct->colType = term->colType; @@ -594,7 +594,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { ct->colVal = (char*)taosMemoryCalloc(1, sizeof(char) * (term->nColVal + 1)); if (ct->colVal == NULL) { taosMemoryFree(ct); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(ct->colVal, term->colVal, term->nColVal); } diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 8dc63ed105..2c681a1df3 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -323,7 +323,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_TIMESTAMP: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int64_t*)src, *dst, -1); tlen = strlen(*dst); @@ -332,7 +332,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UTINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint8_t*)src, *dst, 1); tlen = strlen(*dst); @@ -340,7 +340,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_TINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int8_t*)src, *dst, 1); tlen = strlen(*dst); @@ -348,7 +348,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_SMALLINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int16_t*)src, *dst, -1); tlen = strlen(*dst); @@ -361,7 +361,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_INT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(int32_t*)src, *dst, -1); tlen = strlen(*dst); @@ -369,7 +369,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint32_t*)src, *dst, 1); tlen = strlen(*dst); @@ -377,7 +377,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_BIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%" PRIu64, *(uint64_t*)src); tlen = strlen(*dst); @@ -385,7 +385,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_UBIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)idxInt2str(*(uint64_t*)src, *dst, 1); tlen = strlen(*dst); @@ -393,7 +393,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_FLOAT: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%.9lf", *(float*)src); tlen = strlen(*dst); @@ -401,7 +401,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_DOUBLE: *dst = taosMemoryCalloc(1, bufSize + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(*dst, "%.9lf", *(double*)src); tlen = strlen(*dst); @@ -410,7 +410,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; @@ -422,7 +422,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); if (*dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 03474c0143..fa59fe23fe 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -197,7 +197,7 @@ static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) { } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(tv, pData, valLen); @@ -273,7 +273,7 @@ static int32_t sifInitParamValByCol(SNode *r, SNode *l, SIFParam *param, SIFCtx } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(tv, pData, valLen); @@ -373,7 +373,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam)); if (NULL == paramList) { - SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SIF_ERR_RET(terrno); } if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR && @@ -405,7 +405,7 @@ static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx * SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam)); if (tParams == NULL) { indexError("failed to calloc, nodeList: %p", nodeList); - SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SIF_ERR_RET(terrno); } SListCell *cell = nodeList->pHead; diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index 55a9bb06d9..405e899100 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -201,7 +201,7 @@ int32_t tfileReaderCreate(IFileCtx* ctx, TFileReader** pReader) { int32_t code = 0; TFileReader* reader = taosMemoryCalloc(1, sizeof(TFileReader)); if (reader == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } reader->ctx = ctx; reader->remove = false; @@ -609,7 +609,7 @@ int32_t tfileWriterCreate(IFileCtx* ctx, TFileHeader* header, TFileWriter** pWri int32_t code = 0; TFileWriter* tw = taosMemoryCalloc(1, sizeof(TFileWriter)); if (tw == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; indexError("index: %" PRIu64 " failed to alloc TFilerWriter since %s", header->suid, tstrerror(code)); return code; } @@ -661,7 +661,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { int32_t cap = 4 * 1024; char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (size_t i = 0; i < sz; i++) { @@ -1137,7 +1137,7 @@ static int32_t tfileGetFileList(const char* path, SArray** ppResult) { size_t len = strlen(path) + 1 + strlen(file) + 1; char* buf = taosMemoryCalloc(1, len); if (buf == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception); + TAOS_CHECK_GOTO(terrno, NULL, _exception); } sprintf(buf, "%s/%s", path, file); diff --git a/source/libs/index/src/indexUtil.c b/source/libs/index/src/indexUtil.c index 6a52b7b5a4..aca1ec37fe 100644 --- a/source/libs/index/src/indexUtil.c +++ b/source/libs/index/src/indexUtil.c @@ -44,7 +44,7 @@ int32_t iIntersection(SArray *in, SArray *out) { } MergeIndex *mi = taosMemoryCalloc(sz, sizeof(MergeIndex)); if (mi == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (int i = 0; i < sz; i++) { SArray *t = taosArrayGetP(in, i); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index e2c5b42e39..b76e4448d3 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -179,7 +179,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = pSrc->node.resType.bytes + 1; pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; @@ -188,7 +188,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { int32_t len = getJsonValueLen(pSrc->datum.p); pDst->datum.p = taosMemoryCalloc(1, len); if (NULL == pDst->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pDst->datum.p, pSrc->datum.p, len); break; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 1425df5c5a..74879a53af 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -4083,14 +4083,14 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_GEOMETRY: { pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } varDataSetLen(pNode->datum.p, pNode->node.resType.bytes - VARSTR_HEADER_SIZE); if (TSDB_DATA_TYPE_NCHAR == pNode->node.resType.type) { char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + VARSTR_HEADER_SIZE + 1); if (NULL == buf) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tjsonGetStringValue(pJson, jkValueDatum, buf); @@ -4112,12 +4112,12 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) { case TSDB_DATA_TYPE_JSON: { pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } char* buf = taosMemoryCalloc(1, pNode->node.resType.bytes * 2 + 1); if (NULL == buf) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tjsonGetStringValue(pJson, jkValueDatum, buf); diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index b3568e914e..e71cfc47f8 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -952,7 +952,7 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) { } pNode->datum.p = taosMemoryCalloc(1, pNode->node.resType.bytes + 1); if (NULL == pNode->datum.p) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } code = tlvDecodeBinary(pTlv, pNode->datum.p); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 1d6c19346a..d58ee8dbdd 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -120,7 +120,7 @@ static int32_t callocNodeChunk(SNodeAllocator* pAllocator, SNodeMemChunk** pOutC SNodeMemChunk* pNewChunk = taosMemoryCalloc(1, sizeof(SNodeMemChunk) + pAllocator->chunkSize); if (NULL == pNewChunk) { if (pOutChunk) *pOutChunk = NULL; - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pNewChunk->pBuf = (char*)(pNewChunk + 1); pNewChunk->availableSize = pAllocator->chunkSize; @@ -141,7 +141,7 @@ static int32_t callocNodeChunk(SNodeAllocator* pAllocator, SNodeMemChunk** pOutC static int32_t nodesCallocImpl(int32_t size, void** pOut) { if (NULL == g_pNodeAllocator) { *pOut = taosMemoryCalloc(1, size); - if (!*pOut) return TSDB_CODE_OUT_OF_MEMORY; + if (!*pOut) return terrno; return TSDB_CODE_SUCCESS; } @@ -180,7 +180,7 @@ void nodesFree(void* p) { static int32_t createNodeAllocator(int32_t chunkSize, SNodeAllocator** pAllocator) { *pAllocator = taosMemoryCalloc(1, sizeof(SNodeAllocator)); if (NULL == *pAllocator) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pAllocator)->chunkSize = chunkSize; int32_t code = callocNodeChunk(*pAllocator, NULL); diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index acd1851d76..23025dcab9 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -48,7 +48,7 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSchema* pSchema, bool isTag) { bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBoundInfo->numOfBound = 0; @@ -139,7 +139,7 @@ static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchem int32_t output = 0; void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output)) { @@ -240,7 +240,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 taosMemoryFree(tmp); } else { uError("SML smlBuildCol out of memory"); - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; } goto end; } @@ -253,7 +253,7 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32 } char* pUcs4 = taosMemoryCalloc(1, size); if (NULL == pUcs4) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, size, &len)) { @@ -315,7 +315,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pCreateTblReq) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName, pTableMeta->tableInfo.numOfTags, @@ -323,7 +323,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1); if (pCreateTblReq->ctb.stbName == NULL){ - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } (void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen); @@ -400,7 +400,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc int32_t len = 0; char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE); if (NULL == pUcs4) { - ret = TSDB_CODE_OUT_OF_MEMORY; + ret = terrno; goto end; } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len)) { diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 9412735ded..421fb003f8 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -182,7 +182,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBoundInfo->numOfBound = 0; @@ -768,7 +768,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p } pStmt->pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pStmt->pCreateTblReq) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } insBuildCreateTbReq(pStmt->pCreateTblReq, pStmt->targetTableName.tname, pTag, pStmt->pTableMeta->suid, pStmt->usingTableName.tname, pTagName, pStmt->pTableMeta->tableInfo.numOfTags, @@ -850,7 +850,7 @@ static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) { case TSDB_DATA_TYPE_NCHAR: pValue->datum.p = taosMemoryCalloc(1, pVal->nData + VARSTR_HEADER_SIZE); if (NULL == pValue->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pValue->datum.p, pVal->nData); memcpy(varDataVal(pValue->datum.p), pVal->pData, pVal->nData); @@ -1916,7 +1916,7 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod pStbRowsCxt->pCreateCtbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (pStbRowsCxt->pCreateCtbReq == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } if (code == TSDB_CODE_SUCCESS) { insBuildCreateTbReq(pStbRowsCxt->pCreateCtbReq, pStbRowsCxt->ctbName.tname, pStbRowsCxt->pTag, @@ -2325,7 +2325,7 @@ static void destroyStbRowsDataContext(SStbRowsDataContext* pStbRowsCxt) { static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDataContext** ppStbRowsCxt) { SStbRowsDataContext* pStbRowsCxt = taosMemoryCalloc(1, sizeof(SStbRowsDataContext)); if (!pStbRowsCxt) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } tNameAssign(&pStbRowsCxt->stbName, &pStmt->targetTableName); int32_t code = collectUseTable(&pStbRowsCxt->stbName, pStmt->pTableNameHashObj); diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index 5b459243a4..b67b7fc583 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -32,7 +32,7 @@ typedef struct SKvParam { int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData) { *pData = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == *pData) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SSubmitTbData* pNew = *pData; @@ -190,7 +190,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch int32_t output = 0; void* p = taosMemoryCalloc(1, colLen * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(bind[c].buffer, colLen, (TdUcs4*)(p), colLen * TSDB_NCHAR_SIZE, &output)) { @@ -224,7 +224,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch if (NULL == pDataBlock->pData->pCreateTbReq) { pDataBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pDataBlock->pData->pCreateTbReq) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } } @@ -530,7 +530,7 @@ int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const c int32_t output = 0; void* p = taosMemoryCalloc(1, colLen * TSDB_NCHAR_SIZE); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } if (!taosMbsToUcs4(bind[c].buffer, colLen, (TdUcs4*)(p), colLen * TSDB_NCHAR_SIZE, &output)) { @@ -564,7 +564,7 @@ int32_t qBindStmtTagsValue2(void* pBlock, void* boundTags, int64_t suid, const c if (NULL == pDataBlock->pData->pCreateTbReq) { pDataBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pDataBlock->pData->pCreateTbReq) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto end; } } @@ -593,13 +593,13 @@ static int32_t convertStmtStbNcharCol2(SMsgBuf* pMsgBuf, SSchema* pSchema, TAOS_ dst->buffer = taosMemoryCalloc(src->num, max_buf_len); if (NULL == dst->buffer) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } dst->length = taosMemoryCalloc(src->num, sizeof(int32_t)); if (NULL == dst->length) { taosMemoryFreeClear(dst->buffer); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } char* src_buf = src->buffer; @@ -865,7 +865,7 @@ int32_t buildBoundFields(int32_t numOfBound, int16_t* boundColumns, SSchema* pSc if (fields) { *fields = taosMemoryCalloc(numOfBound, sizeof(TAOS_FIELD_E)); if (NULL == *fields) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SSchema* schema = &pSchema[boundColumns[0]]; @@ -972,7 +972,7 @@ int32_t qCloneStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, bool rese *pDst = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == *pDst) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } STableDataCxt* pNewCxt = (STableDataCxt*)*pDst; @@ -1050,7 +1050,7 @@ int32_t qRebuildStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, uint64_ if (rebuildCreateTb && NULL == pBlock->pData->pCreateTbReq) { pBlock->pData->pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == pBlock->pData->pCreateTbReq) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index b0581d2fd3..e77678fb69 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -188,7 +188,7 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) { pInfo->hasBoundCols = false; pInfo->pColIndex = taosMemoryCalloc(numOfBound, sizeof(int16_t)); if (NULL == pInfo->pColIndex) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } for (int32_t i = 0; i < numOfBound; ++i) { pInfo->pColIndex[i] = i; @@ -230,7 +230,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat STableDataCxt* pTableCxt = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == pTableCxt) { *pOutput = NULL; - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = TSDB_CODE_SUCCESS; @@ -264,7 +264,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat if (TSDB_CODE_SUCCESS == code) { pTableCxt->pData = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == pTableCxt->pData) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } else { pTableCxt->pData->flags = (pCreateTbReq != NULL && NULL != *pCreateTbReq) ? SUBMIT_REQ_AUTO_CREATE_TABLE : 0; pTableCxt->pData->flags |= colMode ? SUBMIT_REQ_COLUMN_DATA_FORMAT : 0; @@ -300,7 +300,7 @@ static int32_t rebuildTableData(SSubmitTbData* pSrc, SSubmitTbData** pDst) { int32_t code = TSDB_CODE_SUCCESS; SSubmitTbData* pTmp = taosMemoryCalloc(1, sizeof(SSubmitTbData)); if (NULL == pTmp) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } else { pTmp->flags = pSrc->flags; pTmp->suid = pSrc->suid; @@ -477,12 +477,12 @@ static int32_t createVgroupDataCxt(STableDataCxt* pTableCxt, SHashObj* pVgroupHa SVgroupDataCxt** pOutput) { SVgroupDataCxt* pVgCxt = taosMemoryCalloc(1, sizeof(SVgroupDataCxt)); if (NULL == pVgCxt) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgCxt->pData = taosMemoryCalloc(1, sizeof(SSubmitReq2)); if (NULL == pVgCxt->pData) { insDestroyVgroupDataCxt(pVgCxt); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgCxt->vgId = pTableCxt->pMeta->vgId; @@ -840,7 +840,7 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList, } SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; } if (TSDB_CODE_SUCCESS == code) { dst->numOfTables = taosArrayGetSize(src->pData->aSubmitTbData); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index a0b8c13e58..9878ff279c 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2929,7 +2929,7 @@ static int32_t rewriteQueryTimeFunc(STranslateContext* pCxt, int64_t val, SNode* char* pStr = taosMemoryCalloc(1, 20); if (NULL == pStr) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } snprintf(pStr, 20, "%" PRId64 "", val); int32_t code = rewriteFuncToValue(pCxt, &pStr, pNode); @@ -3769,7 +3769,7 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) { size_t vgroupNum = taosArrayGetSize(pVgs); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * vgroupNum); if (NULL == *pVgsInfo) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pVgsInfo)->numOfVgroups = vgroupNum; for (int32_t i = 0; i < vgroupNum; ++i) { @@ -3798,7 +3798,7 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) { size_t ndnode = taosArrayGetSize(pDnodes); *pVgsInfo = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo) * ndnode); if (NULL == *pVgsInfo) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pVgsInfo)->numOfVgroups = ndnode; for (int32_t i = 0; i < ndnode; ++i) { @@ -3926,7 +3926,7 @@ static int32_t setSuperTableVgroupList(STranslateContext* pCxt, SName* pName, SR static int32_t setNormalTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { pRealTable->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (NULL == pRealTable->pVgroupList) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pRealTable->pVgroupList->numOfVgroups = 1; return getTableHashVgroupImpl(pCxt, pName, pRealTable->pVgroupList->vgroups); @@ -4034,7 +4034,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo } SVgroupsInfo* pVgpsInfo = taosMemoryCalloc(1, sizeof(int32_t) + sizeof(SVgroupInfo)); if (!pVgpsInfo) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } pVgpsInfo->numOfVgroups = 1; @@ -6348,7 +6348,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* const char* pTbName = taosArrayGetP(pInfo->aTbnames, k); char* pNewTbName = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1); if (!pNewTbName) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } if (NULL == taosArrayPush(pTbNames, &pNewTbName)) { @@ -8682,7 +8682,7 @@ static int32_t createRollupTableMeta(SCreateTableStmt* pStmt, int8_t precision, int32_t numOfField = LIST_LENGTH(pStmt->pCols) + LIST_LENGTH(pStmt->pTags); STableMeta* pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + numOfField * sizeof(SSchema)); if (NULL == pMeta) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pMeta->tableType = TSDB_SUPER_TABLE; pMeta->tableInfo.numOfTags = LIST_LENGTH(pStmt->pTags); @@ -9478,7 +9478,7 @@ static int32_t checkCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pS static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { int32_t code = checkCreateSmaIndex(pCxt, pStmt); pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); - if (pStmt->pReq == NULL) code = TSDB_CODE_OUT_OF_MEMORY; + if (pStmt->pReq == NULL) code = terrno; if (TSDB_CODE_SUCCESS == code) { code = buildCreateSmaReq(pCxt, pStmt, pStmt->pReq); } @@ -11388,7 +11388,7 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) { *buf = taosMemoryCalloc(1, *len); if (*buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } TdFilePtr tfile = taosOpenFile(pName, O_RDONLY | O_BINARY); @@ -11648,7 +11648,7 @@ static int32_t translateShowVariables(STranslateContext* pCxt, SShowStmt* pStmt) static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateDatabaseStmt* pStmt) { pStmt->pCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pCfg) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SName name; @@ -11662,7 +11662,7 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) { pStmt->pDbCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pDbCfg) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pDbCfg); if (TSDB_CODE_SUCCESS == code) { @@ -12086,7 +12086,7 @@ static int32_t translateCreateTSMA(STranslateContext* pCxt, SCreateTSMAStmt* pSt SName useTbName = {0}; if (code == TSDB_CODE_SUCCESS) { pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); - if (!pStmt->pReq) return TSDB_CODE_OUT_OF_MEMORY; + if (!pStmt->pReq) return terrno; } if (code == TSDB_CODE_SUCCESS) { code = buildCreateTSMAReq(pCxt, pStmt, pStmt->pReq, &useTbName); @@ -12394,7 +12394,7 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t* *numOfCols = LIST_LENGTH(pProjections); *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SNode* pNode; @@ -12426,7 +12426,7 @@ static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) *numOfCols = 1; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE; @@ -12439,7 +12439,7 @@ static int32_t extractDescribeResultSchema(STableMeta* pMeta, int32_t* numOfCols if (pMeta && useCompress(pMeta->tableType)) *numOfCols = DESCRIBE_RESULT_COLS_COMPRESS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12479,7 +12479,7 @@ static int32_t extractShowCreateDatabaseResultSchema(int32_t* numOfCols, SSchema *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12497,7 +12497,7 @@ static int32_t extractShowCreateTableResultSchema(int32_t* numOfCols, SSchema** *numOfCols = 2; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12515,7 +12515,7 @@ static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** p *numOfCols = SHOW_CREATE_VIEW_RESULT_COLS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12533,7 +12533,7 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS *numOfCols = 3; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -12555,7 +12555,7 @@ static int32_t extractCompactDbResultSchema(int32_t* numOfCols, SSchema** pSchem *numOfCols = COMPACT_DB_RESULT_COLS; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); if (NULL == (*pSchema)) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; @@ -13358,7 +13358,7 @@ static int32_t serializeVgroupCreateTableBatch(SVgroupCreateTableBatch* pTbBatch SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFreeClear(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = pTbBatch->info; pVgData->pData = buf; @@ -14081,7 +14081,7 @@ static int32_t prepareReadCsvFile(STranslateContext* pCxt, SCreateSubTableFromFi { pCreateInfo = taosMemoryCalloc(1, sizeof(SCreateTbInfo)); if (NULL == pCreateInfo) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _ERR; } @@ -14391,7 +14391,7 @@ static int32_t serializeVgroupDropTableBatch(SVgroupDropTableBatch* pTbBatch, SA SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFreeClear(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = pTbBatch->info; pVgData->pData = buf; @@ -14841,7 +14841,7 @@ static int32_t serializeAlterTbReq(STranslateContext* pCxt, SAlterTableStmt* pSt SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFree(pMsg); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = vg; pVgData->pData = pMsg; @@ -14946,7 +14946,7 @@ static int32_t serializeFlushVgroup(SVgroupInfo* pVg, SArray* pBufArray) { SVgDataBlocks* pVgData = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == pVgData) { taosMemoryFree(buf); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pVgData->vg = *pVg; pVgData->pData = buf; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 250e9385b4..5c4ced7004 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -463,7 +463,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi int32_t valLen = (int32_t)strlen(jsonValue); char* tmp = taosMemoryCalloc(1, valLen * TSDB_NCHAR_SIZE); if (!tmp) { - retCode = TSDB_CODE_OUT_OF_MEMORY; + retCode = terrno; goto end; } val.type = TSDB_DATA_TYPE_NCHAR; @@ -1039,7 +1039,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta) { *pMeta = taosMemoryCalloc(1, sizeof(STableMeta) + pViewMeta->numOfCols * sizeof(SSchema)); if (NULL == *pMeta) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pMeta)->uid = pViewMeta->viewId; (*pMeta)->vgId = MNODE_HANDLE; diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index b78cd36f0e..35e626872e 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -172,7 +172,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { case TSDB_DATA_TYPE_VARBINARY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); memcpy(varDataVal(pVal->datum.p), pParam->buffer, pVal->node.resType.bytes); @@ -182,7 +182,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { case TSDB_DATA_TYPE_GEOMETRY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes); @@ -192,7 +192,7 @@ static int32_t setValueByBindParam(SValueNode* pVal, TAOS_MULTI_BIND* pParam) { pVal->node.resType.bytes *= TSDB_NCHAR_SIZE; pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t output = 0; @@ -460,7 +460,7 @@ static int32_t setValueByBindParam2(SValueNode* pVal, TAOS_STMT2_BIND* pParam) { case TSDB_DATA_TYPE_VARBINARY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); memcpy(varDataVal(pVal->datum.p), pParam->buffer, pVal->node.resType.bytes); @@ -470,7 +470,7 @@ static int32_t setValueByBindParam2(SValueNode* pVal, TAOS_STMT2_BIND* pParam) { case TSDB_DATA_TYPE_GEOMETRY: pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } varDataSetLen(pVal->datum.p, pVal->node.resType.bytes); strncpy(varDataVal(pVal->datum.p), (const char*)pParam->buffer, pVal->node.resType.bytes); @@ -480,7 +480,7 @@ static int32_t setValueByBindParam2(SValueNode* pVal, TAOS_STMT2_BIND* pParam) { pVal->node.resType.bytes *= TSDB_NCHAR_SIZE; pVal->datum.p = taosMemoryCalloc(1, pVal->node.resType.bytes + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t output = 0; From 37c12b6c3a1106809dc1bbdd8a63ecee03dee58e Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 10 Sep 2024 18:55:02 +0800 Subject: [PATCH 22/32] enh: error handling --- source/dnode/vnode/src/inc/tsdb.h | 2 +- source/dnode/vnode/src/tsdb/tsdbCommit2.c | 2 +- source/dnode/vnode/src/tsdb/tsdbFS.c | 6 ++++-- source/dnode/vnode/src/tsdb/tsdbFS2.c | 20 ++++++++----------- source/dnode/vnode/src/tsdb/tsdbFS2.h | 6 +++--- source/dnode/vnode/src/tsdb/tsdbFile2.c | 3 +-- source/dnode/vnode/src/tsdb/tsdbFile2.h | 2 +- source/dnode/vnode/src/tsdb/tsdbIter.c | 3 ++- source/dnode/vnode/src/tsdb/tsdbOpen.c | 4 ++-- source/dnode/vnode/src/tsdb/tsdbRead2.c | 2 +- .../dnode/vnode/src/tsdb/tsdbReaderWriter.c | 3 +-- source/dnode/vnode/src/tsdb/tsdbRetention.c | 8 ++++---- source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c | 13 ++++++------ source/dnode/vnode/src/tsdb/tsdbUpgrade.c | 2 +- source/libs/stream/src/streamBackendRocksdb.c | 4 ++-- source/util/src/tpagedbuf.c | 4 ++-- source/util/src/tworker.c | 6 +++--- 17 files changed, 43 insertions(+), 47 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 59d70889e5..3110d34bad 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -286,7 +286,7 @@ int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *m int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk); // SDelFReader int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb); -int32_t tsdbDelFReaderClose(SDelFReader **ppReader); +void tsdbDelFReaderClose(SDelFReader **ppReader); int32_t tsdbReadDelDatav1(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData, int64_t maxVer); int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData); int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 58ab8bca82..a768716413 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -572,7 +572,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { // begin tasks on file set for (int i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); - TAOS_UNUSED(tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset)); + tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset); if (fset) { code = tsdbTFileSetInitCopy(tsdb, fset, &info->fset); if (code) { diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index dbd79a1f93..baecace7ea 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -105,8 +105,10 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) { code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); } - (void)tsdbFSToBinary(pData, pFS); - (void)taosCalcChecksumAppend(0, pData, size); + int32_t tsize = tsdbFSToBinary(pData, pFS); + + code = taosCalcChecksumAppend(0, pData, size); + TSDB_CHECK_CODE(code, lino, _exit); // save to file pFD = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH); diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 4ccda58903..3684544f14 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -365,7 +365,7 @@ static int32_t tsdbFSDoScanAndFixFile(STFileSystem *fs, const STFileObj *fobj) { if (tsS3Enabled && fobj->f->lcn > 1) { char fname1[TSDB_FILENAME_LEN]; - (void)tsdbTFileLastChunkName(fs->tsdb, fobj->f, fname1); + tsdbTFileLastChunkName(fs->tsdb, fobj->f, fname1); if (!taosCheckExistFile(fname1)) { code = TSDB_CODE_FILE_CORRUPTED; tsdbError("vgId:%d %s failed since file:%s does not exist", TD_VID(fs->tsdb->pVnode), __func__, fname1); @@ -648,10 +648,9 @@ _exit: return code; } -static int32_t close_file_system(STFileSystem *fs) { +static void close_file_system(STFileSystem *fs) { TARRAY2_CLEAR(fs->fSetArr, tsdbTFileSetClear); TARRAY2_CLEAR(fs->fSetArrTmp, tsdbTFileSetClear); - return 0; } static int32_t fset_cmpr_fn(const struct STFileSet *pSet1, const struct STFileSet *pSet2) { @@ -800,13 +799,13 @@ void tsdbEnableBgTask(STsdb *pTsdb) { (void)taosThreadMutexUnlock(&pTsdb->mutex); } -int32_t tsdbCloseFS(STFileSystem **fs) { - if (fs[0] == NULL) return 0; +void tsdbCloseFS(STFileSystem **fs) { + if (fs[0] == NULL) return; (void)tsdbDisableAndCancelAllBgTask((*fs)->tsdb); - (void)close_file_system(fs[0]); + close_file_system(fs[0]); destroy_fs(fs); - return 0; + return; } int64_t tsdbFSAllocEid(STFileSystem *fs) { @@ -1026,13 +1025,12 @@ int32_t tsdbFSCreateRefSnapshotWithoutLock(STFileSystem *fs, TFileSetArray **fse return code; } -int32_t tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr) { +void tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr) { if (fsetArr[0]) { TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear); taosMemoryFreeClear(fsetArr[0]); fsetArr[0] = NULL; } - return 0; } static SHashObj *tsdbFSetRangeArrayToHash(TFileSetRangeArray *pRanges) { @@ -1174,7 +1172,7 @@ _out: void tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr) { tsdbTFileSetRangeArrayDestroy(fsrArr); } -int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) { +void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) { int16_t sttTrigger = tsdb->pVnode->config.sttTrigger; tsdbFSGetFSet(tsdb->pFS, fid, fset); @@ -1195,8 +1193,6 @@ int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) { } tsdbInfo("vgId:%d begin task on file set:%d", TD_VID(tsdb->pVnode), fid); } - - return 0; } int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) { diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.h b/source/dnode/vnode/src/tsdb/tsdbFS2.h index 6de2b8ace0..500a214124 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.h @@ -38,13 +38,13 @@ typedef enum { /* Exposed APIs */ // open/close int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback); -int32_t tsdbCloseFS(STFileSystem **fs); +void tsdbCloseFS(STFileSystem **fs); // snapshot int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr); int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr); int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr); int32_t tsdbFSCreateRefSnapshotWithoutLock(STFileSystem *fs, TFileSetArray **fsetArr); -int32_t tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr); +void tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr); int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pExclude, TFileSetArray **fsetArr, TFileOpArray *fopArr); @@ -61,7 +61,7 @@ int32_t tsdbFSEditAbort(STFileSystem *fs); // other void tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset); int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid); -int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset); +void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset); int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid); // utils int32_t save_fs(const TFileSetArray *arr, const char *fname); diff --git a/source/dnode/vnode/src/tsdb/tsdbFile2.c b/source/dnode/vnode/src/tsdb/tsdbFile2.c index d5d222eb56..5c832dccda 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile2.c @@ -399,7 +399,7 @@ void tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]) { } } -int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]) { +void tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]) { SVnode *pVnode = pTsdb->pVnode; STfs *pTfs = pVnode->pTfs; @@ -428,7 +428,6 @@ int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]) { f->lcn, // g_tfile_info[f->type].suffix); } - return 0; } bool tsdbIsSameTFile(const STFile *f1, const STFile *f2) { diff --git a/source/dnode/vnode/src/tsdb/tsdbFile2.h b/source/dnode/vnode/src/tsdb/tsdbFile2.h index 8f80d88ba4..6027064c02 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFile2.h @@ -45,7 +45,7 @@ enum { int32_t tsdbTFileToJson(const STFile *f, cJSON *json); int32_t tsdbJsonToTFile(const cJSON *json, tsdb_ftype_t ftype, STFile *f); void tsdbTFileName(STsdb *pTsdb, const STFile *f, char fname[]); -int32_t tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]); +void tsdbTFileLastChunkName(STsdb *pTsdb, const STFile *f, char fname[]); bool tsdbIsSameTFile(const STFile *f1, const STFile *f2); bool tsdbIsTFileChanged(const STFile *f1, const STFile *f2); diff --git a/source/dnode/vnode/src/tsdb/tsdbIter.c b/source/dnode/vnode/src/tsdb/tsdbIter.c index 1902a51baf..e4218ea4fc 100644 --- a/source/dnode/vnode/src/tsdb/tsdbIter.c +++ b/source/dnode/vnode/src/tsdb/tsdbIter.c @@ -373,7 +373,8 @@ static int32_t tsdbDataIterOpen(STsdbIter *iter) { iter->dataData->brinBlkArrayIdx = 0; // SBrinBlock - (void)tBrinBlockInit(iter->dataData->brinBlock); + code = tBrinBlockInit(iter->dataData->brinBlock); + if (code) return code; iter->dataData->brinBlockIdx = 0; // SBlockData diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index df507251ed..09d5cdbdb3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -86,7 +86,7 @@ int32_t tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg * _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, lino, tstrerror(code)); - (void)tsdbCloseFS(&pTsdb->pFS); + tsdbCloseFS(&pTsdb->pFS); (void)taosThreadMutexDestroy(&pTsdb->mutex); taosMemoryFree(pTsdb); } else { @@ -109,7 +109,7 @@ int32_t tsdbClose(STsdb **pTsdb) { (*pTsdb)->mem = NULL; (void)taosThreadMutexUnlock(&(*pTsdb)->mutex); - (void)tsdbCloseFS(&(*pTsdb)->pFS); + tsdbCloseFS(&(*pTsdb)->pFS); tsdbCloseCache(*pTsdb); #ifdef TD_ENTERPRISE (void)tsdbCloseCompMonitor(*pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 7813716e9f..8f66df1ffb 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -5967,7 +5967,7 @@ void tsdbUntakeReadSnap2(STsdbReader* pReader, STsdbReadSnap* pSnap, bool proact if (pSnap->pNode) taosMemoryFree(pSnap->pNode); if (pSnap->pINode) taosMemoryFree(pSnap->pINode); - (void) tsdbFSDestroyRefSnapshot(&pSnap->pfSetArray); + tsdbFSDestroyRefSnapshot(&pSnap->pfSetArray); taosMemoryFree(pSnap); } diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 2fd123d8d2..1112dcaaae 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -819,7 +819,7 @@ _exit: return code; } -int32_t tsdbDelFReaderClose(SDelFReader **ppReader) { +void tsdbDelFReaderClose(SDelFReader **ppReader) { int32_t code = 0; SDelFReader *pReader = *ppReader; @@ -832,7 +832,6 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) { } *ppReader = NULL; - return code; } int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData) { diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 070735f079..2409b390c9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -71,8 +71,8 @@ static int32_t tsdbDoCopyFileLC(SRTNer *rtner, const STFileObj *from, const STFi char fname_from[TSDB_FILENAME_LEN]; char fname_to[TSDB_FILENAME_LEN]; - (void)tsdbTFileLastChunkName(rtner->tsdb, from->f, fname_from); - (void)tsdbTFileLastChunkName(rtner->tsdb, to, fname_to); + tsdbTFileLastChunkName(rtner->tsdb, from->f, fname_from); + tsdbTFileLastChunkName(rtner->tsdb, to, fname_to); fdFrom = taosOpenFile(fname_from, TD_FILE_READ); if (fdFrom == NULL) { @@ -316,7 +316,7 @@ static int32_t tsdbRetention(void *arg) { // begin task (void)taosThreadMutexLock(&pTsdb->mutex); - (void)tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset); + tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset); if (fset && (code = tsdbTFileSetInitCopy(pTsdb, fset, &rtner.fset))) { (void)taosThreadMutexUnlock(&pTsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); @@ -693,7 +693,7 @@ static int32_t tsdbDoS3Migrate(SRTNer *rtner) { TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, &lino, _exit); } char fname1[TSDB_FILENAME_LEN]; - (void)tsdbTFileLastChunkName(rtner->tsdb, fobj->f, fname1); + tsdbTFileLastChunkName(rtner->tsdb, fobj->f, fname1); if (taosCheckExistFile(fname1)) { int32_t mtime = 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c index e2cbf37ae4..f86e548321 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c @@ -18,7 +18,7 @@ #include "tsdbFS2.h" #include "tsdbFSetRAW.h" -static int32_t tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader); +static void tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader); // reader typedef struct SDataFileRAWReaderIter { @@ -65,7 +65,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at line %d since %s, sver:0, ever:%" PRId64 " type:%d", TD_VID(tsdb->pVnode), __func__, lino, tstrerror(code), ever, type); - (void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); + tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); taosMemoryFree(reader[0]); reader[0] = NULL; } else { @@ -84,7 +84,7 @@ int32_t tsdbSnapRAWReaderClose(STsdbSnapRAWReader** reader) { STsdb* tsdb = reader[0]->tsdb; TARRAY2_DESTROY(reader[0]->dataReaderArr, tsdbDataFileRAWReaderClose); - (void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); + tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); taosMemoryFree(reader[0]); reader[0] = NULL; @@ -141,15 +141,14 @@ static int32_t tsdbSnapRAWReadFileSetOpenReader(STsdbSnapRAWReader* reader) { _exit: if (code) { - (void)tsdbSnapRAWReadFileSetCloseReader(reader); + tsdbSnapRAWReadFileSetCloseReader(reader); TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino); } return code; } -static int32_t tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader) { +static void tsdbSnapRAWReadFileSetCloseReader(STsdbSnapRAWReader* reader) { TARRAY2_CLEAR(reader->dataReaderArr, tsdbDataFileRAWReaderClose); - return 0; } static int32_t tsdbSnapRAWReadFileSetOpenIter(STsdbSnapRAWReader* reader) { @@ -262,7 +261,7 @@ _exit: static int32_t tsdbSnapRAWReadEnd(STsdbSnapRAWReader* reader) { (void)tsdbSnapRAWReadFileSetCloseIter(reader); - (void)tsdbSnapRAWReadFileSetCloseReader(reader); + tsdbSnapRAWReadFileSetCloseReader(reader); reader->ctx->fset = NULL; return 0; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c index e492ea0f63..6d95ebad28 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c +++ b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c @@ -568,7 +568,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - (void)tsdbDelFReaderClose(&reader); + tsdbDelFReaderClose(&reader); taosArrayDestroy(aDelIdx); return code; } diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index ced62ba82e..8fd36c9ac8 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -904,7 +904,7 @@ _EXIT: streamMutexDestroy(&pHandle->mutex); streamMutexDestroy(&pHandle->cfMutex); taosHashCleanup(pHandle->cfInst); - (void)tdListFree(pHandle->list); + pHandle->list = tdListFree(pHandle->list); taosMemoryFree(pHandle); stDebug("failed to init stream backend at %s", backendPath); taosMemoryFree(backendPath); @@ -937,7 +937,7 @@ void streamBackendCleanup(void* arg) { head = tdListPopHead(pHandle->list); } - (void)tdListFree(pHandle->list); + pHandle->list = tdListFree(pHandle->list); streamMutexDestroy(&pHandle->mutex); streamMutexDestroy(&pHandle->cfMutex); diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 32b9b6e18d..7f2f084b9b 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -663,8 +663,8 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { taosArrayDestroy(pBuf->pIdList); - (void)tdListFree(pBuf->lruList); - (void)tdListFree(pBuf->freePgList); + pBuf->lruList = tdListFree(pBuf->lruList); + pBuf->freePgList = tdListFree(pBuf->freePgList); taosArrayDestroy(pBuf->emptyDummyIdList); taosArrayDestroy(pBuf->pFree); diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index e089f8e6e0..1fc0d16d57 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -887,9 +887,9 @@ void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { taosMemoryFree(pNode); } - (void)tdListFree(pPool->workers); - (void)tdListFree(pPool->backupWorkers); - (void)tdListFree(pPool->exitedWorkers); + pPool->workers = tdListFree(pPool->workers); + pPool->backupWorkers = tdListFree(pPool->backupWorkers); + pPool->exitedWorkers = tdListFree(pPool->exitedWorkers); taosMemoryFree(pPool->pCb); (void)taosThreadMutexDestroy(&pPool->poolLock); From d403a6129adbd22a4f58fd6352cfcda2d61d58d7 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 10 Sep 2024 19:14:27 +0800 Subject: [PATCH 23/32] fix mem leak --- source/libs/transport/src/trans.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 1c783f44fe..fa0be7bcd8 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -103,7 +103,7 @@ void* rpcOpen(const SRpcInit* pInit) { pRpc->timeToGetConn = 10 * 1000; } pRpc->notWaitAvaliableConn = pInit->notWaitAvaliableConn; - + pRpc->tcphandle = (*taosInitHandle[pRpc->connType])(ip, pInit->localPort, pRpc->label, pRpc->numOfThreads, NULL, pRpc); @@ -155,10 +155,13 @@ void* rpcReallocCont(void* ptr, int64_t contLen) { char* st = (char*)ptr - TRANS_MSG_OVERHEAD; int64_t sz = contLen + TRANS_MSG_OVERHEAD; - st = taosMemoryRealloc(st, sz); - if (st == NULL) { + char* nst = taosMemoryRealloc(st, sz); + if (nst == NULL) { + taosMemoryFree(st); terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; + } else { + st = nst; } return st + TRANS_MSG_OVERHEAD; @@ -168,7 +171,7 @@ int32_t rpcSendRequest(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64 return transSendRequest(shandle, pEpSet, pMsg, NULL); } int32_t rpcSendRequestWithCtx(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64_t* pRid, SRpcCtx* pCtx) { - if (pCtx != NULL || pMsg->info.handle != 0 || pMsg->info.noResp != 0|| pRid == NULL) { + if (pCtx != NULL || pMsg->info.handle != 0 || pMsg->info.noResp != 0 || pRid == NULL) { return transSendRequest(shandle, pEpSet, pMsg, pCtx); } else { return transSendRequestWithId(shandle, pEpSet, pMsg, pRid); From 1519be0282078696ec10fc3a2f55570d9950e7ac Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 10 Sep 2024 19:19:57 +0800 Subject: [PATCH 24/32] fix mem leak --- source/libs/transport/src/trans.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index fa0be7bcd8..0881f91d69 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -140,6 +140,7 @@ void* rpcMallocCont(int64_t contLen) { char* start = taosMemoryCalloc(1, size); if (start == NULL) { tError("failed to malloc msg, size:%" PRId64, size); + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } else { tTrace("malloc mem:%p size:%" PRId64, start, size); From 7d5ef92bb22ac2061b53fb8638f8982fd9a3c7e6 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 11 Sep 2024 09:42:59 +0800 Subject: [PATCH 25/32] fix: block data shrink issue --- source/common/src/tdatablock.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 6e4162268d..dee9ec2c0c 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -3397,11 +3397,15 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) { } void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) { + return; + if (NULL == pDataBlock || pDataBlock->info.rows == 0) { return; } - ASSERT(pDataBlock->info.rows > 0); +#define BLOCK_DATA_CHECK_TRESSA(o) ; + + BLOCK_DATA_CHECK_TRESSA(pDataBlock->info.rows > 0); if (!pDataBlock->info.dataLoad && !forceChk) { return; @@ -3419,35 +3423,35 @@ void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) { checkRows = pDataBlock->info.rows; if (isVarType) { - ASSERT(pCol->varmeta.offset); + BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset); } else { - ASSERT(pCol->nullbitmap); + BLOCK_DATA_CHECK_TRESSA(pCol->nullbitmap); } nextPos = 0; for (int64_t r = 0; r < checkRows; ++r) { if (!colDataIsNull_s(pCol, r)) { - ASSERT(pCol->pData); - ASSERT(pCol->varmeta.length <= pCol->varmeta.allocLen); + BLOCK_DATA_CHECK_TRESSA(pCol->pData); + BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.length <= pCol->varmeta.allocLen); if (isVarType) { - ASSERT(pCol->varmeta.allocLen > 0); - ASSERT(pCol->varmeta.offset[r] < pCol->varmeta.length); + BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.allocLen > 0); + BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] < pCol->varmeta.length); if (pCol->reassigned) { - ASSERT(pCol->varmeta.offset[r] >= 0); + BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] >= 0); } else { - ASSERT(pCol->varmeta.offset[r] == nextPos); + BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] == nextPos); } colLen = varDataTLen(pCol->pData + pCol->varmeta.offset[r]); - ASSERT(colLen >= VARSTR_HEADER_SIZE); - ASSERT(colLen <= pCol->info.bytes); + BLOCK_DATA_CHECK_TRESSA(colLen >= VARSTR_HEADER_SIZE); + BLOCK_DATA_CHECK_TRESSA(colLen <= pCol->info.bytes); if (pCol->reassigned) { - ASSERT((pCol->varmeta.offset[r] + colLen) <= pCol->varmeta.length); + BLOCK_DATA_CHECK_TRESSA((pCol->varmeta.offset[r] + colLen) <= pCol->varmeta.length); } else { nextPos += colLen; - ASSERT(nextPos <= pCol->varmeta.length); + BLOCK_DATA_CHECK_TRESSA(nextPos <= pCol->varmeta.length); } typeValue = *(char*)(pCol->pData + pCol->varmeta.offset[r] + colLen - 1); From 6cbb0cf17228b14a37163f30dbc0436f902f2399 Mon Sep 17 00:00:00 2001 From: lyh250-666 Date: Wed, 11 Sep 2024 09:58:41 +0800 Subject: [PATCH 26/32] enh:modify error code passing libs/ --- source/libs/planner/src/planLogicCreater.c | 2 +- source/libs/planner/src/planOptimizer.c | 12 ++-- source/libs/planner/src/planScaleOut.c | 2 +- source/libs/qcom/src/queryUtil.c | 2 +- source/libs/qworker/src/qworker.c | 4 +- source/libs/scalar/src/filter.c | 42 +++++++------- source/libs/scalar/src/scalar.c | 11 ++-- source/libs/scalar/src/sclfunc.c | 36 ++++++------ source/libs/scalar/src/sclvector.c | 16 +++--- source/libs/scheduler/src/schJob.c | 2 +- source/libs/scheduler/src/schRemote.c | 30 +++++----- source/libs/scheduler/src/schTask.c | 2 +- source/libs/stream/src/streamBackendRocksdb.c | 56 +++++++++---------- source/libs/stream/src/streamCheckpoint.c | 6 +- source/libs/stream/src/streamDispatch.c | 2 +- source/libs/stream/src/streamHb.c | 2 +- source/libs/stream/src/streamMeta.c | 6 +- source/libs/stream/src/streamQueue.c | 4 +- source/libs/stream/src/streamSnapshot.c | 6 +- source/libs/stream/src/streamStartHistory.c | 2 +- source/libs/stream/src/streamState.c | 2 +- source/libs/stream/src/streamTask.c | 6 +- source/libs/stream/src/streamTaskSm.c | 2 +- source/libs/stream/src/streamUpdate.c | 6 +- source/libs/stream/src/tstreamFileState.c | 2 +- 25 files changed, 130 insertions(+), 133 deletions(-) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3d13ad4c62..6886260d0a 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -202,7 +202,7 @@ static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ES if (NULL != pRewriteExprs) { cxt.pOutputs = taosMemoryCalloc(LIST_LENGTH(pExprs), sizeof(bool)); if (NULL == cxt.pOutputs) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 988440227b..1296986e7f 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2883,7 +2883,7 @@ static int32_t smaIndexOptCreateSmaScan(SScanLogicNode* pScan, STableIndexInfo* pSmaScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (!pSmaScan->pVgroupList) { nodesDestroyNode((SNode*)pSmaScan); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } code = nodesCloneList(pCols, &pSmaScan->node.pTargets); if (NULL == pSmaScan->node.pTargets) { @@ -4297,7 +4297,7 @@ static void lastRowScanOptRemoveUslessTargets(SNodeList* pTargets, SNodeList* pL static int32_t lastRowScanBuildFuncTypes(SScanLogicNode* pScan, SColumnNode* pColNode, int32_t funcType) { SFunctParam* pFuncTypeParam = taosMemoryCalloc(1, sizeof(SFunctParam)); if (NULL == pFuncTypeParam) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pFuncTypeParam->type = funcType; if (NULL == pScan->pFuncTypes) { @@ -4311,7 +4311,7 @@ static int32_t lastRowScanBuildFuncTypes(SScanLogicNode* pScan, SColumnNode* pCo pFuncTypeParam->pCol = taosMemoryCalloc(1, sizeof(SColumn)); if (NULL == pFuncTypeParam->pCol) { taosMemoryFree(pFuncTypeParam); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pFuncTypeParam->pCol->colId = pColNode->colId; strcpy(pFuncTypeParam->pCol->name, pColNode->colName); @@ -6671,7 +6671,7 @@ static int32_t fillTSMAOptCtx(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pScan) { if (nodeType(pTsmaOptCtx->pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) { pTsmaOptCtx->queryInterval = taosMemoryCalloc(1, sizeof(SInterval)); - if (!pTsmaOptCtx->queryInterval) return TSDB_CODE_OUT_OF_MEMORY; + if (!pTsmaOptCtx->queryInterval) return terrno; SWindowLogicNode* pWindow = (SWindowLogicNode*)pTsmaOptCtx->pParent; pTsmaOptCtx->queryInterval->interval = pWindow->interval; @@ -7076,7 +7076,7 @@ static int32_t tsmaOptRewriteTbname(const STSMAOptCtx* pTsmaOptCtx, SNode** pTbN pValue->node.resType = ((SExprNode*)(*pTbNameNode))->resType; pValue->literal = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1); pValue->datum.p = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1 + VARSTR_HEADER_SIZE); - if (!pValue->literal || !pValue->datum.p) code = TSDB_CODE_OUT_OF_MEMORY; + if (!pValue->literal || !pValue->datum.p) code = terrno; } if (code == TSDB_CODE_SUCCESS) { @@ -7204,7 +7204,7 @@ static int32_t tsmaOptRewriteScan(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pNew int32_t len = sizeof(int32_t) + sizeof(SVgroupInfo) * pVgpsInfo->numOfVgroups; pNewScan->pVgroupList = taosMemoryCalloc(1, len); if (!pNewScan->pVgroupList) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } memcpy(pNewScan->pVgroupList, pVgpsInfo, len); diff --git a/source/libs/planner/src/planScaleOut.c b/source/libs/planner/src/planScaleOut.c index bcac7ddd7e..4027056c69 100644 --- a/source/libs/planner/src/planScaleOut.c +++ b/source/libs/planner/src/planScaleOut.c @@ -47,7 +47,7 @@ static int32_t doSetScanVgroup(SLogicNode* pNode, const SVgroupInfo* pVgroup, bo SScanLogicNode* pScan = (SScanLogicNode*)pNode; pScan->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); if (NULL == pScan->pVgroupList) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } memcpy(pScan->pVgroupList->vgroups, pVgroup, sizeof(SVgroupInfo)); *pFound = true; diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 7c7439eac3..30902269c3 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -623,7 +623,7 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) { *pDst = taosMemoryCalloc(1, sizeof(SVCreateTbReq)); if (NULL == *pDst) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pDst)->flags = pSrc->flags; diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 1a9d3e7ba9..9c6ca18d97 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -436,7 +436,7 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes output.pData = taosMemoryCalloc(1, len); if (NULL == output.pData) { - QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + QW_ERR_RET(terrno); } code = dsGetDataBlock(ctx->sinkHandle, &output); @@ -1324,7 +1324,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S if (NULL == mgmt) { qError("calloc %d failed", (int32_t)sizeof(SQWorker)); (void)atomic_sub_fetch_32(&gQwMgmt.qwNum, 1); - QW_RET(TSDB_CODE_OUT_OF_MEMORY); + QW_RET(terrno); } mgmt->cfg.maxSchedulerNum = QW_DEFAULT_SCHEDULER_NUMBER; diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index ec48dd50ae..c62833a3f5 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -468,20 +468,20 @@ int32_t filterInitUnitsFields(SFilterInfo *info) { info->unitSize = FILTER_DEFAULT_UNIT_SIZE; info->units = taosMemoryCalloc(info->unitSize, sizeof(SFilterUnit)); if (info->units == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } info->fields[FLD_TYPE_COLUMN].num = 0; info->fields[FLD_TYPE_COLUMN].size = FILTER_DEFAULT_FIELD_SIZE; info->fields[FLD_TYPE_COLUMN].fields = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].size, sizeof(SFilterField)); if (info->fields[FLD_TYPE_COLUMN].fields == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } info->fields[FLD_TYPE_VALUE].num = 0; info->fields[FLD_TYPE_VALUE].size = FILTER_DEFAULT_FIELD_SIZE; info->fields[FLD_TYPE_VALUE].fields = taosMemoryCalloc(info->fields[FLD_TYPE_VALUE].size, sizeof(SFilterField)); if (info->fields[FLD_TYPE_VALUE].fields == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } return TSDB_CODE_SUCCESS; @@ -497,7 +497,7 @@ static FORCE_INLINE int32_t filterNewRange(SFilterRangeCtx *ctx, SFilterRange *r } else { *r = taosMemoryCalloc(1, sizeof(SFilterRangeNode)); if (*r == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } } @@ -516,7 +516,7 @@ int32_t filterInitRangeCtx(int32_t type, int32_t options, SFilterRangeCtx **ctx) *ctx = taosMemoryCalloc(1, sizeof(SFilterRangeCtx)); if (*ctx == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*ctx)->type = type; (*ctx)->options = options; @@ -961,7 +961,7 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray *group gp.unitNum = gp1->unitNum + gp2->unitNum; gp.unitIdxs = taosMemoryCalloc(gp.unitNum, sizeof(*gp.unitIdxs)); if (NULL == gp.unitIdxs) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } (void)memcpy(gp.unitIdxs, gp1->unitIdxs, gp1->unitNum * sizeof(*gp.unitIdxs)); (void)memcpy(gp.unitIdxs + gp1->unitNum, gp2->unitIdxs, gp2->unitNum * sizeof(*gp.unitIdxs)); @@ -1300,7 +1300,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; if (out.columnData == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } out.columnData->info.type = type; out.columnData->info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; // reserved space for simple_copy @@ -1330,7 +1330,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) { } else { void *data = taosMemoryCalloc(1, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); // reserved space for simple_copy if (NULL == data) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; break; } (void)memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes); @@ -2203,13 +2203,13 @@ int32_t fltInitValFieldData(SFilterInfo *info) { size_t bufBytes = TMAX(dType->bytes, sizeof(int64_t)); fi->data = taosMemoryCalloc(1, bufBytes); if (fi->data == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } assignVal(fi->data, nodesGetValueFromNode(var), dType->bytes, type); } else { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; if (out.columnData == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } out.columnData->info.type = type; out.columnData->info.precision = precision; @@ -2230,7 +2230,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { : TMAX(out.columnData->info.bytes, sizeof(int64_t)); fi->data = taosMemoryCalloc(1, bufBytes); if (fi->data== NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } size_t valBytes = IS_VAR_DATA_TYPE(type) ? varDataTLen(out.columnData->pData) : out.columnData->info.bytes; @@ -2446,7 +2446,7 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gRes[gResIdx] = taosMemoryCalloc(1, sizeof(SFilterGroupCtx)); if (gRes[gResIdx] == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo)); if (gRes[gResIdx]->colInfo == NULL) { @@ -2876,7 +2876,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) { info->groups = taosMemoryCalloc(info->groupNum, sizeof(*info->groups)); if (info->groups == NULL) { info->groupNum = 0; - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } } @@ -2888,7 +2888,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) { pg->unitFlags = taosMemoryCalloc(pg->unitNum, sizeof(*pg->unitFlags)); if (pg->unitFlags == NULL) { pg->unitNum = 0; - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } info->groups[i] = *pg; } @@ -3005,7 +3005,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ int32_t code = TSDB_CODE_SUCCESS; uint32_t *idxNum = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxNum)); if (idxNum == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } for (int32_t i = 0; i < gResNum; ++i) { for (uint32_t m = 0; m < gRes[i]->colNum; ++m) { @@ -3031,7 +3031,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ if (idxs == NULL) { idxs = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxs)); if (idxs == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } } @@ -3044,7 +3044,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_ info->colRange = taosMemoryCalloc(colNum, POINTER_BYTES); if (info->colRange == NULL) { info->colRangeNum = 0; - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } for (int32_t i = 0; i < gResNum; ++i) { @@ -3584,7 +3584,7 @@ int32_t filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *p (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)) { char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); if (newColData == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); if (len < 0) { @@ -3659,7 +3659,7 @@ int32_t filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)) { char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); if (newColData == NULL) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); if (len < 0) { @@ -3740,7 +3740,7 @@ int32_t filterPreprocess(SFilterInfo *info) { int32_t gResNum = 0; SFilterGroupCtx **gRes = taosMemoryCalloc(info->groupNum, sizeof(SFilterGroupCtx *)); if (gRes == NULL) { - FLT_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_JRET(terrno); } FLT_ERR_JRET(filterMergeGroupUnits(info, gRes, &gResNum)); @@ -5218,7 +5218,7 @@ int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pInfo, uint32_t options) *pInfo = taosMemoryCalloc(1, sizeof(SFilterInfo)); if (NULL == *pInfo) { fltError("taosMemoryCalloc %d failed", (int32_t)sizeof(SFilterInfo)); - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + FLT_ERR_RET(terrno); } } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b9a95a3216..3b2450906a 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -41,7 +41,6 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode *valueNode) { int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarParam *pParam) { SColumnInfoData *pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); if (pColumnData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } @@ -99,7 +98,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL int32_t code = TSDB_CODE_SUCCESS; if (NULL == pLeft) { sclError("calloc %d failed", (int32_t)sizeof(SScalarParam)); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } pLeft->numOfRows = pb->info.rows; @@ -131,7 +130,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SListCell *cell = nodeList->pNodeList->pHead; SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; if (out.columnData == NULL) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } int32_t len = 0; void *buf = NULL; @@ -485,7 +484,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarC SScalarParam *paramList = taosMemoryCalloc(*paramNum, sizeof(SScalarParam)); if (NULL == paramList) { sclError("calloc %d failed", (int32_t)((*paramNum) * sizeof(SScalarParam))); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } if (pParamList) { @@ -581,7 +580,7 @@ int32_t sclInitOperatorParams(SScalarParam **pParams, SOperatorNode *node, SScal SScalarParam *paramList = taosMemoryCalloc(paramNum, sizeof(SScalarParam)); if (NULL == paramList) { sclError("calloc %d failed", (int32_t)(paramNum * sizeof(SScalarParam))); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } SCL_ERR_JRET(sclSetOperatorValueType(node, ctx)); @@ -608,7 +607,7 @@ int32_t sclGetNodeRes(SNode *node, SScalarCtx *ctx, SScalarParam **res) { int32_t rowNum = 0; *res = taosMemoryCalloc(1, sizeof(**res)); if (NULL == *res) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } SCL_ERR_RET(sclInitParam(node, *res, ctx, &rowNum)); diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 5fc7c06d57..4e8107a5b2 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -618,7 +618,7 @@ static int32_t trimHelper(char *orgStr, char* remStr, int32_t orgLen, int32_t re static int32_t convVarcharToNchar(char *input, char **output, int32_t inputLen, int32_t *outputLen) { *output = taosMemoryCalloc(inputLen * TSDB_NCHAR_SIZE, 1); if (NULL == *output) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } bool ret = taosMbsToUcs4(input, inputLen, (TdUcs4 *)*output, inputLen * TSDB_NCHAR_SIZE, outputLen); if (!ret) { @@ -631,7 +631,7 @@ static int32_t convVarcharToNchar(char *input, char **output, int32_t inputLen, static int32_t convNcharToVarchar(char *input, char **output, int32_t inputLen, int32_t *outputLen) { *output = taosMemoryCalloc(inputLen, 1); if (NULL == *output) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } *outputLen = taosUcs4ToMbs((TdUcs4 *)input, inputLen, *output); if (*outputLen < 0) { @@ -814,7 +814,7 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar, if (hasNchar && type == TSDB_DATA_TYPE_VARCHAR) { TdUcs4 *newBuf = taosMemoryCalloc((varDataLen(input) + 1) * TSDB_NCHAR_SIZE, 1); if (NULL == newBuf) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t len = varDataLen(input); bool ret = taosMbsToUcs4(varDataVal(input), len, newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, &len); @@ -853,10 +853,10 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu char *outputBuf = NULL; if (NULL == pInputData) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } if (NULL == input) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } int32_t inputLen = 0; @@ -882,7 +882,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu outputBuf = taosMemoryCalloc(outputLen, 1); if (NULL == outputBuf) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } for (int32_t k = 0; k < numOfRows; ++k) { @@ -928,7 +928,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p char *outputBuf = NULL; if (NULL == pInputData) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } int32_t inputLen = 0; @@ -960,7 +960,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p outputBuf = taosMemoryCalloc(outputLen, 1); if (NULL == outputBuf) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } for (int32_t k = 0; k < numOfRows; ++k) { @@ -1016,7 +1016,7 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala int32_t outputLen = pInputData->varmeta.length; char *outputBuf = taosMemoryCalloc(outputLen, 1); if (outputBuf == NULL) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } char *output = outputBuf; @@ -1070,7 +1070,7 @@ static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar } char *outputBuf = taosMemoryCalloc(outputLen, 1); if (outputBuf == NULL) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } char *output = outputBuf; @@ -1528,7 +1528,7 @@ int32_t replaceFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO char *outputBuf = taosMemoryCalloc(outputLen + VARSTR_HEADER_SIZE, 1); if (NULL == outputBuf) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } for (int32_t i = 0; i < numOfRows; ++i) { @@ -1643,7 +1643,7 @@ int32_t substrIdxFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * } char *outputBuf = taosMemoryCalloc(outputLen + VARSTR_HEADER_SIZE, 1); if (NULL == outputBuf) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } for (int32_t k = 0; k < numOfRows; ++k) { @@ -1741,7 +1741,7 @@ int32_t repeatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows); char *outputBuf = taosMemoryCalloc(outputLen, 1); if (outputBuf == NULL) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } char *output = outputBuf; @@ -1834,7 +1834,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp char *buf = taosMemoryMalloc(bufSize); if (convBuf == NULL || output == NULL || buf == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _end; } @@ -2403,7 +2403,7 @@ int32_t toCharFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOu int32_t code = 0; if (format == NULL || out == NULL) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) { @@ -4230,7 +4230,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char * intervals = taosMemoryCalloc(numOfBins, sizeof(double)); if (NULL == intervals) { cJSON_Delete(binDesc); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } if (cJSON_IsNumber(width) && factor == NULL && binType == LINEAR_BIN) { // linear bin process @@ -4295,7 +4295,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char * intervals = taosMemoryCalloc(numOfBins, sizeof(double)); if (NULL == intervals) { cJSON_Delete(binDesc); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } cJSON *bin = binDesc->child; if (bin == NULL) { @@ -4327,7 +4327,7 @@ static int32_t getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char * *binNum = numOfBins - 1; *bins = taosMemoryCalloc(numOfBins, sizeof(SHistoFuncBin)); if (NULL == bins) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } for (int32_t i = 0; i < *binNum; ++i) { (*bins)[i].lower = intervals[i] < intervals[i + 1] ? intervals[i] : intervals[i + 1]; diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index ead6053505..d8cc620b1e 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -124,7 +124,7 @@ int32_t convertBinaryToDouble(const void *inData, void *outData) { char *tmp = taosMemoryCalloc(1, varDataTLen(inData)); if (tmp == NULL) { *((double *)outData) = 0.; - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(tmp, varDataVal(inData), varDataLen(inData)); double ret = taosStr2Double(tmp, NULL); @@ -370,7 +370,7 @@ static FORCE_INLINE int32_t varToVarbinary(char *buf, SScalarParam *pOut, int32_ if (t == NULL) { sclError("Out of memory"); taosMemoryFree(data); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } varDataSetLen(t, size); (void)memcpy(varDataVal(t), data, size); @@ -383,7 +383,7 @@ static FORCE_INLINE int32_t varToVarbinary(char *buf, SScalarParam *pOut, int32_ char *t = taosMemoryCalloc(1, inputLen); if (t == NULL) { sclError("Out of memory"); - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(t, buf, inputLen); int32_t code = colDataSetVal(pOut->columnData, rowIndex, t, false); @@ -401,7 +401,7 @@ static FORCE_INLINE int32_t varToNchar(char *buf, SScalarParam *pOut, int32_t ro char *t = taosMemoryCalloc(1, outputMaxLen); if (NULL == t) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } int32_t ret = taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), outputMaxLen - VARSTR_HEADER_SIZE, &len); @@ -424,7 +424,7 @@ static FORCE_INLINE int32_t ncharToVar(char *buf, SScalarParam *pOut, int32_t ro char *t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE); if (NULL == t) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t)); if (len < 0) { @@ -457,7 +457,7 @@ static FORCE_INLINE int32_t varToGeometry(char *buf, SScalarParam *pOut, int32_t output = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE); if (NULL == output) { - SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_JRET(terrno); } (void)memcpy(output + VARSTR_HEADER_SIZE, t, len); varDataSetLen(output, len); @@ -2155,7 +2155,7 @@ int32_t vectorJsonContains(SScalarParam *pLeft, SScalarParam *pRight, SScalarPar char *pRightData = colDataGetVarData(pRight->columnData, 0); char *jsonKey = taosMemoryCalloc(1, varDataLen(pRightData) + 1); if (NULL == jsonKey) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(jsonKey, varDataVal(pRightData), varDataLen(pRightData)); for (; i >= 0 && i < pLeft->numOfRows; i += step) { @@ -2189,7 +2189,7 @@ int32_t vectorJsonArrow(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam char *pRightData = colDataGetVarData(pRight->columnData, 0); char *jsonKey = taosMemoryCalloc(1, varDataLen(pRightData) + 1); if (NULL == jsonKey) { - SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCL_ERR_RET(terrno); } (void)memcpy(jsonKey, varDataVal(pRightData), varDataLen(pRightData)); for (; i >= 0 && i < pLeft->numOfRows; i += step) { diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 8e2fbb878d..2dbbdeca44 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -810,7 +810,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); if (NULL == pJob) { qError("qid:0x%" PRIx64 " calloc %d failed", pReq->pDag->queryId, (int32_t)sizeof(SSchJob)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } pJob->attr.explainMode = pReq->pDag->explainInfo.mode; diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index bf88248259..40391cea7e 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -583,7 +583,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchTaskCallbackParam)); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->queryId = pJob->queryId; @@ -600,7 +600,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchHbCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->head.isHbParam = true; @@ -625,7 +625,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam)); if (NULL == param) { qError("calloc SSchTaskCallbackParam failed"); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->pTrans = trans->pTrans; @@ -640,7 +640,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3 SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } msgSendInfo->paramFreeFp = taosMemoryFree; @@ -797,13 +797,13 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP; @@ -927,7 +927,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) { SMsgSendInfo *pDst = taosMemoryCalloc(1, sizeof(*pSrc)); if (NULL == pDst) { qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc)); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } TAOS_MEMCPY(pDst, pSrc, sizeof(*pSrc)); @@ -1059,7 +1059,7 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray *taskAction) { void *msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { qError("calloc hb req %d failed", msgSize); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { @@ -1116,7 +1116,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } TAOS_MEMCPY(msg, pTask->msg, msgSize); @@ -1142,7 +1142,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_JRET(terrno); } msgSize = tSerializeSVDeleteReq(msg, msgSize, &req); @@ -1190,7 +1190,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSSubQueryMsg(msg, msgSize, &qMsg) < 0) { @@ -1228,7 +1228,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) { @@ -1256,7 +1256,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) { @@ -1283,7 +1283,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_JOB_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { SCH_JOB_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); @@ -1314,7 +1314,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } if (tSerializeSTaskNotifyReq(msg, msgSize, &qMsg) < 0) { diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index 59b8954a48..9ba2c7ea5c 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -1237,7 +1237,7 @@ _return: int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { SSchTaskCtx *param = taosMemoryCalloc(1, sizeof(SSchTaskCtx)); if (NULL == param) { - SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + SCH_ERR_RET(terrno); } param->jobRid = pJob->refId; diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index ced62ba82e..845dabcf11 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -213,7 +213,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) { char* state = taosMemoryCalloc(1, cap); if (state == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(state, cap, "%s%s%s", path, TD_DIRSEP, "state"); @@ -226,7 +226,7 @@ int32_t rebuildDirFromCheckpoint(const char* path, int64_t chkpId, char** dst) { char* chkp = taosMemoryCalloc(1, cap); if (chkp == NULL) { taosMemoryFree(state); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(chkp, cap, "%s%s%s%scheckpoint%" PRId64 "", path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId); @@ -279,7 +279,7 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) { char* metaPath = taosMemoryCalloc(1, cap); if (metaPath == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t n = snprintf(metaPath, cap, "%s%s%s", path, TD_DIRSEP, "META"); @@ -302,7 +302,7 @@ int32_t remoteChkp_readMetaData(char* path, SSChkpMetaOnS3** pMeta) { SSChkpMetaOnS3* p = taosMemoryCalloc(1, sizeof(SSChkpMetaOnS3)); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } n = sscanf(buf, META_ON_S3_FORMATE, p->pCurrName, &p->currChkptId, p->pManifestName, &p->manifestChkptId, @@ -334,7 +334,7 @@ int32_t remoteChkp_validAndCvtMeta(char* path, SSChkpMetaOnS3* pMeta, int64_t ch char* src = taosMemoryCalloc(1, cap); char* dst = taosMemoryCalloc(1, cap); if (src == NULL || dst == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -400,7 +400,7 @@ int32_t remoteChkpGetDelFile(char* path, SArray* toDel) { char* p = taosMemoryCalloc(1, cap); if (p == NULL) { taosMemoryFree(pMeta); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(p, cap, "%s_%" PRId64 "", key, pMeta->currChkptId); @@ -494,7 +494,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId char* defaultTmp = taosMemoryCalloc(1, cap); if (defaultTmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(defaultPath, cap, "%s%s", defaultPath, "_tmp"); @@ -592,8 +592,7 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) { if (srcName == NULL || dstName == NULL) { taosMemoryFree(srcName); taosMemoryFree(dstName); - code = TSDB_CODE_OUT_OF_MEMORY; - return code; + return terrno; } // copy file to dst @@ -711,7 +710,7 @@ int32_t restoreCheckpointData(const char* path, const char* key, int64_t chkptId checkpointPath = taosMemoryCalloc(1, cap); checkpointRoot = taosMemoryCalloc(1, cap); if (prefixPath == NULL || defaultPath == NULL || checkpointPath == NULL || checkpointRoot == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -1343,7 +1342,7 @@ int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_ha rocksdb_column_family_handle_t** ppCf = taosMemoryCalloc(nCf, sizeof(rocksdb_column_family_handle_t*)); if (ppCf == NULL) { - TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception); + TAOS_CHECK_GOTO(terrno, NULL, _exception); } for (int i = 0; i < nCf; i++) { ppCf[i] = taosArrayGetP(pHandle, i); @@ -1410,7 +1409,7 @@ int32_t chkpPreBuildDir(char* path, int64_t chkpId, char** chkpDir, char** chkpI char* pChkpDir = taosMemoryCalloc(1, cap); char* pChkpIdDir = taosMemoryCalloc(1, cap); if (pChkpDir == NULL || pChkpIdDir == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -1587,7 +1586,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId) int32_t cap = len + 64; char* pDst = taosMemoryCalloc(1, cap); if (pDst == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; stError("failed to alloc memory to load extra info, dir:%s", pChkpIdDir); goto _EXIT; } @@ -1643,7 +1642,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) { int32_t cap = len + 64; char* pDst = taosMemoryCalloc(1, cap); if (pDst == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; stError("failed to alloc memory to add extra info, dir:%s", pChkpIdDir); goto _EXIT; } @@ -2119,7 +2118,7 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { if (vlen > 512) { dst = taosMemoryCalloc(1, vlen + 128); if (dst == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t dstCap = vlen + 128; int32_t compressedSize = LZ4_compress_default((char*)value, dst, vlen, dstCap); @@ -2134,7 +2133,7 @@ int32_t valueEncode(void* value, int32_t vlen, int64_t ttl, char** dest) { size_t size = sizeof(key.unixTimestamp) + sizeof(key.len) + sizeof(key.rawLen) + sizeof(key.compress) + key.len; char* p = taosMemoryCalloc(1, size); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _exception; } char* buf = p; @@ -2210,7 +2209,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) { } pOutput = taosMemoryCalloc(1, key.rawLen); if (pOutput == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXCEPT; } @@ -2530,7 +2529,7 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta int32_t code = 0; char* statePath = taosMemoryCalloc(1, strlen(path) + 128); if (statePath == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(statePath, "%s%s%s", path, TD_DIRSEP, key); @@ -2547,7 +2546,7 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta char* dbPath = taosMemoryCalloc(1, strlen(statePath) + 128); if (dbPath == NULL) { taosMemoryFree(statePath); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } sprintf(dbPath, "%s%s%s", statePath, TD_DIRSEP, "state"); @@ -2765,7 +2764,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { (void)taosReleaseRef(taskDbWrapperId, refId); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = @@ -2795,7 +2794,7 @@ int32_t taskDbGenChkpUploadData__s3(STaskDbWrapper* pDb, void* bkdChkpMgt, int64 char* temp = taosMemoryCalloc(1, cap); if (temp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(temp, cap, "%s%s%s%" PRId64, pDb->path, TD_DIRSEP, "tmp", chkpId); @@ -4555,7 +4554,7 @@ int32_t compareHashTableImpl(SHashObj* p1, SHashObj* p2, SArray* diff) { if (!isBkdDataMeta(name, len) && !taosHashGet(p1, name, len)) { char* fname = taosMemoryCalloc(1, len + 1); if (fname == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)strncpy(fname, name, len); if (taosArrayPush(diff, &fname) == NULL) { @@ -4716,7 +4715,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { char* fname = taosMemoryCalloc(1, len + 1); if (fname == NULL) { (void)taosThreadRwlockUnlock(&p->rwLock); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (void)strncpy(fname, name, len); @@ -4767,7 +4766,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { int32_t code = 0; SDbChkp* p = taosMemoryCalloc(1, sizeof(SDbChkp)); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -4784,7 +4783,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { p->len = strlen(path) + 128; p->buf = taosMemoryCalloc(1, p->len); if (p->buf == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _EXIT; } @@ -4861,7 +4860,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { char* buffer = taosMemoryCalloc(4, cap); if (buffer == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _ERROR; } @@ -5026,8 +5025,7 @@ int32_t bkdMgtCreate(char* path, SBkdMgt** mgt) { int32_t code = 0; SBkdMgt* p = taosMemoryCalloc(1, sizeof(SBkdMgt)); if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - return code; + return terrno; } p->pDbChkpTbl = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); @@ -5081,7 +5079,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* path = taosMemoryCalloc(1, cap); if (path == NULL) { (void)taosThreadRwlockUnlock(&bm->rwLock); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId); diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index 242e12f591..fa2bc65194 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -49,7 +49,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6 SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); if (pBlock == NULL) { taosFreeQitem(pChkpoint); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pBlock->info.type = STREAM_CHECKPOINT; @@ -704,7 +704,7 @@ static int32_t getCheckpointDataMeta(const char* id, const char* path, SArray* l char* filePath = taosMemoryCalloc(1, cap); if (filePath == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t nBytes = snprintf(filePath, cap, "%s%s%s", path, TD_DIRSEP, "META_TMP"); @@ -1296,7 +1296,7 @@ int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(buf, cap, "%s/%s", id, fname); diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 4926dcb69d..9bdb2348ae 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -143,7 +143,7 @@ static int32_t buildStreamRetrieveReq(SStreamTask* pTask, const SSDataBlock* pBl int32_t len = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock) + PAYLOAD_PREFIX_LEN; pRetrieve = taosMemoryCalloc(1, len); - if (pRetrieve == NULL) return TSDB_CODE_OUT_OF_MEMORY; + if (pRetrieve == NULL) return terrno; int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); pRetrieve->useconds = 0; diff --git a/source/libs/stream/src/streamHb.c b/source/libs/stream/src/streamHb.c index 1fd3106cff..4e35cb718c 100644 --- a/source/libs/stream/src/streamHb.c +++ b/source/libs/stream/src/streamHb.c @@ -314,7 +314,7 @@ int32_t createMetaHbInfo(int64_t* pRid, SMetaHbInfo** pRes) { *pRes = NULL; SMetaHbInfo* pInfo = taosMemoryCalloc(1, sizeof(SMetaHbInfo)); if (pInfo == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pInfo->hbTmr = taosTmrStart(streamMetaHbToMnode, META_HB_CHECK_INTERVAL, pRid, streamTimer); diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 36d0086ac6..bc902ccf29 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -357,13 +357,13 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, SStreamMeta* pMeta = taosMemoryCalloc(1, sizeof(SStreamMeta)); if (pMeta == NULL) { stError("vgId:%d failed to prepare stream meta, alloc size:%" PRIzu ", out of memory", vgId, sizeof(SStreamMeta)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t len = strlen(path) + 64; char* tpath = taosMemoryCalloc(1, len); if (tpath == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _err; } @@ -630,7 +630,7 @@ int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask) { buf = taosMemoryCalloc(1, len); if (buf == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER) { diff --git a/source/libs/stream/src/streamQueue.c b/source/libs/stream/src/streamQueue.c index 3765d0f9d3..cfa49fd92e 100644 --- a/source/libs/stream/src/streamQueue.c +++ b/source/libs/stream/src/streamQueue.c @@ -51,7 +51,7 @@ int32_t streamQueueOpen(int64_t cap, SStreamQueue** pQ) { SStreamQueue* pQueue = taosMemoryCalloc(1, sizeof(SStreamQueue)); if (pQueue == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } code = taosOpenQueue(&pQueue->pQueue); @@ -372,7 +372,7 @@ int32_t streamTaskPutTranstateIntoInputQ(SStreamTask* pTask) { pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); if (pBlock == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; goto _err; } diff --git a/source/libs/stream/src/streamSnapshot.c b/source/libs/stream/src/streamSnapshot.c index 0390422623..68ca60cbf1 100644 --- a/source/libs/stream/src/streamSnapshot.c +++ b/source/libs/stream/src/streamSnapshot.c @@ -347,7 +347,7 @@ int32_t streamBackendSnapInitFile(char* metaPath, SStreamTaskSnap* pSnap, SBacke char* path = taosMemoryCalloc(1, cap); if (path == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } nBytes = snprintf(path, cap, "%s%s%s%s%s%" PRId64 "", pSnap->dbPrefixPath, TD_DIRSEP, "checkpoints", TD_DIRSEP, @@ -492,7 +492,7 @@ int32_t streamSnapReaderOpen(void* pMeta, int64_t sver, int64_t chkpId, char* pa // impl later SStreamSnapReader* pReader = taosMemoryCalloc(1, sizeof(SStreamSnapReader)); if (pReader == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = streamSnapHandleInit(&pReader->handle, (char*)path, pMeta); @@ -632,7 +632,7 @@ int32_t streamSnapWriterOpen(void* pMeta, int64_t sver, int64_t ever, char* path int32_t code = 0; SStreamSnapWriter* pWriter = taosMemoryCalloc(1, sizeof(SStreamSnapWriter)); if (pWriter == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } SStreamSnapHandle* pHandle = &pWriter->handle; diff --git a/source/libs/stream/src/streamStartHistory.c b/source/libs/stream/src/streamStartHistory.c index a8c76d3f52..941b8f5145 100644 --- a/source/libs/stream/src/streamStartHistory.c +++ b/source/libs/stream/src/streamStartHistory.c @@ -432,7 +432,7 @@ int32_t createHTaskLaunchInfo(SStreamMeta* pMeta, STaskId* pTaskId, int64_t hStr SLaunchHTaskInfo** pInfo) { *pInfo = taosMemoryCalloc(1, sizeof(SLaunchHTaskInfo)); if ((*pInfo) == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } (*pInfo)->id.streamId = pTaskId->streamId; diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index c6ecaf9c2b..e6754d7bfd 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -483,7 +483,7 @@ int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal } *pVal = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN); if (!(*pVal)) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 355a586e52..5d6cf39e40 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -111,7 +111,7 @@ int32_t tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool if (pTask == NULL) { stError("s-task:0x%" PRIx64 " failed malloc new stream task, size:%d, code:%s", streamId, (int32_t)sizeof(SStreamTask), tstrerror(terrno)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pTask->ver = SSTREAM_TASK_VER; @@ -489,7 +489,7 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i if (pOutputInfo->pTokenBucket == NULL) { stError("s-task:%s failed to prepare the tokenBucket, code:%s", pTask->id.idStr, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } // 2MiB per second for sink task @@ -1196,7 +1196,7 @@ void streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t c int32_t streamTaskCreateActiveChkptInfo(SActiveCheckpointInfo** pRes) { SActiveCheckpointInfo* pInfo = taosMemoryCalloc(1, sizeof(SActiveCheckpointInfo)); if (pInfo == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } int32_t code = taosThreadMutexInit(&pInfo->lock, NULL); diff --git a/source/libs/stream/src/streamTaskSm.c b/source/libs/stream/src/streamTaskSm.c index 968a737ec7..c4ab48827c 100644 --- a/source/libs/stream/src/streamTaskSm.c +++ b/source/libs/stream/src/streamTaskSm.c @@ -286,7 +286,7 @@ int32_t streamCreateStateMachine(SStreamTask* pTask) { if (pSM == NULL) { stError("s-task:%s failed to create task stateMachine, size:%d, code:%s", id, (int32_t)sizeof(SStreamTaskSM), tstrerror(terrno)); - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } pSM->pTask = pTask; diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index 58ed50da65..40de393570 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -150,7 +150,7 @@ int32_t updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, b int32_t lino = 0; SUpdateInfo* pInfo = taosMemoryCalloc(1, sizeof(SUpdateInfo)); if (pInfo == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } pInfo->pTsBuckets = NULL; @@ -203,12 +203,12 @@ int32_t updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, b pInfo->pkColType = pkType; pInfo->pKeyBuff = taosMemoryCalloc(1, sizeof(TSKEY) + sizeof(int64_t) + pkLen); if (!pInfo->pKeyBuff) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } pInfo->pValueBuff = taosMemoryCalloc(1, sizeof(TSKEY) + pkLen); if (!pInfo->pValueBuff) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } if (pkLen != 0) { diff --git a/source/libs/stream/src/tstreamFileState.c b/source/libs/stream/src/tstreamFileState.c index cbaaec0964..aa237efd04 100644 --- a/source/libs/stream/src/tstreamFileState.c +++ b/source/libs/stream/src/tstreamFileState.c @@ -626,7 +626,7 @@ int32_t getRowBuffByPos(SStreamFileState* pFileState, SRowBuffPos* pPos, void** if (pFileState->curRowCount < pFileState->maxRowCount) { pPos->pRowBuff = taosMemoryCalloc(1, pFileState->rowSize); if (!pPos->pRowBuff) { - code = TSDB_CODE_OUT_OF_MEMORY; + code = terrno; QUERY_CHECK_CODE(code, lino, _end); } pFileState->curRowCount++; From fdd2bbf5fcd68699f4802607c9a691f9d8455333 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 11 Sep 2024 10:10:17 +0800 Subject: [PATCH 27/32] fix(stream): remove delay rsp for dispatch --- source/libs/stream/src/streamDispatch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 4926dcb69d..e71f6e748a 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -1486,8 +1486,6 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i int32_t numOfFailed = 0; bool triggerDispatchRsp = false; - taosMsleep(500); - // we only set the dispatch msg info for current checkpoint trans streamMutexLock(&pTask->lock); triggerDispatchRsp = (streamTaskGetStatus(pTask).state == TASK_STATUS__CK) && From 6b1e12872f422fedb048acf857d73717d6102af4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 11 Sep 2024 10:19:37 +0800 Subject: [PATCH 28/32] test: update test cases. --- tests/system-test/1-insert/database_pre_suf.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/system-test/1-insert/database_pre_suf.py b/tests/system-test/1-insert/database_pre_suf.py index 29a6e27525..bc266671a6 100755 --- a/tests/system-test/1-insert/database_pre_suf.py +++ b/tests/system-test/1-insert/database_pre_suf.py @@ -284,7 +284,6 @@ class TDTestCase: fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) - time.sleep(1) tdSql.query("select count(*) from stable_1;") tdSql.checkData(0,0,10*num_random*n) tdSql.query("select count(*) from hn_table_1_r;") @@ -292,10 +291,6 @@ class TDTestCase: # stream data check tdCom.check_stream_task_status(stream_name,vgroups,90) - print("sleep 30s") - time.sleep(30) - - print("check--------------------------------------------------------------------------") tdSql.query("select startts,wend,max_int from stream_max_stable_1 ;") tdSql.checkRows(20) tdSql.query("select sum(max_int) from stream_max_stable_1 ;") From 064a2715825e6e815ca5124433bc7f15a789391a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 11 Sep 2024 10:21:38 +0800 Subject: [PATCH 29/32] Update streamDispatch.c --- source/libs/stream/src/streamDispatch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 4926dcb69d..e71f6e748a 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -1486,8 +1486,6 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i int32_t numOfFailed = 0; bool triggerDispatchRsp = false; - taosMsleep(500); - // we only set the dispatch msg info for current checkpoint trans streamMutexLock(&pTask->lock); triggerDispatchRsp = (streamTaskGetStatus(pTask).state == TASK_STATUS__CK) && From 9b3cd3fb8dc023198052b9c45c496bcb5afb8ef8 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 11 Sep 2024 10:56:40 +0800 Subject: [PATCH 30/32] enh: error code handle --- source/dnode/vnode/src/inc/tsdb.h | 6 +-- source/dnode/vnode/src/tsdb/tsdbCommit2.c | 4 +- source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c | 4 +- source/dnode/vnode/src/tsdb/tsdbDataFileRW.c | 8 +-- source/dnode/vnode/src/tsdb/tsdbFS2.c | 24 ++++----- source/dnode/vnode/src/tsdb/tsdbFS2.h | 6 +-- source/dnode/vnode/src/tsdb/tsdbFSet2.c | 53 ++++++++++++++----- source/dnode/vnode/src/tsdb/tsdbFile2.c | 4 +- source/dnode/vnode/src/tsdb/tsdbIter.c | 5 +- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 6 ++- source/dnode/vnode/src/tsdb/tsdbMerge.c | 11 ++-- source/dnode/vnode/src/tsdb/tsdbOpen.c | 16 +++--- .../dnode/vnode/src/tsdb/tsdbReaderWriter.c | 9 ++-- source/dnode/vnode/src/tsdb/tsdbRetention.c | 5 +- source/dnode/vnode/src/tsdb/tsdbSnapInfo.c | 24 +++++++-- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 2 +- source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c | 11 ++-- source/dnode/vnode/src/tsdb/tsdbSttFileRW.c | 6 ++- source/dnode/vnode/src/tsdb/tsdbUpgrade.c | 2 +- source/dnode/vnode/src/tsdb/tsdbUtil.c | 2 +- 20 files changed, 133 insertions(+), 75 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 3110d34bad..7c68d31f84 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -280,7 +280,7 @@ void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t); // tsdbReaderWriter.c ============================================================================================== // SDataFReader int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet); -int32_t tsdbDataFReaderClose(SDataFReader **ppReader); +void tsdbDataFReaderClose(SDataFReader **ppReader); int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx); int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mDataBlk); int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk); @@ -678,8 +678,8 @@ typedef TARRAY2(STFileSet *) TFileSetArray; typedef struct STFileSetRange STFileSetRange; typedef TARRAY2(STFileSetRange *) TFileSetRangeArray; // disjoint ranges -int32_t tsdbTFileSetRangeClear(STFileSetRange **fsr); -void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr); +void tsdbTFileSetRangeClear(STFileSetRange **fsr); +void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr); // fset partition enum { diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index a768716413..d9d951d591 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -710,7 +710,7 @@ int32_t tsdbCommitCommit(STsdb *tsdb) { for (int32_t i = 0; i < taosArrayGetSize(tsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(tsdb->commitInfo->arr, i); if (info->fset) { - TAOS_UNUSED(tsdbFinishTaskOnFileSet(tsdb, info->fid)); + tsdbFinishTaskOnFileSet(tsdb, info->fid); } } @@ -741,7 +741,7 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) { for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i); if (info->fset) { - TAOS_UNUSED(tsdbFinishTaskOnFileSet(pTsdb, info->fid)); + tsdbFinishTaskOnFileSet(pTsdb, info->fid); } } (void)taosThreadMutexUnlock(&pTsdb->mutex); diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c index 842730cb71..4ab9d729b6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c @@ -117,7 +117,7 @@ static int32_t tsdbDataFileRAWWriterCloseAbort(SDataFileRAWWriter *writer) { return 0; } -static int32_t tsdbDataFileRAWWriterDoClose(SDataFileRAWWriter *writer) { return 0; } +static void tsdbDataFileRAWWriterDoClose(SDataFileRAWWriter *writer) { return; } static int32_t tsdbDataFileRAWWriterCloseCommit(SDataFileRAWWriter *writer, TFileOpArray *opArr) { int32_t code = 0; @@ -200,7 +200,7 @@ int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFil } else { TAOS_CHECK_GOTO(tsdbDataFileRAWWriterCloseCommit(writer[0], opArr), &lino, _exit); } - (void)tsdbDataFileRAWWriterDoClose(writer[0]); + tsdbDataFileRAWWriterDoClose(writer[0]); } taosMemoryFree(writer[0]); writer[0] = NULL; diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c index 2d54d33105..e965221920 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c @@ -847,7 +847,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr for (int i = 0; i < brinBlock->numOfRecords; i++) { SBrinRecord record; - (void)tBrinBlockGet(brinBlock, i, &record); + TAOS_CHECK_RETURN(tBrinBlockGet(brinBlock, i, &record)); if (i == 0) { brinBlk.minTbid.suid = record.suid; brinBlk.minTbid.uid = record.uid; @@ -1160,7 +1160,8 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) { SBrinRecord record; - (void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); + code = tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); + TSDB_CHECK_CODE(code, lino, _exit); if (record.uid != writer->ctx->tbid->uid) { writer->ctx->tbHasOldData = false; goto _exit; @@ -1170,7 +1171,8 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST goto _exit; } else { SBrinRecord record[1]; - (void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); + code = tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); + TSDB_CHECK_CODE(code, lino, _exit); if (tsdbRowKeyCmprNullAsLargest(key, &record->lastKey) > 0) { // key > record->lastKey if (writer->blockData->nRow > 0) { TAOS_CHECK_GOTO(tsdbDataFileDoWriteBlockData(writer, writer->blockData), &lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 3684544f14..d5dff7d5b7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -747,8 +747,8 @@ _exit: return code; } -static void tsdbFSSetBlockCommit(STFileSet *fset, bool block); -extern int32_t tsdbStopAllCompTask(STsdb *tsdb); +static void tsdbFSSetBlockCommit(STFileSet *fset, bool block); +extern void tsdbStopAllCompTask(STsdb *tsdb); int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { STFileSystem *fs = pTsdb->pFS; @@ -783,12 +783,15 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { // destroy all channels for (int32_t i = 0; i < taosArrayGetSize(channelArray); i++) { SVAChannelID *channel = taosArrayGet(channelArray, i); - (void)vnodeAChannelDestroy(channel, true); + int32_t code = vnodeAChannelDestroy(channel, true); + if (code) { + tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code)); + } } taosArrayDestroy(channelArray); #ifdef TD_ENTERPRISE - (void)tsdbStopAllCompTask(pTsdb); + tsdbStopAllCompTask(pTsdb); #endif return 0; } @@ -802,7 +805,7 @@ void tsdbEnableBgTask(STsdb *pTsdb) { void tsdbCloseFS(STFileSystem **fs) { if (fs[0] == NULL) return; - (void)tsdbDisableAndCancelAllBgTask((*fs)->tsdb); + TAOS_UNUSED(tsdbDisableAndCancelAllBgTask((*fs)->tsdb)); close_file_system(fs[0]); destroy_fs(fs); return; @@ -983,13 +986,12 @@ int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { return code; } -int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr) { +void tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr) { if (fsetArr[0]) { TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear); taosMemoryFree(fsetArr[0]); fsetArr[0] = NULL; } - return 0; } int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { @@ -1101,7 +1103,7 @@ _out: return code; } -int32_t tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr) { return tsdbFSDestroyCopySnapshot(fsetArr); } +void tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr) { tsdbFSDestroyCopySnapshot(fsetArr); } int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ever, TFileSetRangeArray *pRanges, TFileSetRangeArray **fsrArr) { @@ -1157,7 +1159,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev (void)taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { - (void)tsdbTFileSetRangeClear(&fsr1); + tsdbTFileSetRangeClear(&fsr1); TARRAY2_DESTROY(fsrArr[0], tsdbTFileSetRangeClear); fsrArr[0] = NULL; } @@ -1195,7 +1197,7 @@ void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) { } } -int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) { +void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) { int16_t sttTrigger = tsdb->pVnode->config.sttTrigger; if (sttTrigger == 1) { STFileSet *fset = NULL; @@ -1208,6 +1210,4 @@ int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) { tsdbInfo("vgId:%d finish task on file set:%d", TD_VID(tsdb->pVnode), fid); } } - - return 0; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.h b/source/dnode/vnode/src/tsdb/tsdbFS2.h index 500a214124..9993c1e33d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.h @@ -41,14 +41,14 @@ int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback); void tsdbCloseFS(STFileSystem **fs); // snapshot int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr); -int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr); +void tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr); int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr); int32_t tsdbFSCreateRefSnapshotWithoutLock(STFileSystem *fs, TFileSetArray **fsetArr); void tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr); int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pExclude, TFileSetArray **fsetArr, TFileOpArray *fopArr); -int32_t tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr); +void tsdbFSDestroyCopyRangedSnapshot(TFileSetArray **fsetArr); int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ever, TFileSetRangeArray *pRanges, TFileSetRangeArray **fsrArr); void tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr); @@ -62,7 +62,7 @@ int32_t tsdbFSEditAbort(STFileSystem *fs); void tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset); int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid); void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset); -int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid); +void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid); // utils int32_t save_fs(const TFileSetArray *arr, const char *fname); void current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype); diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.c b/source/dnode/vnode/src/tsdb/tsdbFSet2.c index 5a07994678..fc78fec2ea 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.c @@ -64,9 +64,16 @@ static int32_t tsdbSttLvlInitRef(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lv STFileObj *fobj1; TARRAY2_FOREACH(lvl1->fobjArr, fobj1) { - (void)tsdbTFileObjRef(fobj1); + code = tsdbTFileObjRef(fobj1); + if (code) { + tsdbSttLvlClear(lvl); + return code; + } code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj1); - if (code) return code; + if (code) { + tsdbSttLvlClear(lvl); + return code; + } } return 0; } @@ -99,7 +106,12 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64 return 0; } -static void tsdbSttLvlRemoveFObj(void *data) { (void)tsdbTFileObjRemove(*(STFileObj **)data); } +static void tsdbSttLvlRemoveFObj(void *data) { + int32_t code = tsdbTFileObjRemove(*(STFileObj **)data); + if (code) { + tsdbError("failed to remove file obj, code:%d, error:%s", code, tstrerror(code)); + } +} static void tsdbSttLvlRemove(SSttLvl **lvl) { TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlRemoveFObj); taosMemoryFree(lvl[0]); @@ -348,7 +360,8 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) { int32_t idx = TARRAY2_SEARCH_IDX(lvl->fobjArr, &tfobjp, tsdbTFileObjCmpr, TD_EQ); TARRAY2_REMOVE(lvl->fobjArr, idx, tsdbSttLvlClearFObj); } else { - (void)tsdbTFileObjUnref(fset->farr[op->of.type]); + code = tsdbTFileObjUnref(fset->farr[op->of.type]); + if (code) return code; fset->farr[op->of.type] = NULL; } } else { @@ -391,9 +404,11 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f } } else { if (fobj1->f->cid != fobj2->f->cid) { - (void)tsdbTFileObjRemove(fobj2); + code = tsdbTFileObjRemove(fobj2); + if (code) return code; } else { - (void)tsdbTFileObjRemoveUpdateLC(fobj2); + code = tsdbTFileObjRemoveUpdateLC(fobj2); + if (code) return code; } code = tsdbTFileObjInit(pTsdb, fobj1->f, &fset2->farr[ftype]); if (code) return code; @@ -404,7 +419,8 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f if (code) return code; } else { // remove the file - (void)tsdbTFileObjRemove(fobj2); + code = tsdbTFileObjRemove(fobj2); + if (code) return code; fset2->farr[ftype] = NULL; } } @@ -570,7 +586,11 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if (fset1->farr[ftype] == NULL) continue; - (void)tsdbTFileObjRef(fset1->farr[ftype]); + code = tsdbTFileObjRef(fset1->farr[ftype]); + if (code) { + tsdbTFileSetClear(fset); + return code; + } fset[0]->farr[ftype] = fset1->farr[ftype]; } @@ -595,13 +615,13 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs return 0; } -int32_t tsdbTFileSetRangeClear(STFileSetRange **fsr) { - if (!fsr[0]) return 0; +void tsdbTFileSetRangeClear(STFileSetRange **fsr) { + if (!fsr[0]) return; tsdbTFileSetClear(&fsr[0]->fset); taosMemoryFree(fsr[0]); fsr[0] = NULL; - return 0; + return; } void tsdbTFileSetRangeArrayDestroy(TFileSetRangeArray **ppArr) { @@ -616,7 +636,11 @@ void tsdbTFileSetClear(STFileSet **fset) { if (fset && *fset) { for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if ((*fset)->farr[ftype] == NULL) continue; - (void)tsdbTFileObjUnref((*fset)->farr[ftype]); + int32_t code = tsdbTFileObjUnref((*fset)->farr[ftype]); + if (code) { + tsdbError("failed to unref file, fid:%d, ftype:%d", (*fset)->fid, ftype); + } + (*fset)->farr[ftype] = NULL; } TARRAY2_DESTROY((*fset)->lvlArr, tsdbSttLvlClear); @@ -632,7 +656,10 @@ void tsdbTFileSetRemove(STFileSet *fset) { for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if (fset->farr[ftype] != NULL) { - (void)tsdbTFileObjRemove(fset->farr[ftype]); + int32_t code = tsdbTFileObjRemove(fset->farr[ftype]); + if (code) { + tsdbError("failed to remove file, fid:%d, ftype:%d", fset->fid, ftype); + } fset->farr[ftype] = NULL; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbFile2.c b/source/dnode/vnode/src/tsdb/tsdbFile2.c index 5c832dccda..da78d67db3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile2.c @@ -249,8 +249,8 @@ int32_t tsdbTFileObjRef(STFileObj *fobj) { (void)taosThreadMutexLock(&fobj->mutex); if (fobj->ref <= 0 || fobj->state != TSDB_FSTATE_LIVE) { - (void)taosThreadMutexUnlock(&fobj->mutex); tsdbError("file %s, fobj:%p ref %d", fobj->fname, fobj, fobj->ref); + (void)taosThreadMutexUnlock(&fobj->mutex); return TSDB_CODE_FAILED; } @@ -335,8 +335,8 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) { int32_t tsdbTFileObjRemove(STFileObj *fobj) { (void)taosThreadMutexLock(&fobj->mutex); if (fobj->state != TSDB_FSTATE_LIVE || fobj->ref <= 0) { - (void)taosThreadMutexUnlock(&fobj->mutex); tsdbError("file %s, fobj:%p ref %d", fobj->fname, fobj, fobj->ref); + (void)taosThreadMutexUnlock(&fobj->mutex); return TSDB_CODE_FAILED; } fobj->state = TSDB_FSTATE_DEAD; diff --git a/source/dnode/vnode/src/tsdb/tsdbIter.c b/source/dnode/vnode/src/tsdb/tsdbIter.c index e4218ea4fc..4c5a803f22 100644 --- a/source/dnode/vnode/src/tsdb/tsdbIter.c +++ b/source/dnode/vnode/src/tsdb/tsdbIter.c @@ -153,7 +153,8 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) { for (; iter->dataData->brinBlockIdx < iter->dataData->brinBlock->numOfRecords; iter->dataData->brinBlockIdx++) { SBrinRecord record[1]; - (void)tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record); + code = tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record); + if (code) return code; if (iter->filterByVersion && (record->maxVer < iter->range[0] || record->minVer > iter->range[1])) { continue; @@ -224,7 +225,7 @@ static int32_t tsdbMemTableIterNext(STsdbIter *iter, const TABLEID *tbid) { iter->row->row = row[0]; - (void)tsdbTbDataIterNext(iter->memtData->tbIter); + TAOS_UNUSED(tsdbTbDataIterNext(iter->memtData->tbIter)); goto _exit; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 11fcb08d89..8b4cdf9367 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -403,7 +403,11 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid pMemTable->aBucket[idx] = pTbData; pMemTable->nTbData++; - (void)tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn); + if (tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn) == NULL) { + taosWUnLockLatch(&pMemTable->latch); + code = TSDB_CODE_INTERNAL_ERROR; + goto _exit; + } taosWUnLockLatch(&pMemTable->latch); diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index a4965d49eb..61a82d828e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -77,9 +77,8 @@ static int32_t tsdbMergerClose(SMerger *merger) { return 0; } -static int32_t tsdbMergeFileSetEndCloseReader(SMerger *merger) { +static void tsdbMergeFileSetEndCloseReader(SMerger *merger) { TARRAY2_CLEAR(merger->sttReaderArr, tsdbSttFileReaderClose); - return 0; } static int32_t tsdbMergeFileSetBeginOpenReader(SMerger *merger) { @@ -219,7 +218,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(merger->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); - (void)tsdbMergeFileSetEndCloseReader(merger); + tsdbMergeFileSetEndCloseReader(merger); } return code; } @@ -271,7 +270,9 @@ static int32_t tsdbMergeFileSetBeginOpenWriter(SMerger *merger) { TAOS_CHECK_GOTO(tfsAllocDisk(merger->tsdb->pVnode->pTfs, level, &did), &lino, _exit); - (void)tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did); + code = tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did); + TSDB_CHECK_CODE(code, lino, _exit); + SFSetWriterConfig config = { .tsdb = merger->tsdb, .toSttOnly = true, @@ -354,7 +355,7 @@ static int32_t tsdbMergeFileSetEnd(SMerger *merger) { TAOS_CHECK_GOTO(tsdbMergeFileSetEndCloseIter(merger), &lino, _exit); - TAOS_CHECK_GOTO(tsdbMergeFileSetEndCloseReader(merger), &lino, _exit); + tsdbMergeFileSetEndCloseReader(merger); // edit file system TAOS_CHECK_GOTO(tsdbFSEditBegin(merger->tsdb->pFS, merger->fopArr, TSDB_FEDIT_MERGE), &lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 09d5cdbdb3..1923c8bafc 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -17,7 +17,7 @@ #include "tsdbFS2.h" extern int32_t tsdbOpenCompMonitor(STsdb *tsdb); -extern int32_t tsdbCloseCompMonitor(STsdb *tsdb); +extern void tsdbCloseCompMonitor(STsdb *tsdb); void tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) { STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg; @@ -65,19 +65,23 @@ int32_t tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg * // create dir if (pVnode->pTfs) { - (void)tfsMkdir(pVnode->pTfs, pTsdb->path); + code = tfsMkdir(pVnode->pTfs, pTsdb->path); + TSDB_CHECK_CODE(code, lino, _exit); } else { - (void)taosMkDir(pTsdb->path); + code = taosMkDir(pTsdb->path); + TSDB_CHECK_CODE(code, lino, _exit); } // open tsdb - TAOS_CHECK_GOTO(tsdbOpenFS(pTsdb, &pTsdb->pFS, rollback), &lino, _exit); + code = tsdbOpenFS(pTsdb, &pTsdb->pFS, rollback); + TSDB_CHECK_CODE(code, lino, _exit); if (pTsdb->pFS->fsstate == TSDB_FS_STATE_INCOMPLETE && force == false) { TAOS_CHECK_GOTO(TSDB_CODE_NEED_RETRY, &lino, _exit); } - TAOS_CHECK_GOTO(tsdbOpenCache(pTsdb), &lino, _exit); + code = tsdbOpenCache(pTsdb); + TSDB_CHECK_CODE(code, lino, _exit); #ifdef TD_ENTERPRISE TAOS_CHECK_GOTO(tsdbOpenCompMonitor(pTsdb), &lino, _exit); @@ -112,7 +116,7 @@ int32_t tsdbClose(STsdb **pTsdb) { tsdbCloseFS(&(*pTsdb)->pFS); tsdbCloseCache(*pTsdb); #ifdef TD_ENTERPRISE - (void)tsdbCloseCompMonitor(*pTsdb); + tsdbCloseCompMonitor(*pTsdb); #endif (void)taosThreadMutexDestroy(&(*pTsdb)->mutex); taosMemoryFreeClear(*pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 1112dcaaae..44b115d1db 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -160,7 +160,8 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit); } - (void)taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage); + code = taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage); + TSDB_CHECK_CODE(code, lino, _exit); if (encryptAlgorithm == DND_CA_SM4) { // if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){ @@ -635,9 +636,8 @@ _exit: return code; } -int32_t tsdbDataFReaderClose(SDataFReader **ppReader) { - int32_t code = 0; - if (*ppReader == NULL) return code; +void tsdbDataFReaderClose(SDataFReader **ppReader) { + if (*ppReader == NULL) return; // head tsdbCloseFile(&(*ppReader)->pHeadFD); @@ -660,7 +660,6 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) { } taosMemoryFree(*ppReader); *ppReader = NULL; - return code; } int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) { diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 2409b390c9..dee412114b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -255,7 +255,8 @@ static int32_t tsdbDoRetention(SRTNer *rtner) { SDiskID did; TAOS_CHECK_GOTO(tfsAllocDisk(rtner->tsdb->pVnode->pTfs, expLevel, &did), &lino, _exit); - (void)tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did); + code = tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did); + TSDB_CHECK_CODE(code, lino, _exit); // data for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX && (fobj = fset->farr[ftype], 1); ++ftype) { @@ -337,7 +338,7 @@ static int32_t tsdbRetention(void *arg) { _exit: if (rtner.fset) { (void)taosThreadMutexLock(&pTsdb->mutex); - (void)tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid); + tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid); (void)taosThreadMutexUnlock(&pTsdb->mutex); } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c index d531179f97..53bace9941 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c @@ -102,7 +102,11 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition** } count++; SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer}; - (void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn); + code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn); + if (code) { + tsdbFSetPartitionClear(&p); + return code; + } } typ = TSDB_FSET_RANGE_TYP_STT; @@ -120,12 +124,20 @@ static int32_t tsdbTFileSetToFSetPartition(STFileSet* fset, STsdbFSetPartition** } count++; SVersionRange vr = {.minVer = f->minVer, .maxVer = f->maxVer}; - (void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn); + code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn); + if (code) { + tsdbFSetPartitionClear(&p); + return code; + } } } if (corrupt && count == 0) { SVersionRange vr = {.minVer = VERSION_MIN, .maxVer = fset->maxVerValid}; - (void)TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn); + code = TARRAY2_SORT_INSERT(&p->verRanges[typ], vr, tVersionRangeCmprFn); + if (code) { + tsdbFSetPartitionClear(&p); + return code; + } } ppSP[0] = p; return 0; @@ -182,7 +194,11 @@ int32_t tsdbFSetPartListToRangeDiff(STsdbFSetPartList* pList, TFileSetRangeArray r->sver = maxVerValid + 1; r->ever = VERSION_MAX; tsdbDebug("range diff fid:%" PRId64 ", sver:%" PRId64 ", ever:%" PRId64, part->fid, r->sver, r->ever); - (void)TARRAY2_SORT_INSERT(pDiff, r, tsdbTFileSetRangeCmprFn); + code = TARRAY2_SORT_INSERT(pDiff, r, tsdbTFileSetRangeCmprFn); + if (code) { + taosMemoryFree(r); + goto _err; + } } ppRanges[0] = pDiff; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 6b9a959157..15930353bf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -1127,7 +1127,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) { tsdbDataFileReaderClose(&writer[0]->ctx->dataReader); TARRAY2_DESTROY(writer[0]->fopArr, NULL); - TAOS_UNUSED(tsdbFSDestroyCopyRangedSnapshot(&writer[0]->fsetArr)); + tsdbFSDestroyCopyRangedSnapshot(&writer[0]->fsetArr); for (int32_t i = 0; i < ARRAY_SIZE(writer[0]->buffers); ++i) { tBufferDestroy(writer[0]->buffers + i); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c index f86e548321..609e2a80e9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c @@ -157,10 +157,9 @@ static int32_t tsdbSnapRAWReadFileSetOpenIter(STsdbSnapRAWReader* reader) { return 0; } -static int32_t tsdbSnapRAWReadFileSetCloseIter(STsdbSnapRAWReader* reader) { +static void tsdbSnapRAWReadFileSetCloseIter(STsdbSnapRAWReader* reader) { reader->dataIter->count = 0; reader->dataIter->idx = 0; - return 0; } static int64_t tsdbSnapRAWReadPeek(SDataFileRAWReader* reader) { @@ -260,7 +259,7 @@ _exit: } static int32_t tsdbSnapRAWReadEnd(STsdbSnapRAWReader* reader) { - (void)tsdbSnapRAWReadFileSetCloseIter(reader); + tsdbSnapRAWReadFileSetCloseIter(reader); tsdbSnapRAWReadFileSetCloseReader(reader); reader->ctx->fset = NULL; return 0; @@ -410,7 +409,9 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec()); code = tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did); TSDB_CHECK_CODE(code, lino, _exit); - (void)tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); + + code = tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbSnapRAWWriteFileSetOpenWriter(writer); TSDB_CHECK_CODE(code, lino, _exit); @@ -489,7 +490,7 @@ int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** writer, int8_t rollback) { } TARRAY2_DESTROY(writer[0]->fopArr, NULL); - (void)tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr); + tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr); taosMemoryFree(writer[0]); writer[0] = NULL; diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index 3d9ea4ef69..bf941e0383 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -590,11 +590,13 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) { statisBlk.cmprAlg = writer->config->cmprAlg; statisBlk.numOfPKs = statisBlock->numOfPKs; - (void)tStatisBlockGet(statisBlock, 0, &record); + code = tStatisBlockGet(statisBlock, 0, &record); + TSDB_CHECK_CODE(code, lino, _exit); statisBlk.minTbid.suid = record.suid; statisBlk.minTbid.uid = record.uid; - (void)tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record); + code = tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record); + TSDB_CHECK_CODE(code, lino, _exit); statisBlk.maxTbid.suid = record.suid; statisBlk.maxTbid.uid = record.uid; diff --git a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c index 6d95ebad28..b980bc5f25 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c +++ b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c @@ -356,7 +356,7 @@ static int32_t tsdbUpgradeFileSet(STsdb *tsdb, SDFileSet *pDFileSet, TFileSetArr TAOS_CHECK_GOTO(tsdbUpgradeStt(tsdb, pDFileSet, reader, fset), &lino, _exit); } - (void)tsdbDataFReaderClose(&reader); + tsdbDataFReaderClose(&reader); TAOS_CHECK_GOTO(TARRAY2_APPEND(fileSetArray, fset), &lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 8820a026e9..63141db729 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -106,7 +106,7 @@ _exit: #endif void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) { - (void)tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem); + TAOS_UNUSED(tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem)); } #ifdef BUILD_NO_CALL From 82adb5347878ec8a5d38727634116a5fbb27bbc9 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 11 Sep 2024 13:31:28 +0800 Subject: [PATCH 31/32] fix: correct block check --- source/common/src/tdatablock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index dee9ec2c0c..bd169914df 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -3397,13 +3397,14 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) { } void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) { - return; + //return; if (NULL == pDataBlock || pDataBlock->info.rows == 0) { return; } -#define BLOCK_DATA_CHECK_TRESSA(o) ; +//#define BLOCK_DATA_CHECK_TRESSA(o) ; +#define BLOCK_DATA_CHECK_TRESSA(o) ASSERT(o) BLOCK_DATA_CHECK_TRESSA(pDataBlock->info.rows > 0); @@ -3439,6 +3440,8 @@ void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) { BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] < pCol->varmeta.length); if (pCol->reassigned) { BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] >= 0); + } else if (0 == r) { + nextPos = pCol->varmeta.offset[r]; } else { BLOCK_DATA_CHECK_TRESSA(pCol->varmeta.offset[r] == nextPos); } From aecdabe9a4ad0cb9938292b27598f727543fdaeb Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 11 Sep 2024 13:38:24 +0800 Subject: [PATCH 32/32] fix: remove block check --- source/common/src/tdatablock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index bd169914df..08f6842c4b 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -3397,14 +3397,14 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo) { } void blockDataCheck(const SSDataBlock* pDataBlock, bool forceChk) { - //return; + return; if (NULL == pDataBlock || pDataBlock->info.rows == 0) { return; } -//#define BLOCK_DATA_CHECK_TRESSA(o) ; -#define BLOCK_DATA_CHECK_TRESSA(o) ASSERT(o) +#define BLOCK_DATA_CHECK_TRESSA(o) ; +//#define BLOCK_DATA_CHECK_TRESSA(o) A S S E R T(o) BLOCK_DATA_CHECK_TRESSA(pDataBlock->info.rows > 0);