diff --git a/docs/examples/c/multi_bind_example.c b/docs/examples/c/multi_bind_example.c index 3d0bd3ccef..0134899a1d 100644 --- a/docs/examples/c/multi_bind_example.c +++ b/docs/examples/c/multi_bind_example.c @@ -33,7 +33,7 @@ void executeSQL(TAOS *taos, const char *sql) { void checkErrorCode(TAOS_STMT *stmt, int code, const char *msg) { if (code != 0) { printf("%s. error: %s\n", msg, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); exit(EXIT_FAILURE); } } @@ -123,7 +123,7 @@ void insertData(TAOS *taos) { int affectedRows = taos_stmt_affected_rows(stmt); printf("successfully inserted %d rows\n", affectedRows); // close - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); } int main() { diff --git a/docs/examples/c/stmt_example.c b/docs/examples/c/stmt_example.c index 290a6bee66..3b9efe49d7 100644 --- a/docs/examples/c/stmt_example.c +++ b/docs/examples/c/stmt_example.c @@ -33,7 +33,7 @@ void executeSQL(TAOS *taos, const char *sql) { void checkErrorCode(TAOS_STMT *stmt, int code, const char* msg) { if (code != 0) { printf("%s. error: %s\n", msg, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); exit(EXIT_FAILURE); } } @@ -119,7 +119,7 @@ void insertData(TAOS *taos) { int affectedRows = taos_stmt_affected_rows(stmt); printf("successfully inserted %d rows\n", affectedRows); // close - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); } int main() { diff --git a/docs/examples/c/subscribe_demo.c b/docs/examples/c/subscribe_demo.c deleted file mode 100644 index 2fe62c24eb..0000000000 --- a/docs/examples/c/subscribe_demo.c +++ /dev/null @@ -1,66 +0,0 @@ -// A simple demo for asynchronous subscription. -// compile with: -// gcc -o subscribe_demo subscribe_demo.c -ltaos - -#include -#include -#include -#include - -int nTotalRows; - -/** - * @brief callback function of subscription. - * - * @param tsub - * @param res - * @param param. the additional parameter passed to taos_subscribe - * @param code. error code - */ -void subscribe_callback(TAOS_SUB* tsub, TAOS_RES* res, void* param, int code) { - if (code != 0) { - printf("error: %d\n", code); - exit(EXIT_FAILURE); - } - - TAOS_ROW row = NULL; - int num_fields = taos_num_fields(res); - TAOS_FIELD* fields = taos_fetch_fields(res); - int nRows = 0; - - while ((row = taos_fetch_row(res))) { - char buf[4096] = {0}; - taos_print_row(buf, row, fields, num_fields); - puts(buf); - nRows++; - } - - nTotalRows += nRows; - printf("%d rows consumed.\n", nRows); -} - -int main() { - TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 6030); - if (taos == NULL) { - printf("failed to connect to server\n"); - exit(EXIT_FAILURE); - } - - int restart = 1; // if the topic already exists, where to subscribe from the begin. - const char* topic = "topic-meter-current-bg-10"; - const char* sql = "select * from power.meters where current > 10"; - void* param = NULL; // additional parameter. - int interval = 2000; // consumption interval in microseconds. - TAOS_SUB* tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, NULL, interval); - - // wait for insert from others process. you can open TDengine CLI to insert some records for test. - - getchar(); // press Enter to stop - - printf("total rows consumed: %d\n", nTotalRows); - int keep = 0; // whether to keep subscribe process - taos_unsubscribe(tsub, keep); - - taos_close(taos); - taos_cleanup(); -} diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 10ae3ee076..21a3553528 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1076,10 +1076,10 @@ typedef struct { SUpdateUserIpWhite* pUserIpWhite; } SUpdateIpWhite; -int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); -int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); -void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq); -SUpdateIpWhite* cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq); +int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); +int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); +void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq); +int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq, SUpdateIpWhite** pUpdate); typedef struct { int64_t ipWhiteVer; @@ -3640,7 +3640,7 @@ static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ve int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal); int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal); -int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); +void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight); int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight); void tOffsetDestroy(void* pVal); diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index 324804aa7c..09143dde29 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -201,7 +201,7 @@ void qStreamSetOpen(qTaskInfo_t tinfo); void qStreamSetSourceExcluded(qTaskInfo_t tinfo, int8_t sourceExcluded); -void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); +int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 5f322be99b..0d1e62cdbe 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -682,13 +682,13 @@ void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo); // fill-history task int32_t streamLaunchFillHistoryTask(SStreamTask* pTask); int32_t streamStartScanHistoryAsync(SStreamTask* pTask, int8_t igUntreated); -int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration); +void streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration); bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer); // checkpoint related void streamTaskGetActiveCheckpointInfo(const SStreamTask* pTask, int32_t* pTransId, int64_t* pCheckpointId); int32_t streamTaskSetActiveCheckpointInfo(SStreamTask* pTask, int64_t activeCheckpointId); -int32_t streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t checkpointId); +void streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t checkpointId); bool streamTaskAlreadySendTrigger(SStreamTask* pTask, int32_t downstreamNodeId); void streamTaskGetTriggerRecvStatus(SStreamTask* pTask, int32_t* pRecved, int32_t* pTotal); void streamTaskInitTriggerDispatchInfo(SStreamTask* pTask); diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index b7a459f957..6c0d04354a 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -164,13 +164,13 @@ int rpcRegisterBrokenLinkArg(SRpcMsg *msg); int rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock // These functions will not be called in the child process -int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx); -int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); -int rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated, - int32_t timeoutMs); -int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn); -void *rpcAllocHandle(); -void rpcSetIpWhite(void *thandl, void *arg); +int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx); +int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); +int rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated, + int32_t timeoutMs); +int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn); +void *rpcAllocHandle(); +int32_t rpcSetIpWhite(void *thandl, void *arg); int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 5ec18daab7..7ff3e500cf 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -90,6 +90,8 @@ int32_t taosGetErrSize(); #define TSDB_CODE_RPC_NETWORK_ERROR TAOS_DEF_ERROR_CODE(0, 0x0023) #define TSDB_CODE_RPC_NETWORK_BUSY TAOS_DEF_ERROR_CODE(0, 0x0024) #define TSDB_CODE_HTTP_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0025) +#define TSDB_CODE_RPC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0026) +#define TSDB_CODE_RPC_ASYNC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0027) diff --git a/include/util/tarray2.h b/include/util/tarray2.h index ce24a1d2ce..0781b3ac4e 100644 --- a/include/util/tarray2.h +++ b/include/util/tarray2.h @@ -116,7 +116,7 @@ static FORCE_INLINE int32_t tarray2SortInsert(void *arr, const void *elePtr, int if ((cb) && (a)->size > 0) { \ TArray2Cb cb_ = (TArray2Cb)(cb); \ for (int32_t i = 0; i < (a)->size; ++i) { \ - cb_((a)->data + i); \ + (void)cb_((a)->data + i); \ } \ } \ (a)->size = 0; \ diff --git a/include/util/tlockfree.h b/include/util/tlockfree.h index 82dd5a0e8b..1a575f8ea1 100644 --- a/include/util/tlockfree.h +++ b/include/util/tlockfree.h @@ -84,7 +84,7 @@ int32_t taosWTryLockLatch(SRWLatch *pLatch); int32_t old_ = atomic_add_fetch_32((x), 0); \ if (old_ & 0x00000001) { \ if (i_ % 1000 == 0) { \ - sched_yield(); \ + (void)sched_yield(); \ } \ continue; \ } @@ -98,9 +98,9 @@ int32_t taosWTryLockLatch(SRWLatch *pLatch); #define taosCorBeginWrite(x) \ taosCorBeginRead(x) if (atomic_val_compare_exchange_32((x), old_, old_ + 1) != old_) { continue; } -#define taosCorEndWrite(x) \ - atomic_add_fetch_32((x), 1); \ - break; \ +#define taosCorEndWrite(x) \ + (void)atomic_add_fetch_32((x), 1); \ + break; \ } #ifdef __cplusplus diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 01a4fd5640..0a5fb1a7b4 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -85,7 +85,6 @@ void taos_cleanup(void) { tscWarn("failed to close clientReqRefPool"); } - DestroyRegexCache(); rpcCleanup(); tscDebug("rpc cleanup"); @@ -93,6 +92,8 @@ void taos_cleanup(void) { tmqMgmtClose(); + DestroyRegexCache(); + tscInfo("all local resources released"); taosCleanupCfg(); taosCloseLog(); diff --git a/source/client/src/clientMonitor.c b/source/client/src/clientMonitor.c index 40cea644fd..92a8fc3b29 100644 --- a/source/client/src/clientMonitor.c +++ b/source/client/src/clientMonitor.c @@ -489,6 +489,7 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs SAppInstInfo* pInst = getAppInstByClusterId(clusterId); if (pInst == NULL) { tscError("failed to get app instance by clusterId:%" PRId64, clusterId); + taosMemoryFree(fileName); return terrno; } SEpSet ep = getEpSet_s(&pInst->mgmtEp); diff --git a/source/common/src/rsync.c b/source/common/src/rsync.c index 5e51f62a1f..c7044864ae 100644 --- a/source/common/src/rsync.c +++ b/source/common/src/rsync.c @@ -32,10 +32,10 @@ static void removeEmptyDir() { empty = false; } if (empty) taosRemoveDir(filename); - taosCloseDir(&pDirTmp); + (void)taosCloseDir(&pDirTmp); } - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); } #ifdef WINDOWS @@ -92,12 +92,12 @@ static int32_t generateConfigFile(char* confDir) { uDebug("[rsync] conf:%s", confContent); if (taosWriteFile(pFile, confContent, strlen(confContent)) <= 0) { uError("[rsync] write conf file error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); code = TAOS_SYSTEM_ERROR(errno); return code; } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return 0; } diff --git a/source/common/src/tcol.c b/source/common/src/tcol.c index a949d0793a..17972c6777 100644 --- a/source/common/src/tcol.c +++ b/source/common/src/tcol.c @@ -238,7 +238,7 @@ const char* columnLevelStr(uint8_t type) { bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(encode)) return true; - strtolower(encode, encode); + (void)strtolower(encode, encode); for (int i = 0; i < supportedEncodeNum; ++i) { if (0 == strcmp((const char*)encode, supportedEncode[i])) { return true; @@ -255,7 +255,7 @@ bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OP } bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(compress)) return true; - strtolower(compress, compress); + (void)strtolower(compress, compress); for (int i = 0; i < supportedCompressNum; ++i) { if (0 == strcmp((const char*)compress, supportedCompress[i])) { return true; @@ -273,7 +273,7 @@ bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRES } bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(level)) return true; - strtolower(level, level); + (void)strtolower(level, level); if (1 == strlen(level)) { if ('h' == level[0] || 'm' == level[0] || 'l' == level[0]) return true; } else { diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 371fc130f0..5caf93de65 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -706,7 +706,10 @@ static int32_t tRowMergeImpl(SArray *aRowP, STSchema *pTSchema, int32_t iStart, if (code) goto _exit; taosArrayRemoveBatch(aRowP, iStart, nRow, (FDelete)tRowPDestroy); - taosArrayInsert(aRowP, iStart, &pRow); + if (taosArrayInsert(aRowP, iStart, &pRow) == NULL) { + code = terrno; + goto _exit; + } _exit: if (aIter) { @@ -1708,7 +1711,7 @@ bool tTagGet(const STag *pTag, STagVal *pTagVal) { offset = pTag->idx[midx]; } - tGetTagVal(p + offset, &tv, isJson); + (void)tGetTagVal(p + offset, &tv, isJson); if (isJson) { c = tTagValJsonCmprFn(pTagVal, &tv); } else { @@ -1758,7 +1761,7 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) { } else { offset = pTag->idx[iTag]; } - tGetTagVal(p + offset, &tv, pTag->flags & TD_TAG_JSON); + (void)tGetTagVal(p + offset, &tv, pTag->flags & TD_TAG_JSON); if (taosArrayPush(*ppArray, &tv) == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err; @@ -1788,7 +1791,7 @@ void tTagSetCid(const STag *pTag, int16_t iTag, int16_t cid) { offset = pTag->idx[iTag]; } - tPutI16v(p + offset, cid); + (void)tPutI16v(p + offset, cid); } // STSchema ======================================== @@ -3152,16 +3155,16 @@ static int32_t tColDataCopyRowSingleCol(SColData *pFromColData, int32_t iFromRow SET_BIT1(pToColData->pBitMap, iToRow, GET_BIT1(pFromColData->pBitMap, iFromRow)); } break; case HAS_VALUE: { - tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow); + (void)tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow); } break; case (HAS_VALUE | HAS_NONE): case (HAS_VALUE | HAS_NULL): { SET_BIT1(pToColData->pBitMap, iToRow, GET_BIT1(pFromColData->pBitMap, iFromRow)); - tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow); + (void)tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow); } break; case (HAS_VALUE | HAS_NULL | HAS_NONE): { SET_BIT2(pToColData->pBitMap, iToRow, GET_BIT2(pFromColData->pBitMap, iFromRow)); - tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow); + (void)tColDataCopyRowCell(pFromColData, iFromRow, pToColData, iToRow); } break; default: return -1; @@ -3235,24 +3238,24 @@ static int32_t tColDataMergeSortMerge(SColData *aColData, int32_t start, int32_t tColDataArrGetRowKey(aColData, nColData, j, &keyj); while (i <= mid && j <= end) { if (tRowKeyCompare(&keyi, &keyj) <= 0) { - tColDataCopyRowAppend(aColData, i++, aDstColData, nColData); + (void)tColDataCopyRowAppend(aColData, i++, aDstColData, nColData); tColDataArrGetRowKey(aColData, nColData, i, &keyi); } else { - tColDataCopyRowAppend(aColData, j++, aDstColData, nColData); + (void)tColDataCopyRowAppend(aColData, j++, aDstColData, nColData); tColDataArrGetRowKey(aColData, nColData, j, &keyj); } } while (i <= mid) { - tColDataCopyRowAppend(aColData, i++, aDstColData, nColData); + (void)tColDataCopyRowAppend(aColData, i++, aDstColData, nColData); } while (j <= end) { - tColDataCopyRowAppend(aColData, j++, aDstColData, nColData); + (void)tColDataCopyRowAppend(aColData, j++, aDstColData, nColData); } for (i = start, k = 0; i <= end; ++i, ++k) { - tColDataCopyRow(aDstColData, k, aColData, i, nColData); + (void)tColDataCopyRow(aDstColData, k, aColData, i, nColData); } if (aDstColData) { @@ -3551,7 +3554,7 @@ void tColDataSortMerge(SArray *colDataArr) { // sort ------- if (doSort) { - tColDataSort(aColData, nColData); + (void)tColDataSort(aColData, nColData); } if (doMerge != 1) { @@ -4209,17 +4212,17 @@ int32_t tValueColumnGet(SValueColumn *valCol, int32_t idx, SValue *value) { int32_t offset, nextOffset; SBufferReader reader = BUFFER_READER_INITIALIZER(idx * sizeof(offset), &valCol->offsets); - tBufferGetI32(&reader, &offset); + (void)tBufferGetI32(&reader, &offset); if (idx == valCol->numOfValues - 1) { nextOffset = tBufferGetSize(&valCol->data); } else { - tBufferGetI32(&reader, &nextOffset); + (void)tBufferGetI32(&reader, &nextOffset); } value->nData = nextOffset - offset; value->pData = (uint8_t *)tBufferGetDataAt(&valCol->data, offset); } else { SBufferReader reader = BUFFER_READER_INITIALIZER(idx * tDataTypes[value->type].bytes, &valCol->data); - tBufferGet(&reader, tDataTypes[value->type].bytes, &value->val); + (void)tBufferGet(&reader, tDataTypes[value->type].bytes, &value->val); } return 0; } @@ -4269,7 +4272,7 @@ int32_t tValueColumnDecompress(void *input, const SValueColumnCompressInfo *info SBuffer *assist) { int32_t code; - tValueColumnClear(valCol); + (void)tValueColumnClear(valCol); valCol->type = info->type; // offset if (IS_VAR_DATA_TYPE(valCol->type)) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 04e3316bed..ebaf1041c9 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -396,8 +396,9 @@ struct SConfig *taosGetCfg() { return tsCfg; } static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile, char *apolloUrl) { - char cfgDir[PATH_MAX] = {0}; - char cfgFile[PATH_MAX + 100] = {0}; + int32_t code = 0; + char cfgDir[PATH_MAX] = {0}; + char cfgFile[PATH_MAX + 100] = {0}; TAOS_CHECK_RETURN(taosExpandDir(inputCfgDir, cfgDir, PATH_MAX)); char lastC = cfgDir[strlen(cfgDir) - 1]; @@ -424,32 +425,32 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *input } if (apolloUrl != NULL && apolloUrl[0] == '\0') { - TAOS_CHECK_RETURN(cfgGetApollUrl(envCmd, envFile, apolloUrl)); + (void)(cfgGetApollUrl(envCmd, envFile, apolloUrl)); } - if (cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl) != 0) { - uError("failed to load from apollo url:%s since %s", apolloUrl, terrstr()); - TAOS_RETURN(TSDB_CODE_INVALID_CFG); + if ((code = cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl)) != 0) { + uError("failed to load from apollo url:%s since %s", apolloUrl, tstrerror(code)); + TAOS_RETURN(code); } - if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) { - uError("failed to load from cfg file:%s since %s", cfgFile, terrstr()); - TAOS_RETURN(TSDB_CODE_INVALID_CFG); + if ((code = cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile)) != 0) { + uError("failed to load from cfg file:%s since %s", cfgFile, tstrerror(code)); + TAOS_RETURN(code); } - if (cfgLoad(pCfg, CFG_STYPE_ENV_FILE, envFile) != 0) { - uError("failed to load from env file:%s since %s", envFile, terrstr()); - TAOS_RETURN(TSDB_CODE_INVALID_CFG); + if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_FILE, envFile)) != 0) { + uError("failed to load from env file:%s since %s", envFile, tstrerror(code)); + TAOS_RETURN(code); } - if (cfgLoad(pCfg, CFG_STYPE_ENV_VAR, NULL) != 0) { - uError("failed to load from global env variables since %s", terrstr()); - TAOS_RETURN(TSDB_CODE_INVALID_CFG); + if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_VAR, NULL)) != 0) { + uError("failed to load from global env variables since %s", tstrerror(code)); + TAOS_RETURN(code); } - if (cfgLoad(pCfg, CFG_STYPE_ENV_CMD, envCmd) != 0) { - uError("failed to load from cmd env variables since %s", terrstr()); - TAOS_RETURN(TSDB_CODE_INVALID_CFG); + if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_CMD, envCmd)) != 0) { + uError("failed to load from cmd env variables since %s", tstrerror(code)); + TAOS_RETURN(code); } TAOS_RETURN(TSDB_CODE_SUCCESS); @@ -1280,12 +1281,12 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi } if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != TSDB_CODE_SUCCESS) { - printf("failed to load cfg since %s", tstrerror(code)); + printf("failed to load cfg since %s\n", tstrerror(code)); goto _exit; } if ((code = cfgLoadFromArray(pCfg, pArgs)) != TSDB_CODE_SUCCESS) { - printf("failed to load cfg from array since %s", tstrerror(code)); + printf("failed to load cfg from array since %s\n", tstrerror(code)); goto _exit; } @@ -1302,12 +1303,12 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi TAOS_CHECK_RETURN(taosSetAllDebugFlag(pCfg, pDebugItem->i32)); if ((code = taosMulModeMkDir(tsLogDir, 0777, true)) != TSDB_CODE_SUCCESS) { - printf("failed to create dir:%s since %s", tsLogDir, tstrerror(code)); + printf("failed to create dir:%s since %s\n", tsLogDir, tstrerror(code)); goto _exit; } if ((code = taosInitLog(logname, logFileNum)) != 0) { - printf("failed to init log file since %s", terrstr()); + printf("failed to init log file since %s\n", tstrerror(code)); goto _exit; } @@ -1329,12 +1330,12 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char * if (cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1; if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) { - printf("failed to load cfg since %s", terrstr()); + printf("failed to load cfg since %s\n", tstrerror(code)); goto _exit; } if ((code = cfgLoadFromArray(pCfg, pArgs)) != 0) { - printf("failed to load cfg from array since %s", terrstr()); + printf("failed to load cfg from array since %s\n", tstrerror(code)); goto _exit; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c17b8ef526..9e663d495c 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -522,7 +522,7 @@ int32_t tDeserializeSClientHbBatchReq(void *buf, int32_t bufLen, SClientHbBatchR } if (!tDecodeIsEnd(&decoder)) { - tDecodeI64(&decoder, &pBatchReq->ipWhiteList); + if (tDecodeI64(&decoder, &pBatchReq->ipWhiteList) < 0) return -1; } tEndDecode(&decoder); @@ -1764,23 +1764,33 @@ int32_t tDeserializeSUpdateIpWhite(void *buf, int32_t bufLen, SUpdateIpWhite *pR return 0; } void tFreeSUpdateIpWhiteReq(SUpdateIpWhite *pReq) { - for (int i = 0; i < pReq->numOfUser; i++) { - SUpdateUserIpWhite *pUserWhite = &pReq->pUserIpWhite[i]; - taosMemoryFree(pUserWhite->pIpRanges); + if (pReq == NULL) return; + + if (pReq->pUserIpWhite) { + for (int i = 0; i < pReq->numOfUser; i++) { + SUpdateUserIpWhite *pUserWhite = &pReq->pUserIpWhite[i]; + taosMemoryFree(pUserWhite->pIpRanges); + } } taosMemoryFree(pReq->pUserIpWhite); - // impl later return; } -SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) { +int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq, SUpdateIpWhite **pUpdateMsg) { + int32_t code = 0; + if (pReq == NULL) { + return 0; + } SUpdateIpWhite *pClone = taosMemoryCalloc(1, sizeof(SUpdateIpWhite)); - if (pClone == NULL) return NULL; + if (pClone == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } pClone->numOfUser = pReq->numOfUser; pClone->ver = pReq->ver; - if ((pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser)) == NULL) { + pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser); + if (pClone->pUserIpWhite == NULL) { taosMemoryFree(pClone); - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; } for (int i = 0; i < pReq->numOfUser; i++) { @@ -1792,17 +1802,21 @@ SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) { pNew->numOfRange = pOld->numOfRange; int32_t sz = pOld->numOfRange * sizeof(SIpV4Range); - if ((pNew->pIpRanges = taosMemoryCalloc(1, sz)) == NULL) { - for (int j = 0; j < i; j++) { - taosMemoryFree(pClone->pUserIpWhite[j].pIpRanges); - } - taosMemoryFree(pClone->pUserIpWhite); - taosMemoryFree(pClone); - return NULL; + pNew->pIpRanges = taosMemoryCalloc(1, sz); + if (pNew->pIpRanges == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; } memcpy(pNew->pIpRanges, pOld->pIpRanges, sz); } - return pClone; +_return: + if (code < 0) { + tFreeSUpdateIpWhiteReq(pClone); + taosMemoryFree(pClone); + } else { + *pUpdateMsg = pClone; + } + return code; } int32_t tSerializeRetrieveIpWhite(void *buf, int32_t bufLen, SRetrieveIpWhiteReq *pReq) { SEncoder encoder = {0}; @@ -2149,21 +2163,21 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs char db[TSDB_DB_FNAME_LEN] = {0}; if (tDecodeCStrTo(pDecoder, db) < 0) goto _err; int32_t len = strlen(db); - taosHashPut(pRsp->createdDbs, db, len + 1, db, len + 1); + if (taosHashPut(pRsp->createdDbs, db, len + 1, db, len + 1) < 0) goto _err; } for (int32_t i = 0; i < numOfReadDbs; ++i) { char db[TSDB_DB_FNAME_LEN] = {0}; if (tDecodeCStrTo(pDecoder, db) < 0) goto _err; int32_t len = strlen(db); - taosHashPut(pRsp->readDbs, db, len + 1, db, len + 1); + if (taosHashPut(pRsp->readDbs, db, len + 1, db, len + 1) < 0) goto _err; } for (int32_t i = 0; i < numOfWriteDbs; ++i) { char db[TSDB_DB_FNAME_LEN] = {0}; if (tDecodeCStrTo(pDecoder, db) < 0) goto _err; int32_t len = strlen(db); - taosHashPut(pRsp->writeDbs, db, len + 1, db, len + 1); + if (taosHashPut(pRsp->writeDbs, db, len + 1, db, len + 1) < 0) goto _err; } if (!tDecodeIsEnd(pDecoder)) { @@ -2195,7 +2209,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs if ((value = taosMemoryCalloc(valuelen + 1, sizeof(char))) == NULL) goto _err; if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->readTbs, key, keyLen, value, valuelen + 1); + if (taosHashPut(pRsp->readTbs, key, keyLen, value, valuelen + 1) < 0) goto _err; taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -2214,7 +2228,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs if ((value = taosMemoryCalloc(valuelen + 1, sizeof(char))) == NULL) goto _err; if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->writeTbs, key, keyLen, value, valuelen + 1); + if (taosHashPut(pRsp->writeTbs, key, keyLen, value, valuelen + 1) < 0) goto _err; taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -2233,7 +2247,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs if ((value = taosMemoryCalloc(valuelen + 1, sizeof(char))) == NULL) goto _err; if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->alterTbs, key, keyLen, value, valuelen + 1); + if (taosHashPut(pRsp->alterTbs, key, keyLen, value, valuelen + 1) < 0) goto _err; taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -2252,7 +2266,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs if ((value = taosMemoryCalloc(valuelen + 1, sizeof(char))) == NULL) goto _err; if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->readViews, key, keyLen, value, valuelen + 1); + if (taosHashPut(pRsp->readViews, key, keyLen, value, valuelen + 1) < 0) goto _err; taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -2271,7 +2285,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs if ((value = taosMemoryCalloc(valuelen + 1, sizeof(char))) == NULL) goto _err; if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->writeViews, key, keyLen, value, valuelen + 1); + if (taosHashPut(pRsp->writeViews, key, keyLen, value, valuelen + 1) < 0) goto _err; taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -2290,7 +2304,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs if ((value = taosMemoryCalloc(valuelen + 1, sizeof(char))) == NULL) goto _err; if (tDecodeCStrTo(pDecoder, value) < 0) goto _err; - taosHashPut(pRsp->alterViews, key, keyLen, value, valuelen + 1); + if (taosHashPut(pRsp->alterViews, key, keyLen, value, valuelen + 1) < 0) goto _err; taosMemoryFreeClear(key); taosMemoryFreeClear(value); @@ -2306,7 +2320,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs int32_t ref = 0; if (tDecodeI32(pDecoder, &ref) < 0) goto _err; - taosHashPut(pRsp->useDbs, key, keyLen, &ref, sizeof(ref)); + if (taosHashPut(pRsp->useDbs, key, keyLen, &ref, sizeof(ref)) < 0) goto _err; taosMemoryFreeClear(key); } // since 3.0.7.0 @@ -4226,7 +4240,7 @@ int32_t tSerializeSDbCfgRsp(void *buf, int32_t bufLen, const SDbCfgRsp *pRsp) { tEncoderInit(&encoder, buf, bufLen); if (tStartEncode(&encoder) < 0) return -1; - tSerializeSDbCfgRspImpl(&encoder, pRsp); + if (tSerializeSDbCfgRspImpl(&encoder, pRsp) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; tEncoderClear(&encoder); @@ -7087,7 +7101,7 @@ int32_t tDeserializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq) { if (tStartDecode(&decoder) < 0) return -1; if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1; - tDecodeCStrTo(&decoder, pReq->subKey); + if (tDecodeCStrTo(&decoder, pReq->subKey) < 0) return -1; tEndDecode(&decoder); @@ -7342,6 +7356,7 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { if (tEncodeSTqOffsetVal(&encoder, &pReq->reqOffset) < 0) return -1; if (tEncodeI8(&encoder, pReq->enableReplay) < 0) return -1; if (tEncodeI8(&encoder, pReq->sourceExcluded) < 0) return -1; + if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1; tEndEncode(&encoder); @@ -7353,7 +7368,6 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { pHead->vgId = htonl(pReq->head.vgId); pHead->contLen = htonl(tlen + headLen); } - if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1; return tlen + headLen; } @@ -7801,8 +7815,8 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) { if (tEncodeCStr(pCoder, pSma->tagsFilter) < 0) return -1; } - tEncodeSSchemaWrapper(pCoder, &pSma->schemaRow); - tEncodeSSchemaWrapper(pCoder, &pSma->schemaTag); + if (tEncodeSSchemaWrapper(pCoder, &pSma->schemaRow) < 0) return -1; + if (tEncodeSSchemaWrapper(pCoder, &pSma->schemaTag) < 0) return -1; return 0; } @@ -7847,8 +7861,8 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma, bool deepCopy) { pSma->tagsFilter = NULL; } // only needed in dstVgroup - tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaRow); - tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaTag); + if (tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaRow) < 0) return -1; + if (tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaTag) < 0) return -1; return 0; } @@ -7856,7 +7870,7 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma, bool deepCopy) { int32_t tEncodeSVCreateTSmaReq(SEncoder *pCoder, const SVCreateTSmaReq *pReq) { if (tStartEncode(pCoder) < 0) return -1; - tEncodeTSma(pCoder, pReq); + if (tEncodeTSma(pCoder, pReq) < 0) return -1; tEndEncode(pCoder); return 0; @@ -7865,7 +7879,7 @@ int32_t tEncodeSVCreateTSmaReq(SEncoder *pCoder, const SVCreateTSmaReq *pReq) { int32_t tDecodeSVCreateTSmaReq(SDecoder *pCoder, SVCreateTSmaReq *pReq) { if (tStartDecode(pCoder) < 0) return -1; - tDecodeTSma(pCoder, pReq, false); + if (tDecodeTSma(pCoder, pReq, false) < 0) return -1; tEndDecode(pCoder); return 0; @@ -9180,7 +9194,7 @@ int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) { return 0; } -int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { +void tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { if (pVal->type == TMQ_OFFSET__RESET_NONE) { (void)snprintf(buf, maxLen, "none"); } else if (pVal->type == TMQ_OFFSET__RESET_EARLIEST) { @@ -9192,7 +9206,7 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) { if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) { char *tmp = taosMemoryCalloc(1, pVal->primaryKey.nData + 1); - if (tmp == NULL) return terrno; + if (tmp == NULL) return; (void)memcpy(tmp, pVal->primaryKey.pData, pVal->primaryKey.nData); (void)snprintf(buf, maxLen, "tsdb:%" PRId64 "|%" PRId64 ",pk type:%d,val:%s", pVal->uid, pVal->ts, pVal->primaryKey.type, tmp); @@ -9202,8 +9216,6 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { pVal->primaryKey.type, pVal->primaryKey.val); } } - - return 0; } bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) { @@ -9230,7 +9242,9 @@ int32_t tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { tOffsetDestroy(pLeft); *pLeft = *pRight; if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) { - if ((pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData)) == NULL) { + pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData); + if (pLeft->primaryKey.pData == NULL) { + uError("failed to allocate memory for offset"); return terrno; } (void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData); @@ -10727,7 +10741,7 @@ void tFreeSMDropTbReqOnSingleVg(void *p) { int32_t tSerializeSMDropTbsReq(void *buf, int32_t bufLen, const SMDropTbsReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - tStartEncode(&encoder); + if (tStartEncode(&encoder) < 0) return -1; int32_t size = pReq->pVgReqs ? pReq->pVgReqs->size : 0; if (tEncodeI32(&encoder, size) < 0) return -1; for (int32_t i = 0; i < size; ++i) { @@ -10743,7 +10757,7 @@ int32_t tSerializeSMDropTbsReq(void *buf, int32_t bufLen, const SMDropTbsReq *pR int32_t tDeserializeSMDropTbsReq(void *buf, int32_t bufLen, SMDropTbsReq *pReq) { SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); - tStartDecode(&decoder); + if (tStartDecode(&decoder) < 0) return -1; int32_t size = 0; if (tDecodeI32(&decoder, &size) < 0) return -1; pReq->pVgReqs = taosArrayInit(size, sizeof(SMDropTbReqsOnSingleVg)); diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 1dc4a6f9ba..942255cd7c 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -68,7 +68,7 @@ bool tdSTSRowIterFetch(STSRowIter *pIter, col_id_t colId, col_type_t colType, SC return false; } } - tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal); + (void)tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal); ++pIter->colIdx; } else if (TD_IS_KV_ROW(pIter->pRow)) { return tdSTSRowIterGetKvVal(pIter, colId, &pIter->kvIdx, pVal); diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 2d748706b5..b3e5015706 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -80,11 +80,11 @@ static void dmSetAssert(int32_t signum, void *sigInfo, void *context) { tsAssert static void dmStopDnode(int signum, void *sigInfo, void *context) { // taosIgnSignal(SIGUSR1); // taosIgnSignal(SIGUSR2); - taosIgnSignal(SIGTERM); - taosIgnSignal(SIGHUP); - taosIgnSignal(SIGINT); - taosIgnSignal(SIGABRT); - taosIgnSignal(SIGBREAK); + (void)taosIgnSignal(SIGTERM); + (void)taosIgnSignal(SIGHUP); + (void)taosIgnSignal(SIGINT); + (void)taosIgnSignal(SIGABRT); + (void)taosIgnSignal(SIGBREAK); dInfo("shut down signal is %d", signum); #ifndef WINDOWS @@ -102,11 +102,11 @@ void dmLogCrash(int signum, void *sigInfo, void *context) { // taosIgnSignal(SIGBREAK); #ifndef WINDOWS - taosIgnSignal(SIGBUS); + (void)taosIgnSignal(SIGBUS); #endif - taosIgnSignal(SIGABRT); - taosIgnSignal(SIGFPE); - taosIgnSignal(SIGSEGV); + (void)taosIgnSignal(SIGABRT); + (void)taosIgnSignal(SIGFPE); + (void)taosIgnSignal(SIGSEGV); char *pMsg = NULL; const char *flags = "UTL FATAL "; @@ -135,23 +135,23 @@ _return: } static void dmSetSignalHandle() { - taosSetSignal(SIGUSR1, dmSetDebugFlag); - taosSetSignal(SIGUSR2, dmSetAssert); - taosSetSignal(SIGTERM, dmStopDnode); - taosSetSignal(SIGHUP, dmStopDnode); - taosSetSignal(SIGINT, dmStopDnode); - taosSetSignal(SIGBREAK, dmStopDnode); + (void)taosSetSignal(SIGUSR1, dmSetDebugFlag); + (void)taosSetSignal(SIGUSR2, dmSetAssert); + (void)taosSetSignal(SIGTERM, dmStopDnode); + (void)taosSetSignal(SIGHUP, dmStopDnode); + (void)taosSetSignal(SIGINT, dmStopDnode); + (void)taosSetSignal(SIGBREAK, dmStopDnode); #ifndef WINDOWS - taosSetSignal(SIGTSTP, dmStopDnode); - taosSetSignal(SIGQUIT, dmStopDnode); + (void)taosSetSignal(SIGTSTP, dmStopDnode); + (void)taosSetSignal(SIGQUIT, dmStopDnode); #endif #ifndef WINDOWS - taosSetSignal(SIGBUS, dmLogCrash); + (void)taosSetSignal(SIGBUS, dmLogCrash); #endif - taosSetSignal(SIGABRT, dmLogCrash); - taosSetSignal(SIGFPE, dmLogCrash); - taosSetSignal(SIGSEGV, dmLogCrash); + (void)taosSetSignal(SIGABRT, dmLogCrash); + (void)taosSetSignal(SIGFPE, dmLogCrash); + (void)taosSetSignal(SIGSEGV, dmLogCrash); } static int32_t dmParseArgs(int32_t argc, char const *argv[]) { diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index f50754992c..2942a85f68 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -21,32 +21,45 @@ extern SConfig *tsCfg; static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) { + int32_t code = 0; if (pMgmt->pData->dnodeId == 0 || pMgmt->pData->clusterId == 0) { dInfo("set local info, dnodeId:%d clusterId:%" PRId64, pCfg->dnodeId, pCfg->clusterId); - taosThreadRwlockWrlock(&pMgmt->pData->lock); + (void)taosThreadRwlockWrlock(&pMgmt->pData->lock); pMgmt->pData->dnodeId = pCfg->dnodeId; pMgmt->pData->clusterId = pCfg->clusterId; - dmWriteEps(pMgmt->pData); - taosThreadRwlockUnlock(&pMgmt->pData->lock); + code = dmWriteEps(pMgmt->pData); + if (code != 0) { + dInfo("failed to set local info, dnodeId:%d clusterId:%" PRId64 " reason:%s", pCfg->dnodeId, pCfg->clusterId, + tstrerror(code)); + } + (void)taosThreadRwlockUnlock(&pMgmt->pData->lock); } } static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) { + int32_t code = 0; dDebug("ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->pData->ipWhiteVer, ver); if (pMgmt->pData->ipWhiteVer == ver) { if (ver == 0) { dDebug("disable ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->pData->ipWhiteVer, ver); - rpcSetIpWhite(pMgmt->msgCb.serverRpc, NULL); - // pMgmt->ipWhiteVer = ver; + (void)rpcSetIpWhite(pMgmt->msgCb.serverRpc, NULL); } return; } int64_t oldVer = pMgmt->pData->ipWhiteVer; - // pMgmt->ipWhiteVer = ver; SRetrieveIpWhiteReq req = {.ipWhiteVer = oldVer}; int32_t contLen = tSerializeRetrieveIpWhite(NULL, 0, &req); - void *pHead = rpcMallocCont(contLen); - tSerializeRetrieveIpWhite(pHead, contLen, &req); + if (contLen < 0) { + dError("failed to serialize ip white list request since: %s", tstrerror(contLen)); + return; + } + void *pHead = rpcMallocCont(contLen); + contLen = tSerializeRetrieveIpWhite(pHead, contLen, &req); + if (contLen < 0) { + rpcFreeCont(pHead); + dError("failed to serialize ip white list request since:%s", tstrerror(contLen)); + return; + } SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, @@ -57,9 +70,12 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) { .info.handle = 0}; SEpSet epset = {0}; - dmGetMnodeEpSet(pMgmt->pData, &epset); + (void)dmGetMnodeEpSet(pMgmt->pData, &epset); - rpcSendRequest(pMgmt->msgCb.clientRpc, &epset, &rpcMsg, NULL); + code = rpcSendRequest(pMgmt->msgCb.clientRpc, &epset, &rpcMsg, NULL); + if (code != 0) { + dError("failed to send retrieve ip white list request since:%s", tstrerror(code)); + } } static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { const STraceId *trace = &pRsp->info.traceId; @@ -70,9 +86,9 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { dGInfo("dnode:%d, set to dropped since not exist in mnode, statusSeq:%d", pMgmt->pData->dnodeId, pMgmt->statusSeq); pMgmt->pData->dropped = 1; - dmWriteEps(pMgmt->pData); + (void)dmWriteEps(pMgmt->pData); dInfo("dnode will exit since it is in the dropped state"); - raise(SIGINT); + (void)raise(SIGINT); } } else { SStatusRsp statusRsp = {0}; @@ -93,9 +109,10 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { } void dmSendStatusReq(SDnodeMgmt *pMgmt) { + int32_t code = 0; SStatusReq req = {0}; - taosThreadRwlockRdlock(&pMgmt->pData->lock); + (void)taosThreadRwlockRdlock(&pMgmt->pData->lock); req.sver = tsVersion; req.dnodeVer = pMgmt->pData->dnodeVer; req.dnodeId = pMgmt->pData->dnodeId; @@ -129,7 +146,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN); memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN); memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN); - taosThreadRwlockUnlock(&pMgmt->pData->lock); + (void)taosThreadRwlockUnlock(&pMgmt->pData->lock); SMonVloadInfo vinfo = {0}; (*pMgmt->getVnodeLoadsFp)(&vinfo); @@ -146,8 +163,18 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { req.ipWhiteVer = pMgmt->pData->ipWhiteVer; int32_t contLen = tSerializeSStatusReq(NULL, 0, &req); - void *pHead = rpcMallocCont(contLen); - tSerializeSStatusReq(pHead, contLen, &req); + if (contLen < 0) { + dError("failed to serialize status req since %s", tstrerror(contLen)); + return; + } + + void *pHead = rpcMallocCont(contLen); + contLen = tSerializeSStatusReq(pHead, contLen, &req); + if (contLen < 0) { + rpcFreeCont(pHead); + dError("failed to serialize status req since %s", tstrerror(contLen)); + return; + } tFreeSStatusReq(&req); SRpcMsg rpcMsg = {.pCont = pHead, @@ -163,8 +190,15 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { SEpSet epSet = {0}; int8_t epUpdated = 0; - dmGetMnodeEpSet(pMgmt->pData, &epSet); - rpcSendRecvWithTimeout(pMgmt->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, &epUpdated, tsStatusInterval * 5 * 1000); + (void)dmGetMnodeEpSet(pMgmt->pData, &epSet); + + code = + rpcSendRecvWithTimeout(pMgmt->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, &epUpdated, tsStatusInterval * 5 * 1000); + if (code != 0) { + dError("failed to send status req since %s", tstrerror(code)); + return; + } + if (rpcRsp.code != 0) { dmRotateMnodeEpSet(pMgmt->pData); char tbuf[512]; @@ -193,7 +227,7 @@ void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) { SEpSet epSet = {0}; dmGetMnodeEpSet(pMgmt->pData, &epSet); - rpcSendRequest(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, NULL); + (void)rpcSendRequest(pMgmt->msgCb.clientRpc, &epSet, &rpcMsg, NULL); } int32_t dmProcessAuthRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index add62d1edc..a3e1a64012 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -266,22 +266,22 @@ static void *dmCrashReportThreadFp(void *param) { int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) { int32_t code = 0; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pMgmt->statusThread, &thAttr, dmStatusThreadFp, pMgmt) != 0) { code = TAOS_SYSTEM_ERROR(errno); dError("failed to create status thread since %s", tstrerror(code)); return code; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); tmsgReportStartup("dnode-status", "initialized"); return 0; } void dmStopStatusThread(SDnodeMgmt *pMgmt) { if (taosCheckPthreadValid(pMgmt->statusThread)) { - taosThreadJoin(pMgmt->statusThread, NULL); + (void)taosThreadJoin(pMgmt->statusThread, NULL); taosThreadClear(&pMgmt->statusThread); } } @@ -289,40 +289,40 @@ void dmStopStatusThread(SDnodeMgmt *pMgmt) { int32_t dmStartNotifyThread(SDnodeMgmt *pMgmt) { int32_t code = 0; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pMgmt->notifyThread, &thAttr, dmNotifyThreadFp, pMgmt) != 0) { code = TAOS_SYSTEM_ERROR(errno); dError("failed to create notify thread since %s", strerror(code)); return code; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); tmsgReportStartup("dnode-notify", "initialized"); return 0; } void dmStopNotifyThread(SDnodeMgmt *pMgmt) { if (taosCheckPthreadValid(pMgmt->notifyThread)) { - tsem_post(&dmNotifyHdl.sem); - taosThreadJoin(pMgmt->notifyThread, NULL); + (void)tsem_post(&dmNotifyHdl.sem); + (void)taosThreadJoin(pMgmt->notifyThread, NULL); taosThreadClear(&pMgmt->notifyThread); } - tsem_destroy(&dmNotifyHdl.sem); + (void)tsem_destroy(&dmNotifyHdl.sem); } int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) { int32_t code = 0; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pMgmt->monitorThread, &thAttr, dmMonitorThreadFp, pMgmt) != 0) { code = TAOS_SYSTEM_ERROR(errno); dError("failed to create monitor thread since %s", tstrerror(code)); return code; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); tmsgReportStartup("dnode-monitor", "initialized"); return 0; } @@ -330,30 +330,30 @@ int32_t dmStartMonitorThread(SDnodeMgmt *pMgmt) { int32_t dmStartAuditThread(SDnodeMgmt *pMgmt) { int32_t code = 0; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pMgmt->auditThread, &thAttr, dmAuditThreadFp, pMgmt) != 0) { code = TAOS_SYSTEM_ERROR(errno); dError("failed to create audit thread since %s", tstrerror(code)); return code; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); tmsgReportStartup("dnode-audit", "initialized"); return 0; } void dmStopMonitorThread(SDnodeMgmt *pMgmt) { if (taosCheckPthreadValid(pMgmt->monitorThread)) { - taosThreadJoin(pMgmt->monitorThread, NULL); - taosThreadClear(&pMgmt->monitorThread); + (void)taosThreadJoin(pMgmt->monitorThread, NULL); + (void)taosThreadClear(&pMgmt->monitorThread); } } void dmStopAuditThread(SDnodeMgmt *pMgmt) { if (taosCheckPthreadValid(pMgmt->auditThread)) { - taosThreadJoin(pMgmt->auditThread, NULL); - taosThreadClear(&pMgmt->auditThread); + (void)taosThreadJoin(pMgmt->auditThread, NULL); + (void)taosThreadClear(&pMgmt->auditThread); } } @@ -364,15 +364,15 @@ int32_t dmStartCrashReportThread(SDnodeMgmt *pMgmt) { } TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pMgmt->crashReportThread, &thAttr, dmCrashReportThreadFp, pMgmt) != 0) { code = TAOS_SYSTEM_ERROR(errno); dError("failed to create crashReport thread since %s", tstrerror(code)); return code; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); tmsgReportStartup("dnode-crashReport", "initialized"); return 0; } @@ -383,8 +383,8 @@ void dmStopCrashReportThread(SDnodeMgmt *pMgmt) { } if (taosCheckPthreadValid(pMgmt->crashReportThread)) { - taosThreadJoin(pMgmt->crashReportThread, NULL); - taosThreadClear(&pMgmt->crashReportThread); + (void)taosThreadJoin(pMgmt->crashReportThread, NULL); + (void)taosThreadClear(&pMgmt->crashReportThread); } } @@ -454,7 +454,11 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { .contLen = pMsg->info.rspLen, .info = pMsg->info, }; - rpcSendResponse(&rsp); + + code = rpcSendResponse(&rsp); + if (code != 0) { + dError("failed to send response since %s", tstrerror(code)); + } } dTrace("msg:%p, is freed, code:0x%x", pMsg, code); @@ -463,6 +467,7 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { } int32_t dmStartWorker(SDnodeMgmt *pMgmt) { + int32_t code = 0; SSingleWorkerCfg cfg = { .min = 1, .max = 1, @@ -470,9 +475,9 @@ int32_t dmStartWorker(SDnodeMgmt *pMgmt) { .fp = (FItem)dmProcessMgmtQueue, .param = pMgmt, }; - if (tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg) != 0) { - dError("failed to start dnode-mgmt worker since %s", terrstr()); - return -1; + if ((code = tSingleWorkerInit(&pMgmt->mgmtWorker, &cfg)) != 0) { + dError("failed to start dnode-mgmt worker since %s", tstrerror(code)); + return code; } dDebug("dnode workers are initialized"); @@ -487,6 +492,5 @@ void dmStopWorker(SDnodeMgmt *pMgmt) { int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { SSingleWorker *pWorker = &pMgmt->mgmtWorker; dTrace("msg:%p, put into worker %s", pMsg, pWorker->name); - taosWriteQitem(pWorker->queue, pMsg); - return 0; + return taosWriteQitem(pWorker->queue, pMsg); } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 067ce528d5..7605df8e7c 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -17,12 +17,12 @@ #include "mmInt.h" void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) { - mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->stb, &pInfo->grant); + (void)mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->stb, &pInfo->grant); } void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) { pInfo->isMnode = 1; - mndGetLoad(pMgmt->pMnode, &pInfo->load); + (void)mndGetLoad(pMgmt->pMnode, &pInfo->load); } int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c index 57436adcd0..20802e33d9 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmInt.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmInt.c @@ -68,7 +68,7 @@ static void mmClose(SMnodeMgmt *pMgmt) { if (pMgmt->pMnode != NULL) { mmStopWorker(pMgmt); mndClose(pMgmt->pMnode); - taosThreadRwlockDestroy(&pMgmt->lock); + (void)taosThreadRwlockDestroy(&pMgmt->lock); pMgmt->pMnode = NULL; } @@ -107,7 +107,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) { pMgmt->msgCb = pInput->msgCb; pMgmt->msgCb.putToQueueFp = (PutToQueueFp)mmPutMsgToQueue; pMgmt->msgCb.mgmt = pMgmt; - taosThreadRwlockInit(&pMgmt->lock, NULL); + (void)taosThreadRwlockInit(&pMgmt->lock, NULL); SMnodeOpt option = {0}; if ((code = mmReadFile(pMgmt->path, &option)) != 0) { @@ -163,9 +163,9 @@ static int32_t mmStart(SMnodeMgmt *pMgmt) { static void mmStop(SMnodeMgmt *pMgmt) { dDebug("mnode-mgmt start to stop"); mndPreClose(pMgmt->pMnode); - taosThreadRwlockWrlock(&pMgmt->lock); + (void)taosThreadRwlockWrlock(&pMgmt->lock); pMgmt->stopped = 1; - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); mndStop(pMgmt->pMnode); } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index 26e99f4798..fc070d0d05 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -20,20 +20,20 @@ static inline int32_t mmAcquire(SMnodeMgmt *pMgmt) { int32_t code = 0; - taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosThreadRwlockRdlock(&pMgmt->lock); if (pMgmt->stopped) { code = -1; } else { - atomic_add_fetch_32(&pMgmt->refCount, 1); + (void)atomic_add_fetch_32(&pMgmt->refCount, 1); } - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); return code; } static inline void mmRelease(SMnodeMgmt *pMgmt) { - taosThreadRwlockRdlock(&pMgmt->lock); - atomic_sub_fetch_32(&pMgmt->refCount, 1); - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockRdlock(&pMgmt->lock); + (void)atomic_sub_fetch_32(&pMgmt->refCount, 1); + (void)taosThreadRwlockUnlock(&pMgmt->lock); } static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) { @@ -100,16 +100,16 @@ static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { static inline int32_t mmPutMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pMsg) { const STraceId *trace = &pMsg->info.traceId; - - if (mmAcquire(pMgmt) == 0) { + int32_t code = 0; + if ((code = mmAcquire(pMgmt)) == 0) { dGTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType)); - taosWriteQitem(pWorker->queue, pMsg); + code = taosWriteQitem(pWorker->queue, pMsg); mmRelease(pMgmt); - return 0; + return code; } else { - dGTrace("msg:%p, failed to put into %s queue since %s, type:%s", pMsg, pWorker->name, terrstr(), + dGTrace("msg:%p, failed to put into %s queue since %s, type:%s", pMsg, pWorker->name, tstrerror(code), TMSG_INFO(pMsg->msgType)); - return -1; + return code; } } diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c index ae7125811e..a8ad26f006 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c @@ -18,13 +18,13 @@ void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) { SQnodeLoad qload = {0}; - qndGetLoad(pMgmt->pQnode, &qload); + (void)qndGetLoad(pMgmt->pQnode, &qload); qload.dnodeId = pMgmt->pData->dnodeId; } void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) { - qndGetLoad(pMgmt->pQnode, pInfo); + (void)qndGetLoad(pMgmt->pQnode, pInfo); pInfo->dnodeId = pMgmt->pData->dnodeId; } diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c index 5b380c2a0b..9ae16f7581 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c @@ -23,7 +23,7 @@ static inline void qmSendRsp(SRpcMsg *pMsg, int32_t code) { .contLen = pMsg->info.rspLen, .info = pMsg->info, }; - tmsgSendRsp(&rsp); + (void)tmsgSendRsp(&rsp); } static void qmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { @@ -43,8 +43,7 @@ static void qmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { static int32_t qmPutNodeMsgToWorker(SSingleWorker *pWorker, SRpcMsg *pMsg) { dTrace("msg:%p, put into worker %s, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType)); - taosWriteQitem(pWorker->queue, pMsg); - return 0; + return taosWriteQitem(pWorker->queue, pMsg); } int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) { @@ -69,18 +68,18 @@ int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { switch (qtype) { case QUERY_QUEUE: dTrace("msg:%p, is created and will put into qnode-query queue, len:%d", pMsg, pRpc->contLen); - taosWriteQitem(pMgmt->queryWorker.queue, pMsg); - return 0; + code = taosWriteQitem(pMgmt->queryWorker.queue, pMsg); + return code; case READ_QUEUE: case FETCH_QUEUE: dTrace("msg:%p, is created and will put into qnode-fetch queue, len:%d", pMsg, pRpc->contLen); - taosWriteQitem(pMgmt->fetchWorker.queue, pMsg); - return 0; + code = taosWriteQitem(pMgmt->fetchWorker.queue, pMsg); + return code; default: terrno = TSDB_CODE_INVALID_PARA; rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); - return -1; + return terrno; } } diff --git a/source/dnode/mgmt/mgmt_snode/src/smWorker.c b/source/dnode/mgmt/mgmt_snode/src/smWorker.c index 6d20e076dd..ad602313e0 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smWorker.c +++ b/source/dnode/mgmt/mgmt_snode/src/smWorker.c @@ -23,7 +23,7 @@ static inline void smSendRsp(SRpcMsg *pMsg, int32_t code) { .contLen = pMsg->info.rspLen, .info = pMsg->info, }; - tmsgSendRsp(&rsp); + (void)tmsgSendRsp(&rsp); } static void smProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { @@ -31,7 +31,7 @@ static void smProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO for (int32_t i = 0; i < numOfMsgs; i++) { SRpcMsg *pMsg = NULL; - taosGetQitem(qall, (void **)&pMsg); + (void)taosGetQitem(qall, (void **)&pMsg); const STraceId *trace = &pMsg->info.traceId; dTrace("msg:%p, get from snode-write queue", pMsg); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c index 47ae2a1395..4f2c04c6a5 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmFile.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmFile.c @@ -20,13 +20,13 @@ #define MAX_CONTENT_LEN 2 * 1024 * 1024 int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeObj ***ppVnodes) { - taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosThreadRwlockRdlock(&pMgmt->lock); int32_t num = 0; int32_t size = taosHashGetSize(pMgmt->hash); SVnodeObj **pVnodes = taosMemoryCalloc(size, sizeof(SVnodeObj *)); if (pVnodes == NULL) { - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); return TSDB_CODE_OUT_OF_MEMORY; } @@ -44,7 +44,7 @@ int32_t vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes, SVnodeOb } } - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); *numOfVnodes = num; *ppVnodes = pVnodes; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index b193206e5e..fe438c4396 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -22,7 +22,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) { tfsUpdateSize(pMgmt->pTfs); - taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosThreadRwlockRdlock(&pMgmt->lock); void *pIter = taosHashIterate(pMgmt->hash, NULL); while (pIter) { @@ -32,21 +32,21 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) { SVnodeObj *pVnode = *ppVnode; SVnodeLoad vload = {.vgId = pVnode->vgId}; if (!pVnode->failed) { - vnodeGetLoad(pVnode->pImpl, &vload); + (void)vnodeGetLoad(pVnode->pImpl, &vload); if (isReset) vnodeResetLoad(pVnode->pImpl, &vload); } - taosArrayPush(pInfo->pVloads, &vload); + (void)taosArrayPush(pInfo->pVloads, &vload); pIter = taosHashIterate(pMgmt->hash, pIter); } - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); } void vmGetVnodeLoadsLite(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) { pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoadLite)); if (!pInfo->pVloads) return; - taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosThreadRwlockRdlock(&pMgmt->lock); void *pIter = taosHashIterate(pMgmt->hash, NULL); while (pIter) { @@ -57,13 +57,13 @@ void vmGetVnodeLoadsLite(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo) { if (!pVnode->failed) { SVnodeLoadLite vload = {0}; if (vnodeGetLoadLite(pVnode->pImpl, &vload) == 0) { - taosArrayPush(pInfo->pVloads, &vload); + (void)taosArrayPush(pInfo->pVloads, &vload); } } pIter = taosHashIterate(pMgmt->hash, pIter); } - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); } void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) { @@ -109,7 +109,7 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) { pMgmt->state.numOfBatchInsertReqs = numOfBatchInsertReqs; pMgmt->state.numOfBatchInsertSuccessReqs = numOfBatchInsertSuccessReqs; - tfsGetMonitorInfo(pMgmt->pTfs, &pInfo->tfs); + (void)tfsGetMonitorInfo(pMgmt->pTfs, &pInfo->tfs); taosArrayDestroy(pVloads); } @@ -200,7 +200,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pNode->nodePort = pCreate->replicas[pCfg->syncCfg.replicaNum].port; pNode->nodeRole = TAOS_SYNC_ROLE_VOTER; tstrncpy(pNode->nodeFqdn, pCreate->replicas[pCfg->syncCfg.replicaNum].fqdn, TSDB_FQDN_LEN); - tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); pCfg->syncCfg.replicaNum++; } if (pCreate->selfIndex != -1) { @@ -212,7 +212,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pNode->nodePort = pCreate->learnerReplicas[pCfg->syncCfg.totalReplicaNum].port; pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER; tstrncpy(pNode->nodeFqdn, pCreate->learnerReplicas[pCfg->syncCfg.totalReplicaNum].fqdn, TSDB_FQDN_LEN); - tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); pCfg->syncCfg.totalReplicaNum++; } pCfg->syncCfg.totalReplicaNum += pCfg->syncCfg.replicaNum; @@ -323,7 +323,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnodeImpl(pMgmt, req.vgId, false); if (pVnode != NULL && (req.replica == 1 || !pVnode->failed)) { dError("vgId:%d, already exist", req.vgId); - tFreeSCreateVnodeReq(&req); + (void)tFreeSCreateVnodeReq(&req); vmReleaseVnode(pMgmt, pVnode); code = TSDB_CODE_VND_ALREADY_EXIST; return 0; @@ -340,7 +340,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { if (vnodeCreate(path, &vnodeCfg, diskPrimary, pMgmt->pTfs) < 0) { dError("vgId:%d, failed to create vnode since %s", req.vgId, terrstr()); vmReleaseVnode(pMgmt, pVnode); - tFreeSCreateVnodeReq(&req); + (void)tFreeSCreateVnodeReq(&req); code = terrno != 0 ? terrno : -1; return code; } @@ -374,14 +374,14 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { goto _OVER; } - //taosThreadMutexLock(&pMgmt->createLock); + // taosThreadMutexLock(&pMgmt->createLock); code = vmWriteVnodeListToFile(pMgmt); if (code != 0) { code = terrno != 0 ? terrno : code; - //taosThreadMutexUnlock(&pMgmt->createLock); + // taosThreadMutexUnlock(&pMgmt->createLock); goto _OVER; } - //taosThreadMutexUnlock(&pMgmt->createLock); + // taosThreadMutexUnlock(&pMgmt->createLock); _OVER: if (code != 0) { @@ -392,7 +392,7 @@ _OVER: TMSG_INFO(pMsg->msgType)); } - tFreeSCreateVnodeReq(&req); + (void)tFreeSCreateVnodeReq(&req); terrno = code; return code; } @@ -779,10 +779,11 @@ int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { + int32_t code = 0; SDropVnodeReq dropReq = {0}; if (tDeserializeSDropVnodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - return -1; + return terrno; } int32_t vgId = dropReq.vgId; @@ -791,25 +792,25 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { if (dropReq.dnodeId != pMgmt->pData->dnodeId) { terrno = TSDB_CODE_INVALID_MSG; dError("vgId:%d, dnodeId:%d not matched with local dnode", dropReq.vgId, dropReq.dnodeId); - return -1; + return terrno; } SVnodeObj *pVnode = vmAcquireVnodeImpl(pMgmt, vgId, false); if (pVnode == NULL) { dInfo("vgId:%d, failed to drop since %s", vgId, terrstr()); terrno = TSDB_CODE_VND_NOT_EXIST; - return -1; + return terrno; } pVnode->dropped = 1; - if (vmWriteVnodeListToFile(pMgmt) != 0) { + if ((code = vmWriteVnodeListToFile(pMgmt)) != 0) { pVnode->dropped = 0; vmReleaseVnode(pMgmt, pVnode); - return -1; + return code; } vmCloseVnode(pMgmt, pVnode, false); - vmWriteVnodeListToFile(pMgmt); + (void)vmWriteVnodeListToFile(pMgmt); dInfo("vgId:%d, is dropped", vgId); return 0; @@ -864,7 +865,7 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { continue; } - taosArrayPush(arbHbRsp.hbMembers, &rspMember); + (void)taosArrayPush(arbHbRsp.hbMembers, &rspMember); vmReleaseVnode(pMgmt, pVnode); } @@ -895,7 +896,7 @@ int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { _OVER: tFreeSVArbHeartBeatReq(&arbHbReq); tFreeSVArbHeartBeatRsp(&arbHbRsp); - return terrno == TSDB_CODE_SUCCESS ? 0 : -1; + return terrno; } SArray *vmGetMsgHandles() { diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 41ee392b4d..6bc0b5fe93 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -23,12 +23,12 @@ int32_t vmGetPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) { int32_t diskId = -1; SVnodeObj *pVnode = NULL; - taosThreadRwlockRdlock(&pMgmt->lock); - taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode); + (void)taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode); if (pVnode != NULL) { diskId = pVnode->diskPrimary; } - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); return diskId; } @@ -96,8 +96,8 @@ int32_t vmAllocPrimaryDisk(SVnodeMgmt *pMgmt, int32_t vgId) { SVnodeObj *vmAcquireVnodeImpl(SVnodeMgmt *pMgmt, int32_t vgId, bool strict) { SVnodeObj *pVnode = NULL; - taosThreadRwlockRdlock(&pMgmt->lock); - taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode); + (void)taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosHashGetDup(pMgmt->hash, &vgId, sizeof(int32_t), (void *)&pVnode); if (pVnode == NULL || strict && (pVnode->dropped || pVnode->failed)) { terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; pVnode = NULL; @@ -105,7 +105,7 @@ SVnodeObj *vmAcquireVnodeImpl(SVnodeMgmt *pMgmt, int32_t vgId, bool strict) { int32_t refCount = atomic_add_fetch_32(&pVnode->refCount, 1); // dTrace("vgId:%d, acquire vnode, ref:%d", pVnode->vgId, refCount); } - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); return pVnode; } @@ -115,10 +115,10 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) { return vmAcquireVno void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { if (pVnode == NULL) return; - taosThreadRwlockRdlock(&pMgmt->lock); + (void)taosThreadRwlockRdlock(&pMgmt->lock); int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1); // dTrace("vgId:%d, release vnode, ref:%d", pVnode->vgId, refCount); - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); } static void vmFreeVnodeObj(SVnodeObj **ppVnode) { @@ -163,15 +163,15 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) { pVnode->failed = 1; } - taosThreadRwlockWrlock(&pMgmt->lock); + (void)taosThreadRwlockWrlock(&pMgmt->lock); SVnodeObj *pOld = NULL; - taosHashGetDup(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), (void *)&pOld); + (void)taosHashGetDup(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), (void *)&pOld); if (pOld) { ASSERT(pOld->failed); vmFreeVnodeObj(&pOld); } int32_t code = taosHashPut(pMgmt->hash, &pVnode->vgId, sizeof(int32_t), &pVnode, sizeof(SVnodeObj *)); - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockUnlock(&pMgmt->lock); return code; } @@ -184,9 +184,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) vnodeProposeCommitOnNeed(pVnode->pImpl, atExit); } - taosThreadRwlockWrlock(&pMgmt->lock); - taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t)); - taosThreadRwlockUnlock(&pMgmt->lock); + (void)taosThreadRwlockWrlock(&pMgmt->lock); + (void)taosHashRemove(pMgmt->hash, &pVnode->vgId, sizeof(int32_t)); + (void)taosThreadRwlockUnlock(&pMgmt->lock); vmReleaseVnode(pMgmt, pVnode); if (pVnode->failed) { @@ -235,8 +235,8 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) if (commitAndRemoveWal) { dInfo("vgId:%d, commit data for vnode split", pVnode->vgId); - vnodeSyncCommit(pVnode->pImpl); - vnodeBegin(pVnode->pImpl); + (void)vnodeSyncCommit(pVnode->pImpl); + (void)vnodeBegin(pVnode->pImpl); dInfo("vgId:%d, commit data finished", pVnode->vgId); } @@ -250,8 +250,8 @@ _closed: if (commitAndRemoveWal) { snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d%swal", TD_DIRSEP, pVnode->vgId, TD_DIRSEP); dInfo("vgId:%d, remove all wals, path:%s", pVnode->vgId, path); - tfsRmdir(pMgmt->pTfs, path); - tfsMkdir(pMgmt->pTfs, path); + (void)tfsRmdir(pMgmt->pTfs, path); + (void)tfsMkdir(pMgmt->pTfs, path); } if (pVnode->dropped) { @@ -332,7 +332,7 @@ static void *vmOpenVnodeInThread(void *param) { dInfo("vgId:%d, is opened by thread:%d", pCfg->vgId, pThread->threadIndex); pThread->opened++; - atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); + (void)atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); } dInfo("thread:%d, numOfVnodes:%d, opened:%d failed:%d", pThread->threadIndex, pThread->vnodeNum, pThread->opened, @@ -381,13 +381,13 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) { if (pThread->vnodeNum == 0) continue; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pThread->thread, &thAttr, vmOpenVnodeInThread, pThread) != 0) { dError("thread:%d, failed to create thread to open vnode, reason:%s", pThread->threadIndex, strerror(errno)); } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); } bool updateVnodesList = false; @@ -395,7 +395,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) { for (int32_t t = 0; t < threadNum; ++t) { SVnodeThread *pThread = &threads[t]; if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) { - taosThreadJoin(pThread->thread, NULL); + (void)taosThreadJoin(pThread->thread, NULL); taosThreadClear(&pThread->thread); } taosMemoryFree(pThread->pCfgs); @@ -484,19 +484,19 @@ static void vmCloseVnodes(SVnodeMgmt *pMgmt) { if (pThread->vnodeNum == 0) continue; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pThread->thread, &thAttr, vmCloseVnodeInThread, pThread) != 0) { dError("thread:%d, failed to create thread to close vnode since %s", pThread->threadIndex, strerror(errno)); } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); } for (int32_t t = 0; t < threadNum; ++t) { SVnodeThread *pThread = &threads[t]; if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) { - taosThreadJoin(pThread->thread, NULL); + (void)taosThreadJoin(pThread->thread, NULL); taosThreadClear(&pThread->thread); } taosMemoryFree(pThread->ppVnodes); @@ -519,8 +519,8 @@ static void vmCleanup(SVnodeMgmt *pMgmt) { vmCloseVnodes(pMgmt); vmStopWorker(pMgmt); vnodeCleanup(); - taosThreadRwlockDestroy(&pMgmt->lock); - taosThreadMutexDestroy(&pMgmt->createLock); + (void)taosThreadRwlockDestroy(&pMgmt->lock); + (void)taosThreadMutexDestroy(&pMgmt->createLock); taosMemoryFree(pMgmt); } @@ -569,22 +569,22 @@ static void *vmThreadFp(void *param) { static int32_t vmInitTimer(SVnodeMgmt *pMgmt) { int32_t code = 0; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pMgmt->thread, &thAttr, vmThreadFp, pMgmt) != 0) { code = TAOS_SYSTEM_ERROR(errno); dError("failed to create vnode timer thread since %s", tstrerror(code)); return code; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); return 0; } static void vmCleanupTimer(SVnodeMgmt *pMgmt) { pMgmt->stop = true; if (taosCheckPthreadValid(pMgmt->thread)) { - taosThreadJoin(pMgmt->thread, NULL); + (void)taosThreadJoin(pMgmt->thread, NULL); taosThreadClear(&pMgmt->thread); } } @@ -707,7 +707,7 @@ static void *vmRestoreVnodeInThread(void *param) { } else { dInfo("vgId:%d, is restored by thread:%d", pVnode->vgId, pThread->threadIndex); pThread->opened++; - atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); + (void)atomic_add_fetch_32(&pMgmt->state.openVnodes, 1); } } @@ -761,20 +761,20 @@ static int32_t vmStartVnodes(SVnodeMgmt *pMgmt) { if (pThread->vnodeNum == 0) continue; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pThread->thread, &thAttr, vmRestoreVnodeInThread, pThread) != 0) { dError("thread:%d, failed to create thread to restore vnode since %s", pThread->threadIndex, strerror(errno)); ASSERT(errno == 0); } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); } for (int32_t t = 0; t < threadNum; ++t) { SVnodeThread *pThread = &threads[t]; if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) { - taosThreadJoin(pThread->thread, NULL); + (void)taosThreadJoin(pThread->thread, NULL); taosThreadClear(&pThread->thread); } taosMemoryFree(pThread->ppVnodes); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 4eaaf02573..2ad5464c31 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -187,7 +187,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf static void vmSendResponse(SRpcMsg *pMsg) { if (pMsg->info.handle) { SRpcMsg rsp = {.info = pMsg->info, .code = terrno}; - rpcSendResponse(&rsp); + (void)rpcSendResponse(&rsp); } } @@ -236,7 +236,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp dError("vgId:%d, msg:%p preprocess query msg failed since %s", pVnode->vgId, pMsg, tstrerror(code)); } else { dGTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg); - taosWriteQitem(pVnode->pQueryQ, pMsg); + code = taosWriteQitem(pVnode->pQueryQ, pMsg); } break; case STREAM_QUEUE: diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index e6e065756f..9819c4f64e 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -47,8 +47,8 @@ static int32_t dmCheckRepeatInit(SDnode *pDnode) { } static int32_t dmInitSystem() { - taosIgnSIGPIPE(); - taosBlockSIGPIPE(); + (void)taosIgnSIGPIPE(); + (void)taosBlockSIGPIPE(); taosResolveCRC(); return 0; } @@ -200,10 +200,10 @@ void dmCleanup() { auditCleanup(); syncCleanUp(); walCleanUp(); - udfcClose(); + (void)udfcClose(); udfStopUdfd(); taosStopCacheRefreshWorker(); - dmDiskClose(); + (void)dmDiskClose(); DestroyRegexCache(); #if defined(USE_S3) diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index ccbfeb5aa5..fdce9fd4c9 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -47,7 +47,8 @@ int32_t dmInitDnode(SDnode *pDnode) { } // compress module init - tsCompressInit(tsLossyColumns, tsFPrecision, tsDPrecision, tsMaxRange, tsCurRange, (int)tsIfAdtFse, tsCompressor); + (void)tsCompressInit(tsLossyColumns, tsFPrecision, tsDPrecision, tsMaxRange, tsCurRange, (int)tsIfAdtFse, + tsCompressor); pDnode->wrappers[DNODE].func = dmGetMgmtFunc(); pDnode->wrappers[MNODE].func = mmGetMgmtFunc(); @@ -60,7 +61,7 @@ int32_t dmInitDnode(SDnode *pDnode) { pWrapper->pDnode = pDnode; pWrapper->name = dmNodeName(ntype); pWrapper->ntype = ntype; - taosThreadRwlockInit(&pWrapper->lock, NULL); + (void)taosThreadRwlockInit(&pWrapper->lock, NULL); snprintf(path, sizeof(path), "%s%s%s", tsDataDir, TD_DIRSEP, pWrapper->name); pWrapper->path = taosStrdup(path); @@ -214,8 +215,8 @@ int32_t dmInitVars(SDnode *pDnode) { return -1; } - taosThreadRwlockInit(&pData->lock, NULL); - taosThreadMutexInit(&pDnode->mutex, NULL); + (void)taosThreadRwlockInit(&pData->lock, NULL); + (void)taosThreadMutexInit(&pDnode->mutex, NULL); return 0; } @@ -223,16 +224,16 @@ void dmClearVars(SDnode *pDnode) { for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; taosMemoryFreeClear(pWrapper->path); - taosThreadRwlockDestroy(&pWrapper->lock); + (void)taosThreadRwlockDestroy(&pWrapper->lock); } if (pDnode->lockfile != NULL) { - taosUnLockFile(pDnode->lockfile); - taosCloseFile(&pDnode->lockfile); + (void)taosUnLockFile(pDnode->lockfile); + (void)taosCloseFile(&pDnode->lockfile); pDnode->lockfile = NULL; } SDnodeData *pData = &pDnode->data; - taosThreadRwlockWrlock(&pData->lock); + (void)taosThreadRwlockWrlock(&pData->lock); if (pData->oldDnodeEps != NULL) { if (dmWriteEps(pData) == 0) { dmRemoveDnodePairs(pData); @@ -248,10 +249,10 @@ void dmClearVars(SDnode *pDnode) { taosHashCleanup(pData->dnodeHash); pData->dnodeHash = NULL; } - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); - taosThreadRwlockDestroy(&pData->lock); - taosThreadMutexDestroy(&pDnode->mutex); + (void)taosThreadRwlockDestroy(&pData->lock); + (void)taosThreadMutexDestroy(&pDnode->mutex); memset(&pDnode->mutex, 0, sizeof(pDnode->mutex)); } @@ -266,14 +267,14 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) { SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; SMgmtWrapper *pRetWrapper = pWrapper; - taosThreadRwlockRdlock(&pWrapper->lock); + (void)taosThreadRwlockRdlock(&pWrapper->lock); if (pWrapper->deployed) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); // dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount); } else { pRetWrapper = NULL; } - taosThreadRwlockUnlock(&pWrapper->lock); + (void)taosThreadRwlockUnlock(&pWrapper->lock); return pRetWrapper; } @@ -281,7 +282,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) { int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) { int32_t code = 0; - taosThreadRwlockRdlock(&pWrapper->lock); + (void)taosThreadRwlockRdlock(&pWrapper->lock); if (pWrapper->deployed) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); // dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount); @@ -304,7 +305,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) { break; } } - taosThreadRwlockUnlock(&pWrapper->lock); + (void)taosThreadRwlockUnlock(&pWrapper->lock); return code; } @@ -312,9 +313,9 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) { void dmReleaseWrapper(SMgmtWrapper *pWrapper) { if (pWrapper == NULL) return; - taosThreadRwlockRdlock(&pWrapper->lock); + (void)taosThreadRwlockRdlock(&pWrapper->lock); int32_t refCount = atomic_sub_fetch_32(&pWrapper->refCount, 1); - taosThreadRwlockUnlock(&pWrapper->lock); + (void)taosThreadRwlockUnlock(&pWrapper->lock); // dTrace("node:%s, is released, ref:%d", pWrapper->name, refCount); } @@ -343,7 +344,7 @@ void dmProcessNetTestReq(SDnode *pDnode, SRpcMsg *pMsg) { rsp.contLen = pMsg->contLen; } - rpcSendResponse(&rsp); + (void)rpcSendResponse(&rsp); rpcFreeCont(pMsg->pCont); } @@ -360,11 +361,11 @@ void dmProcessServerStartupStatus(SDnode *pDnode, SRpcMsg *pMsg) { } else { rsp.pCont = rpcMallocCont(contLen); if (rsp.pCont != NULL) { - tSerializeSServerStatusRsp(rsp.pCont, contLen, &statusRsp); + (void)tSerializeSServerStatusRsp(rsp.pCont, contLen, &statusRsp); rsp.contLen = contLen; } } - rpcSendResponse(&rsp); + (void)rpcSendResponse(&rsp); rpcFreeCont(pMsg->pCont); } diff --git a/source/dnode/mgmt/node_mgmt/src/dmNodes.c b/source/dnode/mgmt/node_mgmt/src/dmNodes.c index 175e470b4a..38bd9f6b92 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmNodes.c +++ b/source/dnode/mgmt/node_mgmt/src/dmNodes.c @@ -77,12 +77,12 @@ void dmCloseNode(SMgmtWrapper *pWrapper) { taosMsleep(10); } - taosThreadRwlockWrlock(&pWrapper->lock); + (void)taosThreadRwlockWrlock(&pWrapper->lock); if (pWrapper->pMgmt != NULL) { (*pWrapper->func.closeFp)(pWrapper->pMgmt); pWrapper->pMgmt = NULL; } - taosThreadRwlockUnlock(&pWrapper->lock); + (void)taosThreadRwlockUnlock(&pWrapper->lock); dInfo("node:%s, has been closed", pWrapper->name); } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index f0fa497eec..3d758e1fd3 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -18,18 +18,22 @@ #include "qworker.h" #include "tversion.h" -static inline void dmSendRsp(SRpcMsg *pMsg) { rpcSendResponse(pMsg); } +static inline void dmSendRsp(SRpcMsg *pMsg) { (void)rpcSendResponse(pMsg); } static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) { SEpSet epSet = {0}; dmGetMnodeEpSetForRedirect(&pDnode->data, pMsg, &epSet); - const int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); + int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); pMsg->pCont = rpcMallocCont(contLen); if (pMsg->pCont == NULL) { pMsg->code = TSDB_CODE_OUT_OF_MEMORY; } else { - tSerializeSEpSet(pMsg->pCont, contLen, &epSet); + contLen = tSerializeSEpSet(pMsg->pCont, contLen, &epSet); + if (contLen < 0) { + pMsg->code = contLen; + return; + } pMsg->contLen = contLen; } } @@ -65,13 +69,17 @@ static int32_t dmConvertErrCode(tmsg_t msgType, int32_t code) { return code; } static void dmUpdateRpcIpWhite(SDnodeData *pData, void *pTrans, SRpcMsg *pRpc) { + int32_t code = 0; SUpdateIpWhite ipWhite = {0}; // aosMemoryCalloc(1, sizeof(SUpdateIpWhite)); - tDeserializeSUpdateIpWhite(pRpc->pCont, pRpc->contLen, &ipWhite); - - rpcSetIpWhite(pTrans, &ipWhite); + code = tDeserializeSUpdateIpWhite(pRpc->pCont, pRpc->contLen, &ipWhite); + if (code < 0) { + dError("failed to update rpc ip-white since: %s", tstrerror(code)); + return; + } + code = rpcSetIpWhite(pTrans, &ipWhite); pData->ipWhiteVer = ipWhite.ver; - tFreeSUpdateIpWhiteReq(&ipWhite); + (void)tFreeSUpdateIpWhiteReq(&ipWhite); rpcFreeCont(pRpc->pCont); } @@ -80,7 +88,7 @@ static bool dmIsForbiddenIp(int8_t forbidden, char *user, uint32_t clientIp) { SIpV4Range range = {.ip = clientIp, .mask = 32}; char buf[36] = {0}; - rpcUtilSIpRangeToStr(&range, buf); + (void)rpcUtilSIpRangeToStr(&range, buf); dError("User:%s host:%s not in ip white list", user, buf); return true; } else { @@ -99,7 +107,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { pRpc->info.handle, pRpc->contLen, pRpc->code, pRpc->info.ahandle, pRpc->info.refId); int32_t svrVer = 0; - taosVersionStrToInt(version, &svrVer); + (void)taosVersionStrToInt(version, &svrVer); if ((code = taosCheckVersionCompatible(pRpc->info.cliVer, svrVer, 3)) != 0) { dError("Version not compatible, cli ver: %d, svr ver: %d", pRpc->info.cliVer, svrVer); goto _OVER; @@ -238,7 +246,7 @@ _OVER: if (pWrapper != NULL) { dmSendRsp(&rsp); } else { - rpcSendResponse(&rsp); + (void)rpcSendResponse(&rsp); } } @@ -295,7 +303,7 @@ static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { return code; } else { pMsg->info.handle = 0; - rpcSendRequest(pDnode->trans.clientRpc, pEpSet, pMsg, NULL); + (void)rpcSendRequest(pDnode->trans.clientRpc, pEpSet, pMsg, NULL); return 0; } } @@ -314,14 +322,13 @@ static inline int32_t dmSendSyncReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { pMsg->info.handle); return code; } else { - rpcSendRequest(pDnode->trans.syncRpc, pEpSet, pMsg, NULL); - return 0; + return rpcSendRequest(pDnode->trans.syncRpc, pEpSet, pMsg, NULL); } } -static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { rpcRegisterBrokenLinkArg(pMsg); } +static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { (void)rpcRegisterBrokenLinkArg(pMsg); } -static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcReleaseHandle(pHandle, type); } +static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { (void)rpcReleaseHandle(pHandle, type); } static bool rpcRfp(int32_t code, tmsg_t msgType) { if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND || @@ -381,7 +388,7 @@ int32_t dmInitClient(SDnode *pDnode) { rpcInit.batchSize = 8 * 1024; rpcInit.timeToGetConn = tsTimeToGetAvailableConn; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + (void)taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); pTrans->clientRpc = rpcOpen(&rpcInit); if (pTrans->clientRpc == NULL) { @@ -425,7 +432,7 @@ int32_t dmInitStatusClient(SDnode *pDnode) { rpcInit.supportBatch = 1; rpcInit.batchSize = 8 * 1024; rpcInit.timeToGetConn = tsTimeToGetAvailableConn; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + (void)taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); pTrans->statusRpc = rpcOpen(&rpcInit); if (pTrans->statusRpc == NULL) { @@ -470,7 +477,7 @@ int32_t dmInitSyncClient(SDnode *pDnode) { rpcInit.supportBatch = 1; rpcInit.batchSize = 8 * 1024; rpcInit.timeToGetConn = tsTimeToGetAvailableConn; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + (void)taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); pTrans->syncRpc = rpcOpen(&rpcInit); if (pTrans->syncRpc == NULL) { @@ -521,7 +528,7 @@ int32_t dmInitServer(SDnode *pDnode) { rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.parent = pDnode; rpcInit.compressSize = tsCompressMsgSize; - taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); + (void)taosVersionStrToInt(version, &(rpcInit.compatibilityVer)); pTrans->serverRpc = rpcOpen(&rpcInit); if (pTrans->serverRpc == NULL) { dError("failed to init dnode rpc server"); diff --git a/source/dnode/mgmt/node_util/src/dmEps.c b/source/dnode/mgmt/node_util/src/dmEps.c index 866dce1b87..af5530215b 100644 --- a/source/dnode/mgmt/node_util/src/dmEps.c +++ b/source/dnode/mgmt/node_util/src/dmEps.c @@ -33,7 +33,7 @@ static int32_t dmReadDnodePairs(SDnodeData *pData); void dmGetDnodeEp(void *data, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) { SDnodeData *pData = data; - taosThreadRwlockRdlock(&pData->lock); + (void)taosThreadRwlockRdlock(&pData->lock); SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t)); if (pDnodeEp != NULL) { @@ -48,7 +48,7 @@ void dmGetDnodeEp(void *data, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t } } - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); } static int32_t dmDecodeEps(SJson *pJson, SDnodeData *pData) { @@ -255,8 +255,8 @@ _OVER: if (taosArrayGetSize(pData->dnodeEps) == 0) { SDnodeEp dnodeEp = {0}; dnodeEp.isMnode = 1; - taosGetFqdnPortFromEp(tsFirst, &dnodeEp.ep); - taosArrayPush(pData->dnodeEps, &dnodeEp); + (void)taosGetFqdnPortFromEp(tsFirst, &dnodeEp.ep); + (void)taosArrayPush(pData->dnodeEps, &dnodeEp); } if ((code = dmReadDnodePairs(pData)) != 0) { @@ -337,7 +337,7 @@ int32_t dmWriteEps(SDnodeData *pData) { if (taosWriteFile(pFile, buffer, len) <= 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER); if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); if (taosRenameFile(file, realfile) != 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _OVER); code = 0; @@ -348,7 +348,7 @@ int32_t dmWriteEps(SDnodeData *pData) { _OVER: if (pJson != NULL) tjsonDelete(pJson); if (buffer != NULL) taosMemoryFree(buffer); - if (pFile != NULL) taosCloseFile(&pFile); + if (pFile != NULL) (void)taosCloseFile(&pFile); if (code != 0) { dError("failed to write dnode file:%s since %s, dnodeVer:%" PRId64, realfile, tstrerror(code), pData->dnodeVer); @@ -358,18 +358,18 @@ _OVER: int32_t dmGetDnodeSize(SDnodeData *pData) { int32_t size = 0; - taosThreadRwlockRdlock(&pData->lock); + (void)taosThreadRwlockRdlock(&pData->lock); size = taosArrayGetSize(pData->dnodeEps); - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); return size; } void dmUpdateEps(SDnodeData *pData, SArray *eps) { - taosThreadRwlockWrlock(&pData->lock); + (void)taosThreadRwlockWrlock(&pData->lock); dDebug("new dnode list get from mnode, dnodeVer:%" PRId64, pData->dnodeVer); dmResetEps(pData, eps); - dmWriteEps(pData); - taosThreadRwlockUnlock(&pData->lock); + (void)dmWriteEps(pData); + (void)taosThreadRwlockUnlock(&pData->lock); } static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) { @@ -398,7 +398,7 @@ static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) { for (int32_t i = 0; i < numOfEps; i++) { SDnodeEp *pDnodeEp = taosArrayGet(dnodeEps, i); - taosHashPut(pData->dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp)); + (void)taosHashPut(pData->dnodeHash, &pDnodeEp->id, sizeof(int32_t), pDnodeEp, sizeof(SDnodeEp)); } pData->validMnodeEps = true; @@ -418,7 +418,7 @@ static void dmPrintEps(SDnodeData *pData) { static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) { bool changed = false; if (dnodeId == 0) return changed; - taosThreadRwlockRdlock(&pData->lock); + (void)taosThreadRwlockRdlock(&pData->lock); SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t)); if (pDnodeEp != NULL) { @@ -430,14 +430,14 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) { } } - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); return changed; } void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) { - taosThreadRwlockRdlock(&pData->lock); + (void)taosThreadRwlockRdlock(&pData->lock); *pEpSet = pData->mnodeEps; - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); } void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) { @@ -464,12 +464,12 @@ static FORCE_INLINE void dmSwapEps(SEp *epLhs, SEp *epRhs) { } void dmRotateMnodeEpSet(SDnodeData *pData) { - taosThreadRwlockRdlock(&pData->lock); + (void)taosThreadRwlockRdlock(&pData->lock); SEpSet *pEpSet = &pData->mnodeEps; for (int i = 1; i < pEpSet->numOfEps; i++) { dmSwapEps(&pEpSet->eps[i - 1], &pEpSet->eps[i]); } - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); } void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet) { @@ -486,9 +486,9 @@ void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) { if (memcmp(pEpSet, &pData->mnodeEps, sizeof(SEpSet)) == 0) return; - taosThreadRwlockWrlock(&pData->lock); + (void)taosThreadRwlockWrlock(&pData->lock); pData->mnodeEps = *pEpSet; - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); dInfo("mnode is changed, num:%d use:%d", pEpSet->numOfEps, pEpSet->inUse); for (int32_t i = 0; i < pEpSet->numOfEps; ++i) { @@ -502,7 +502,7 @@ bool dmUpdateDnodeInfo(void *data, int32_t *did, int64_t *clusterId, char *fqdn, int32_t dnodeId = -1; if (did != NULL) dnodeId = *did; - taosThreadRwlockRdlock(&pData->lock); + (void)taosThreadRwlockRdlock(&pData->lock); if (pData->oldDnodeEps != NULL) { int32_t size = (int32_t)taosArrayGetSize(pData->oldDnodeEps); @@ -542,7 +542,7 @@ bool dmUpdateDnodeInfo(void *data, int32_t *did, int64_t *clusterId, char *fqdn, } } - taosThreadRwlockUnlock(&pData->lock); + (void)taosThreadRwlockUnlock(&pData->lock); return updated; } @@ -550,26 +550,26 @@ static int32_t dmDecodeEpPairs(SJson *pJson, SDnodeData *pData) { int32_t code = 0; SJson *dnodes = tjsonGetObjectItem(pJson, "dnodes"); - if (dnodes == NULL) return -1; + if (dnodes == NULL) return TSDB_CODE_INVALID_CFG_VALUE; int32_t numOfDnodes = tjsonGetArraySize(dnodes); for (int32_t i = 0; i < numOfDnodes; ++i) { SJson *dnode = tjsonGetArrayItem(dnodes, i); - if (dnode == NULL) return -1; + if (dnode == NULL) return TSDB_CODE_INVALID_CFG_VALUE; SDnodeEpPair pair = {0}; tjsonGetInt32ValueFromDouble(dnode, "id", pair.id, code); - if (code < 0) return -1; + if (code < 0) return TSDB_CODE_INVALID_CFG_VALUE; code = tjsonGetStringValue(dnode, "fqdn", pair.oldFqdn); - if (code < 0) return -1; + if (code < 0) return TSDB_CODE_INVALID_CFG_VALUE; tjsonGetUInt16ValueFromDouble(dnode, "port", pair.oldPort, code); - if (code < 0) return -1; + if (code < 0) return TSDB_CODE_INVALID_CFG_VALUE; code = tjsonGetStringValue(dnode, "new_fqdn", pair.newFqdn); - if (code < 0) return -1; + if (code < 0) return TSDB_CODE_INVALID_CFG_VALUE; tjsonGetUInt16ValueFromDouble(dnode, "new_port", pair.newPort, code); - if (code < 0) return -1; + if (code < 0) return TSDB_CODE_INVALID_CFG_VALUE; - if (taosArrayPush(pData->oldDnodeEps, &pair) == NULL) return -1; + if (taosArrayPush(pData->oldDnodeEps, &pair) == NULL) return TSDB_CODE_OUT_OF_MEMORY; } return code; diff --git a/source/dnode/mgmt/node_util/src/dmFile.c b/source/dnode/mgmt/node_util/src/dmFile.c index eee6ab3a41..c8b24d5469 100644 --- a/source/dnode/mgmt/node_util/src/dmFile.c +++ b/source/dnode/mgmt/node_util/src/dmFile.c @@ -211,7 +211,7 @@ int32_t dmCheckRunning(const char *dataDir, TdFilePtr *pFile) { if (ret < 0) { code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(pFile); + (void)taosCloseFile(pFile); *pFile = NULL; return code; } @@ -239,7 +239,7 @@ static int32_t dmWriteCheckCodeFile(char *file, char *realfile, char *key, bool opts.source = DM_KEY_INDICATOR; opts.result = result; opts.unitLen = 16; - CBC_Encrypt(&opts); + (void)CBC_Encrypt(&opts); pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH); if (pFile == NULL) { @@ -359,7 +359,7 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) { opts.source = content; opts.result = result; opts.unitLen = 16; - CBC_Decrypt(&opts); + (void)CBC_Decrypt(&opts); if (strcmp(opts.result, DM_KEY_INDICATOR) != 0) { code = TSDB_CODE_DNODE_ENCRYPTKEY_CHANGED; diff --git a/source/dnode/mgmt/node_util/src/dmUtil.c b/source/dnode/mgmt/node_util/src/dmUtil.c index bab7d068f3..68f4c9d0ff 100644 --- a/source/dnode/mgmt/node_util/src/dmUtil.c +++ b/source/dnode/mgmt/node_util/src/dmUtil.c @@ -57,8 +57,8 @@ void *dmSetMgmtHandle(SArray *pArray, tmsg_t msgType, void *nodeMsgFp, bool need void dmGetMonitorSystemInfo(SMonSysInfo *pInfo) { taosGetCpuUsage(&pInfo->cpu_system, &pInfo->cpu_engine); taosGetCpuCores(&pInfo->cpu_cores, false); - taosGetProcMemory(&pInfo->mem_engine); - taosGetSysMemory(&pInfo->mem_system); + (void)taosGetProcMemory(&pInfo->mem_engine); + (void)taosGetSysMemory(&pInfo->mem_system); pInfo->mem_total = tsTotalMemoryKB; pInfo->disk_engine = 0; pInfo->disk_used = tsDataSpace.size.used; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 973215fdbd..a307e3557b 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1892,13 +1892,21 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp)); if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES); if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) { - rsp.dbTsmaVersion = pDb->tsmaVersion; bool exist = false; - if (mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist) != 0) { + int32_t code = mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist); + if (TSDB_CODE_SUCCESS != code) { mndReleaseDb(pMnode, pDb); - mError("db:%s, failed to get db tsmas", pDb->name); + if (code != TSDB_CODE_NEED_RETRY) { + mError("db:%s, failed to get db tsmas", pDb->name); + } else { + mWarn("db:%s, need retry to get db tsmas", pDb->name); + } + taosArrayDestroyP(rsp.pTsmaRsp->pTsmas, tFreeAndClearTableTSMAInfo); + taosMemoryFreeClear(rsp.pTsmaRsp); continue; } + rsp.dbTsmaVersion = pDb->tsmaVersion; + mDebug("update tsma version to %d, got tsma num: %ld", pDb->tsmaVersion, rsp.pTsmaRsp->pTsmas->size); } } @@ -1909,6 +1917,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, if (rsp.useDbRsp->pVgroupInfos == NULL) { mndReleaseDb(pMnode, pDb); mError("db:%s, failed to malloc usedb response", pDb->name); + taosArrayDestroyP(rsp.pTsmaRsp->pTsmas, tFreeAndClearTableTSMAInfo); + taosMemoryFreeClear(rsp.pTsmaRsp); continue; } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index b02f754943..3e70bb20cd 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -185,8 +185,8 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER); code = 0; - mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, - 1); // TODO: check the return value + (void)mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, + 1); // TODO: check the return value _OVER: mndTransDrop(pTrans); @@ -916,7 +916,8 @@ static int32_t mndCreateDnode(SMnode *pMnode, SRpcMsg *pReq, SCreateDnodeReq *pC TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER); code = 0; - mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, 1); // TODO: check the return value + (void)mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, dnodeObj.fqdn, IP_WHITE_ADD, + 1); // TODO: check the return value _OVER: mndTransDrop(pTrans); sdbFreeRaw(pRaw); @@ -1231,7 +1232,8 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM TAOS_CHECK_GOTO(mndTransPrepare(pMnode, pTrans), NULL, _OVER); - mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, pDnode->fqdn, IP_WHITE_DROP, 1); // TODO: check the return value + (void)mndUpdateIpWhiteForAllUser(pMnode, TSDB_DEFAULT_USER, pDnode->fqdn, IP_WHITE_DROP, + 1); // TODO: check the return value code = 0; _OVER: @@ -1749,7 +1751,7 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB #ifdef TD_ENTERPRISE STR_TO_VARSTR(buf, pDnode->machineId); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, buf, false); + (void)colDataSetVal(pColInfo, numOfRows, buf, false); #endif numOfRows++; diff --git a/source/dnode/mnode/impl/src/mndDump.c b/source/dnode/mnode/impl/src/mndDump.c index ca7b5bbac6..31e092f1a4 100644 --- a/source/dnode/mnode/impl/src/mndDump.c +++ b/source/dnode/mnode/impl/src/mndDump.c @@ -74,7 +74,7 @@ void dumpFunc(SSdb *pSdb, SJson *json) { void dumpDb(SSdb *pSdb, SJson *json) { void *pIter = NULL; SJson *items = tjsonCreateObject(); - tjsonAddItemToObject(json, "dbs", items); + (void)tjsonAddItemToObject(json, "dbs", items); while (1) { SDbObj *pObj = NULL; @@ -82,7 +82,7 @@ void dumpDb(SSdb *pSdb, SJson *json) { if (pIter == NULL) break; SJson *item = tjsonCreateObject(); - tjsonAddItemToObject(items, "db", item); + (void)tjsonAddItemToObject(items, "db", item); (void)tjsonAddStringToObject(item, "name", mndGetDbStr(pObj->name)); (void)tjsonAddStringToObject(item, "acct", pObj->acct); @@ -546,7 +546,7 @@ void dumpHeader(SSdb *pSdb, SJson *json) { (void)tjsonAddStringToObject(json, "applyConfig", i642str(pSdb->applyConfig)); SJson *maxIdsJson = tjsonCreateObject(); - tjsonAddItemToObject(json, "maxIds", maxIdsJson); + (void)tjsonAddItemToObject(json, "maxIds", maxIdsJson); for (int32_t i = 0; i < SDB_MAX; ++i) { if(i == 5) continue; int64_t maxId = 0; @@ -557,7 +557,7 @@ void dumpHeader(SSdb *pSdb, SJson *json) { } SJson *tableVersJson = tjsonCreateObject(); - tjsonAddItemToObject(json, "tableVers", tableVersJson); + (void)tjsonAddItemToObject(json, "tableVers", tableVersJson); for (int32_t i = 0; i < SDB_MAX; ++i) { int64_t tableVer = 0; if (i < SDB_MAX) { @@ -581,8 +581,8 @@ void mndDumpSdb() { msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack tmsgSetDefault(&msgCb); - walInit(); - syncInit(); + (void)walInit(); + (void)syncInit(); SMnodeOpt opt = {.msgCb = msgCb}; SMnode *pMnode = mndOpen(path, &opt); @@ -620,10 +620,10 @@ void mndDumpSdb() { mError("failed to write %s since %s", file, terrstr()); return; } - taosWriteFile(pFile, pCont, contLen); - taosWriteFile(pFile, "\n", 1); + (void)taosWriteFile(pFile, pCont, contLen); + (void)taosWriteFile(pFile, "\n", 1); UNUSED(taosFsyncFile(pFile)); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); tjsonDelete(json); taosMemoryFree(pCont); diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index 442da63b31..f89394ee22 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -598,7 +598,7 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) { goto RETRIEVE_FUNC_OVER; } - tSerializeSRetrieveFuncRsp(pRsp, contLen, &retrieveRsp); + (void)tSerializeSRetrieveFuncRsp(pRsp, contLen, &retrieveRsp); pReq->info.rsp = pRsp; pReq->info.rspLen = contLen; diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index 6fc9194249..8786c3a934 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -159,7 +159,7 @@ static void *mndBuildDropIdxReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStbOb pHead->vgId = htonl(pVgroup->vgId); void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead)); - tSerializeSDropIdxReq(pBuf, len - sizeof(SMsgHead), &req); + (void)tSerializeSDropIdxReq(pBuf, len - sizeof(SMsgHead), &req); *contLen = len; return pHead; _err: @@ -333,10 +333,10 @@ void mndReleaseIdx(SMnode *pMnode, SIdxObj *pIdx) { SDbObj *mndAcquireDbByIdx(SMnode *pMnode, const char *idxName) { SName name = {0}; - tNameFromString(&name, idxName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&name, idxName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); char db[TSDB_TABLE_FNAME_LEN] = {0}; - tNameGetFullDbName(&name, db); + (void)tNameGetFullDbName(&name, db); return mndAcquireDb(pMnode, db); } @@ -578,7 +578,7 @@ int32_t mndRetrieveTagIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, i cols = 0; SName idxName = {0}; - tNameFromString(&idxName, pIdx->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&idxName, pIdx->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); char n1[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(n1, (char *)tNameGetTableName(&idxName)); @@ -587,37 +587,37 @@ int32_t mndRetrieveTagIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, i STR_TO_VARSTR(n2, (char *)mndGetDbStr(pIdx->db)); SName stbName = {0}; - tNameFromString(&stbName, pIdx->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&stbName, pIdx->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); char n3[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(n3, (char *)tNameGetTableName(&stbName)); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)n1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)n1, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)n2, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)n2, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)n3, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)n3, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, NULL, true); + (void)colDataSetVal(pColInfo, numOfRows, NULL, true); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pIdx->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pIdx->createdTime, false); char col[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(col, (char *)pIdx->colName); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)col, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)col, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); char tag[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(tag, (char *)"tag_index"); - colDataSetVal(pColInfo, numOfRows, (const char *)tag, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)tag, false); numOfRows++; sdbRelease(pSdb, pIdx); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 906d6aba28..7e072b8fe5 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -48,32 +48,32 @@ static inline int32_t mndAcquireRpc(SMnode *pMnode) { int32_t code = 0; - taosThreadRwlockRdlock(&pMnode->lock); + (void)taosThreadRwlockRdlock(&pMnode->lock); if (pMnode->stopped) { code = TSDB_CODE_APP_IS_STOPPING; } else if (!mndIsLeader(pMnode)) { code = -1; } else { #if 1 - atomic_add_fetch_32(&pMnode->rpcRef, 1); + (void)atomic_add_fetch_32(&pMnode->rpcRef, 1); #else int32_t ref = atomic_add_fetch_32(&pMnode->rpcRef, 1); mTrace("mnode rpc is acquired, ref:%d", ref); #endif } - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); TAOS_RETURN(code); } static inline void mndReleaseRpc(SMnode *pMnode) { - taosThreadRwlockRdlock(&pMnode->lock); + (void)taosThreadRwlockRdlock(&pMnode->lock); #if 1 - atomic_sub_fetch_32(&pMnode->rpcRef, 1); + (void)atomic_sub_fetch_32(&pMnode->rpcRef, 1); #else int32_t ref = atomic_sub_fetch_32(&pMnode->rpcRef, 1); mTrace("mnode rpc is released, ref:%d", ref); #endif - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); } static void *mndBuildTimerMsg(int32_t *pContLen) { @@ -85,7 +85,7 @@ static void *mndBuildTimerMsg(int32_t *pContLen) { void *pReq = rpcMallocCont(contLen); if (pReq == NULL) return NULL; - tSerializeSMTimerMsg(pReq, contLen, &timerReq); + (void)tSerializeSMTimerMsg(pReq, contLen, &timerReq); *pContLen = contLen; return pReq; } @@ -96,7 +96,8 @@ static void mndPullupTrans(SMnode *pMnode) { void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + //TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -106,7 +107,8 @@ static void mndPullupCompacts(SMnode *pMnode) { void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_COMPACT_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + //TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -115,7 +117,8 @@ static void mndPullupTtl(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + //TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } static void mndPullupTrimDb(SMnode *pMnode) { @@ -123,7 +126,8 @@ static void mndPullupTrimDb(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); SRpcMsg rpcMsg = {.msgType = TDMT_MND_S3MIGRATE_DB_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } static void mndPullupS3MigrateDb(SMnode *pMnode) { @@ -131,7 +135,8 @@ static void mndPullupS3MigrateDb(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRIM_DB_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } static int32_t mndPullupArbHeartbeat(SMnode *pMnode) { @@ -155,7 +160,7 @@ static void mndCalMqRebalance(SMnode *pMnode) { void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_TMQ_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -164,7 +169,8 @@ static void mndStreamCheckpointTimer(SMnode *pMnode) { if (pMsg != NULL) { int32_t size = sizeof(SMStreamDoCheckpointMsg); SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_BEGIN_CHECKPOINT, .pCont = pMsg, .contLen = size}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -173,7 +179,8 @@ static void mndStreamCheckNode(SMnode *pMnode) { void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_NODECHECK_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); } } @@ -182,7 +189,8 @@ static void mndStreamConsensusChkpt(SMnode *pMnode) { void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_CONSEN_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -192,7 +200,8 @@ static void mndPullupTelem(SMnode *pMnode) { void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); } } @@ -203,7 +212,8 @@ static void mndPullupGrant(SMnode *pMnode) { if (pReq != NULL) { SRpcMsg rpcMsg = { .msgType = TDMT_MND_GRANT_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9527}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -214,7 +224,8 @@ static void mndIncreaseUpTime(SMnode *pMnode) { if (pReq != NULL) { SRpcMsg rpcMsg = { .msgType = TDMT_MND_UPTIME_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9528}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + // TODO check return value + (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -287,24 +298,24 @@ static void mndCheckDnodeOffline(SMnode *pMnode) { static bool mnodeIsNotLeader(SMnode *pMnode) { terrno = 0; - taosThreadRwlockRdlock(&pMnode->lock); + (void)taosThreadRwlockRdlock(&pMnode->lock); SSyncState state = syncGetState(pMnode->syncMgmt.sync); if (terrno != 0) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); return true; } if (state.state != TAOS_SYNC_STATE_LEADER) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); terrno = TSDB_CODE_SYN_NOT_LEADER; return true; } if (!state.restored || !pMnode->restored) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); terrno = TSDB_CODE_SYN_RESTORING; return true; } - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); return false; } @@ -429,21 +440,21 @@ static void *mndThreadFp(void *param) { static int32_t mndInitTimer(SMnode *pMnode) { int32_t code = 0; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if ((code = taosThreadCreate(&pMnode->thread, &thAttr, mndThreadFp, pMnode)) != 0) { mError("failed to create timer thread since %s", strerror(errno)); TAOS_RETURN(code); } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); tmsgReportStartup("mnode-timer", "initialized"); TAOS_RETURN(code); } static void mndCleanupTimer(SMnode *pMnode) { if (taosCheckPthreadValid(pMnode->thread)) { - taosThreadJoin(pMnode->thread, NULL); + (void)taosThreadJoin(pMnode->thread, NULL); taosThreadClear(&pMnode->thread); } } @@ -467,7 +478,7 @@ static int32_t mndCreateDir(SMnode *pMnode, const char *path) { static int32_t mndInitWal(SMnode *pMnode) { int32_t code = 0; char path[PATH_MAX + 20] = {0}; - snprintf(path, sizeof(path), "%s%swal", pMnode->path, TD_DIRSEP); + (void)snprintf(path, sizeof(path), "%s%swal", pMnode->path, TD_DIRSEP); SWalCfg cfg = {.vgId = 1, .fsyncPeriod = 0, .rollPeriod = -1, @@ -486,7 +497,7 @@ static int32_t mndInitWal(SMnode *pMnode) { TAOS_RETURN(code); } else{ - strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); + (void)strncpy(cfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); } } #endif @@ -642,8 +653,8 @@ static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) { pMnode->syncMgmt.numOfReplicas = pOption->numOfReplicas; pMnode->syncMgmt.numOfTotalReplicas = pOption->numOfTotalReplicas; pMnode->syncMgmt.lastIndex = pOption->lastIndex; - memcpy(pMnode->syncMgmt.replicas, pOption->replicas, sizeof(pOption->replicas)); - memcpy(pMnode->syncMgmt.nodeRoles, pOption->nodeRoles, sizeof(pOption->nodeRoles)); + (void)memcpy(pMnode->syncMgmt.replicas, pOption->replicas, sizeof(pOption->replicas)); + (void)memcpy(pMnode->syncMgmt.nodeRoles, pOption->nodeRoles, sizeof(pOption->nodeRoles)); } SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { @@ -656,7 +667,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { mError("failed to open mnode since %s", terrstr()); return NULL; } - memset(pMnode, 0, sizeof(SMnode)); + (void)memset(pMnode, 0, sizeof(SMnode)); char timestr[24] = "1970-01-01 00:00:00.00"; (void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0); @@ -704,9 +715,10 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { void mndPreClose(SMnode *pMnode) { if (pMnode != NULL) { - syncLeaderTransfer(pMnode->syncMgmt.sync); + // TODO check return value + (void)syncLeaderTransfer(pMnode->syncMgmt.sync); syncPreStop(pMnode->syncMgmt.sync); - sdbWriteFile(pMnode->pSdb, 0); + (void)sdbWriteFile(pMnode->pSdb, 0); } } @@ -785,9 +797,9 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { } SMnode *pMnode = pMsg->info.node; - taosThreadRwlockRdlock(&pMnode->lock); + (void)taosThreadRwlockRdlock(&pMnode->lock); if (pMnode->stopped) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); code = TSDB_CODE_APP_IS_STOPPING; TAOS_RETURN(code); } @@ -795,31 +807,31 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { terrno = 0; SSyncState state = syncGetState(pMnode->syncMgmt.sync); if (terrno != 0) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); code = terrno; TAOS_RETURN(code); } if (state.state != TAOS_SYNC_STATE_LEADER) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); code = TSDB_CODE_SYN_NOT_LEADER; goto _OVER; } if (!state.restored || !pMnode->restored) { - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); code = TSDB_CODE_SYN_RESTORING; goto _OVER; } #if 1 - atomic_add_fetch_32(&pMnode->rpcRef, 1); + (void)atomic_add_fetch_32(&pMnode->rpcRef, 1); #else int32_t ref = atomic_add_fetch_32(&pMnode->rpcRef, 1); mTrace("mnode rpc is acquired, ref:%d", ref); #endif - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); TAOS_RETURN(code); _OVER: @@ -854,7 +866,7 @@ _OVER: int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); pMsg->info.rsp = rpcMallocCont(contLen); if (pMsg->info.rsp != NULL) { - tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); + (void)tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); pMsg->info.hasEpSet = 1; pMsg->info.rspLen = contLen; } @@ -973,7 +985,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr } else { tstrncpy(desc.status, "offline", sizeof(desc.status)); } - taosArrayPush(pClusterInfo->dnodes, &desc); + (void)taosArrayPush(pClusterInfo->dnodes, &desc); sdbRelease(pSdb, pObj); } @@ -999,7 +1011,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr tstrncpy(desc.role, syncStr(pObj->syncState), sizeof(desc.role)); desc.syncState = pObj->syncState; } - taosArrayPush(pClusterInfo->mnodes, &desc); + (void)taosArrayPush(pClusterInfo->mnodes, &desc); sdbRelease(pSdb, pObj); } @@ -1017,8 +1029,8 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr desc.vgroup_id = pVgroup->vgId; SName name = {0}; - tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - tNameGetDbName(&name, desc.database_name); + (void)tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameGetDbName(&name, desc.database_name); desc.tables_num = pVgroup->numOfTables; pGrantInfo->timeseries_used += pVgroup->numOfTimeSeries; @@ -1039,7 +1051,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pClusterInfo->vnodes_total++; } - taosArrayPush(pVgroupInfo->vgroups, &desc); + (void)taosArrayPush(pVgroupInfo->vgroups, &desc); sdbRelease(pSdb, pVgroup); } @@ -1053,14 +1065,14 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr SMonStbDesc desc = {0}; SName name1 = {0}; - tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - tNameGetDbName(&name1, desc.database_name); + (void)tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameGetDbName(&name1, desc.database_name); SName name2 = {0}; - tNameFromString(&name2, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&name2, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); tstrncpy(desc.stb_name, tNameGetTableName(&name2), TSDB_TABLE_NAME_LEN); - taosArrayPush(pStbInfo->stbs, &desc); + (void)taosArrayPush(pStbInfo->stbs, &desc); sdbRelease(pSdb, pStb); } @@ -1094,14 +1106,14 @@ int64_t mndGetRoleTimeMs(SMnode *pMnode) { void mndSetRestored(SMnode *pMnode, bool restored) { if (restored) { - taosThreadRwlockWrlock(&pMnode->lock); + (void)taosThreadRwlockWrlock(&pMnode->lock); pMnode->restored = true; - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); mInfo("mnode set restored:%d", restored); } else { - taosThreadRwlockWrlock(&pMnode->lock); + (void)taosThreadRwlockWrlock(&pMnode->lock); pMnode->restored = false; - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); mInfo("mnode set restored:%d", restored); while (1) { if (pMnode->rpcRef <= 0) break; @@ -1113,9 +1125,9 @@ void mndSetRestored(SMnode *pMnode, bool restored) { bool mndGetRestored(SMnode *pMnode) { return pMnode->restored; } void mndSetStop(SMnode *pMnode) { - taosThreadRwlockWrlock(&pMnode->lock); + (void)taosThreadRwlockWrlock(&pMnode->lock); pMnode->stopped = true; - taosThreadRwlockUnlock(&pMnode->lock); + (void)taosThreadRwlockUnlock(&pMnode->lock); mInfo("mnode set stopped"); } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 014d6468ff..67fdcc2466 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -270,7 +270,7 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { } } if (pObj->pDnode != NULL) { - addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port); + (void)addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port); } sdbRelease(pSdb, pObj); } @@ -341,7 +341,7 @@ static int32_t mndBuildCreateMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *p int32_t code = 0; int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pCreateReq); void *pReq = taosMemoryMalloc(contLen); - tSerializeSDCreateMnodeReq(pReq, contLen, pCreateReq); + (void)tSerializeSDCreateMnodeReq(pReq, contLen, pCreateReq); STransAction action = { .epSet = *pCreateEpSet, @@ -363,7 +363,7 @@ static int32_t mndBuildAlterMnodeTypeRedoAction(STrans *pTrans, SDAlterMnodeType int32_t code = 0; int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterMnodeTypeReq); void *pReq = taosMemoryMalloc(contLen); - tSerializeSDCreateMnodeReq(pReq, contLen, pAlterMnodeTypeReq); + (void)tSerializeSDCreateMnodeReq(pReq, contLen, pAlterMnodeTypeReq); STransAction action = { .epSet = *pAlterMnodeTypeEpSet, @@ -385,7 +385,7 @@ static int32_t mndBuildAlterMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *pA int32_t code = 0; int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, pAlterReq); void *pReq = taosMemoryMalloc(contLen); - tSerializeSDCreateMnodeReq(pReq, contLen, pAlterReq); + (void)tSerializeSDCreateMnodeReq(pReq, contLen, pAlterReq); STransAction action = { .epSet = *pAlterEpSet, @@ -407,7 +407,7 @@ static int32_t mndBuildDropMnodeRedoAction(STrans *pTrans, SDDropMnodeReq *pDrop int32_t code = 0; int32_t contLen = tSerializeSCreateDropMQSNodeReq(NULL, 0, pDropReq); void *pReq = taosMemoryMalloc(contLen); - tSerializeSCreateDropMQSNodeReq(pReq, contLen, pDropReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, pDropReq); STransAction action = { .epSet = *pDroprEpSet, @@ -881,13 +881,13 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false); char b1[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(b1, pObj->pDnode->ep, TSDB_EP_LEN + VARSTR_HEADER_SIZE); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, b1, false); + (void)colDataSetVal(pColInfo, numOfRows, b1, false); char role[20] = "offline"; if (pObj->id == pMnode->selfDnodeId) { @@ -904,7 +904,7 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB char b2[12 + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(b2, role, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)b2, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)b2, false); const char *status = "ready"; if (objStatus == SDB_STATUS_CREATING) status = "creating"; @@ -913,14 +913,14 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB char b3[9 + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)b3, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)b3, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); int64_t roleTimeMs = (isDnodeOnline) ? pObj->roleTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); numOfRows++; sdbRelease(pSdb, pObj); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index f7b509b1cc..875ad562d2 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -263,7 +263,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { if (connReq.db[0]) { char db[TSDB_DB_FNAME_LEN] = {0}; - snprintf(db, TSDB_DB_FNAME_LEN, "%d%s%s", pUser->acctId, TS_PATH_DELIMITER, connReq.db); + (void)snprintf(db, TSDB_DB_FNAME_LEN, "%d%s%s", pUser->acctId, TS_PATH_DELIMITER, connReq.db); pDb = mndAcquireDb(pMnode, db); if (pDb == NULL) { if (0 != strcmp(connReq.db, TSDB_INFORMATION_SCHEMA_DB) && @@ -307,9 +307,9 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { tstrncpy(connectRsp.monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb, TSDB_DB_NAME_LEN); connectRsp.whiteListVer = pUser->ipWhiteListVer; - strcpy(connectRsp.sVer, version); - snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", version, buildinfo, - gitinfo); + (void)strcpy(connectRsp.sVer, version); + (void)snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", version, + buildinfo, gitinfo); mndGetMnodeEpSet(pMnode, &connectRsp.epSet); int32_t contLen = tSerializeSConnectRsp(NULL, 0, &connectRsp); @@ -335,7 +335,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { code = 0; char detail[1000] = {0}; - sprintf(detail, "app:%s", connReq.app); + (void)sprintf(detail, "app:%s", connReq.app); auditRecord(pReq, pMnode->clusterId, "login", "", "", detail, strlen(detail)); @@ -371,9 +371,9 @@ static SAppObj *mndCreateApp(SMnode *pMnode, uint32_t clientIp, SAppHbReq *pReq) app.appId = pReq->appId; app.ip = clientIp; app.pid = pReq->pid; - strcpy(app.name, pReq->name); + (void)strcpy(app.name, pReq->name); app.startTime = pReq->startTime; - memcpy(&app.summary, &pReq->summary, sizeof(pReq->summary)); + (void)memcpy(&app.summary, &pReq->summary, sizeof(pReq->summary)); app.lastAccessTimeMs = taosGetTimestampMs(); const int32_t keepTime = tsShellActivityTimer * 3; @@ -456,7 +456,7 @@ static int32_t mndUpdateAppInfo(SMnode *pMnode, SClientHbReq *pHbReq, SRpcConnIn } } - memcpy(&pApp->summary, &pReq->summary, sizeof(pReq->summary)); + (void)memcpy(&pApp->summary, &pReq->summary, sizeof(pReq->summary)); mndReleaseApp(pMnode, pApp); @@ -492,7 +492,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb SRpcConnInfo connInfo = pMsg->info.conn; if (0 != pHbReq->app.appId) { - mndUpdateAppInfo(pMnode, pHbReq, &connInfo); + TAOS_CHECK_RETURN(mndUpdateAppInfo(pMnode, pHbReq, &connInfo)); } if (pHbReq->query) { @@ -520,7 +520,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb TAOS_RETURN(code); } - mndSaveQueryList(pConn, pBasic); + TAOS_CHECK_RETURN(mndSaveQueryList(pConn, pBasic)); if (pConn->killed != 0) { rspBasic->killConnection = 1; } @@ -546,7 +546,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb int32_t kvNum = taosHashGetSize(pHbReq->info); if (NULL == pHbReq->info || kvNum <= 0) { - taosArrayPush(pBatchRsp->rsps, &hbRsp); + // TODO return value + (void)taosArrayPush(pBatchRsp->rsps, &hbRsp); return TSDB_CODE_SUCCESS; } @@ -574,7 +575,10 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb if (needCheck) { SKv kv1 = {.key = HEARTBEAT_KEY_DYN_VIEW, .valueLen = sizeof(*pDynViewVer), .value = pRspVer}; - taosArrayPush(hbRsp.info, &kv1); + if (taosArrayPush(hbRsp.info, &kv1) == NULL) { + if (terrno != 0) code = terrno; + TAOS_RETURN(code); + }; mTrace("need to check view ver, lastest bootTs:%" PRId64 ", ver:%" PRIu64, pRspVer->svrBootTs, pRspVer->dynViewVer); } @@ -589,31 +593,31 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb case HEARTBEAT_KEY_USER_AUTHINFO: { void *rspMsg = NULL; int32_t rspLen = 0; - mndValidateUserAuthInfo(pMnode, kv->value, kv->valueLen / sizeof(SUserAuthVersion), &rspMsg, &rspLen, - pObj->ipWhiteListVer); + (void)mndValidateUserAuthInfo(pMnode, kv->value, kv->valueLen / sizeof(SUserAuthVersion), &rspMsg, &rspLen, + pObj->ipWhiteListVer); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_USER_AUTHINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); + (void)taosArrayPush(hbRsp.info, &kv1); } break; } case HEARTBEAT_KEY_DBINFO: { void *rspMsg = NULL; int32_t rspLen = 0; - mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbCacheInfo), &rspMsg, &rspLen); + (void)mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbCacheInfo), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); + (void)taosArrayPush(hbRsp.info, &kv1); } break; } case HEARTBEAT_KEY_STBINFO: { void *rspMsg = NULL; int32_t rspLen = 0; - mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableVersion), &rspMsg, &rspLen); + (void)mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableVersion), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); + (void)taosArrayPush(hbRsp.info, &kv1); } break; } @@ -628,10 +632,10 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb void *rspMsg = NULL; int32_t rspLen = 0; - mndValidateViewInfo(pMnode, kv->value, kv->valueLen / sizeof(SViewVersion), &rspMsg, &rspLen); + (void)mndValidateViewInfo(pMnode, kv->value, kv->valueLen / sizeof(SViewVersion), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv1 = {.key = HEARTBEAT_KEY_VIEWINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); + (void)taosArrayPush(hbRsp.info, &kv1); } break; } @@ -639,10 +643,10 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb case HEARTBEAT_KEY_TSMA: { void *rspMsg = NULL; int32_t rspLen = 0; - mndValidateTSMAInfo(pMnode, kv->value, kv->valueLen / sizeof(STSMAVersion), &rspMsg, &rspLen); + (void)mndValidateTSMAInfo(pMnode, kv->value, kv->valueLen / sizeof(STSMAVersion), &rspMsg, &rspLen); if (rspMsg && rspLen > 0) { SKv kv = {.key = HEARTBEAT_KEY_TSMA, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv); + (void)taosArrayPush(hbRsp.info, &kv); } break; } @@ -655,9 +659,10 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb pIter = taosHashIterate(pHbReq->info, pIter); } - taosArrayPush(pBatchRsp->rsps, &hbRsp); - - return TSDB_CODE_SUCCESS; + if (taosArrayPush(pBatchRsp->rsps, &hbRsp) == NULL) { + if (terrno != 0) code = terrno; + } + TAOS_RETURN(code); } static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq) { @@ -675,9 +680,9 @@ static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq) { SConnPreparedObj obj = {0}; obj.totalDnodes = mndGetDnodeSize(pMnode); obj.ipWhiteListVer = batchReq.ipWhiteList; - mndGetOnlineDnodeNum(pMnode, &obj.onlineDnodes); + TAOS_CHECK_RETURN(mndGetOnlineDnodeNum(pMnode, &obj.onlineDnodes)); mndGetMnodeEpSet(pMnode, &obj.epSet); - mndCreateQnodeList(pMnode, &obj.pQnodeList, -1); + TAOS_CHECK_RETURN(mndCreateQnodeList(pMnode, &obj.pQnodeList, -1)); SClientHbBatchRsp batchRsp = {0}; batchRsp.svrTimestamp = taosGetTimestampSec(); @@ -701,7 +706,7 @@ static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq) { } else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) { SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); if (pRsp != NULL) { - taosArrayPush(batchRsp.rsps, pRsp); + (void)taosArrayPush(batchRsp.rsps, pRsp); taosMemoryFree(pRsp); } } @@ -845,32 +850,32 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->id, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->id, false); char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(user, pConn->user); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)user, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)user, false); char app[TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE]; STR_TO_VARSTR(app, pConn->app); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)app, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)app, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->pid, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->pid, false); char endpoint[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0}; - sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port); + (void)sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port); varDataLen(endpoint) = strlen(&endpoint[VARSTR_HEADER_SIZE]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)endpoint, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)endpoint, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->loginTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->loginTimeMs, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->lastAccessTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->lastAccessTimeMs, false); numOfRows++; } @@ -903,50 +908,50 @@ static int32_t packQueriesIntoBlock(SShowObj *pShow, SConnObj *pConn, SSDataBloc cols = 0; char queryId[26 + VARSTR_HEADER_SIZE] = {0}; - sprintf(&queryId[VARSTR_HEADER_SIZE], "%x:%" PRIx64, pConn->id, pQuery->reqRid); + (void)sprintf(&queryId[VARSTR_HEADER_SIZE], "%x:%" PRIx64, pConn->id, pQuery->reqRid); varDataLen(queryId) = strlen(&queryId[VARSTR_HEADER_SIZE]); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)queryId, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)queryId, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->queryId, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->queryId, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->id, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->id, false); char app[TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE]; STR_TO_VARSTR(app, pConn->app); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)app, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)app, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->pid, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->pid, false); char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(user, pConn->user); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)user, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)user, false); char endpoint[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0}; - sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port); + (void)sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port); varDataLen(endpoint) = strlen(&endpoint[VARSTR_HEADER_SIZE]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)endpoint, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)endpoint, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stime, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stime, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->useconds, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->useconds, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stableQuery, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stableQuery, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->isSubQuery, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->isSubQuery, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->subPlanNum, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->subPlanNum, false); char subStatus[TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE] = {0}; int64_t reserve = 64; @@ -965,12 +970,12 @@ static int32_t packQueriesIntoBlock(SShowObj *pShow, SConnObj *pConn, SSDataBloc } varDataLen(subStatus) = strlen(&subStatus[VARSTR_HEADER_SIZE]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, subStatus, (varDataLen(subStatus) == 0) ? true : false); + (void)colDataSetVal(pColInfo, curRowIndex, subStatus, (varDataLen(subStatus) == 0) ? true : false); char sql[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(sql, pQuery->sql); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, curRowIndex, (const char *)sql, false); + (void)colDataSetVal(pColInfo, curRowIndex, (const char *)sql, false); pBlock->info.rows++; } @@ -1037,55 +1042,55 @@ static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->appId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->appId, false); char ip[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0}; - sprintf(&ip[VARSTR_HEADER_SIZE], "%s", taosIpStr(pApp->ip)); + (void)sprintf(&ip[VARSTR_HEADER_SIZE], "%s", taosIpStr(pApp->ip)); varDataLen(ip) = strlen(&ip[VARSTR_HEADER_SIZE]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)ip, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)ip, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->pid, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->pid, false); char name[TSDB_APP_NAME_LEN + 6 + VARSTR_HEADER_SIZE] = {0}; - sprintf(&name[VARSTR_HEADER_SIZE], "%s", pApp->name); + (void)sprintf(&name[VARSTR_HEADER_SIZE], "%s", pApp->name); varDataLen(name) = strlen(&name[VARSTR_HEADER_SIZE]); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)name, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)name, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->startTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->startTime, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertsReq, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertsReq, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertRows, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertRows, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertElapsedTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertElapsedTime, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertBytes, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertBytes, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.fetchBytes, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.fetchBytes, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.queryElapsedTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.queryElapsedTime, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfSlowQueries, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfSlowQueries, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.totalRequests, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.totalRequests, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.currentRequests, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.currentRequests, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->lastAccessTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->lastAccessTimeMs, false); numOfRows++; } diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index e63ff8b931..303e86bb82 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -1760,14 +1760,14 @@ static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) { SDbObj newDb = {0}; memcpy(&newDb, pCxt->pDb, sizeof(SDbObj)); newDb.tsmaVersion++; - TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); - TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); TAOS_CHECK_GOTO(mndSetCreateSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER); TAOS_CHECK_GOTO(mndSetCreateSmaUndoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER); TAOS_CHECK_GOTO(mndSetCreateSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &createStreamRedoAction), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendUndoAction(pTrans, &createStreamUndoAction), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendUndoAction(pTrans, &dropStbUndoAction), NULL, _OVER); + TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); + TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); TAOS_CHECK_GOTO(mndTransPrepare(pCxt->pMnode, pTrans), NULL, _OVER); code = TSDB_CODE_SUCCESS; @@ -2030,12 +2030,12 @@ static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) { SDbObj newDb = {0}; memcpy(&newDb, pCxt->pDb, sizeof(SDbObj)); newDb.tsmaVersion++; - TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); - TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); TAOS_CHECK_GOTO(mndSetDropSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER); TAOS_CHECK_GOTO(mndSetDropSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &dropStreamRedoAction), NULL, _OVER); TAOS_CHECK_GOTO(mndTransAppendRedoAction(pTrans, &dropStbRedoAction), NULL, _OVER); + TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); + TAOS_CHECK_GOTO(mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb), NULL, _OVER); TAOS_CHECK_GOTO(mndTransPrepare(pCxt->pMnode, pTrans), NULL, _OVER); code = TSDB_CODE_SUCCESS; _OVER: @@ -2450,13 +2450,14 @@ static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rs typedef bool (*tsmaFilter)(const SSmaObj* pSma, void* param); static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilter filtered, void* param, bool* exist) { - int32_t code = -1; + int32_t code = 0; SSmaObj * pSma = NULL; SSmaObj * pBaseTsma = NULL; SSdb * pSdb = pMnode->pSdb; void * pIter = NULL; SStreamObj * pStream = NULL; SStbObj * pStb = NULL; + bool shouldRetry = false; while (1) { pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); @@ -2470,6 +2471,7 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt pStb = mndAcquireStb(pMnode, pSma->dstTbName); if (!pStb) { sdbRelease(pSdb, pSma); + shouldRetry = true; continue; } @@ -2478,16 +2480,24 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); if (TSDB_CODE_SUCCESS != code) { sdbRelease(pSdb, pSma); + mndReleaseStb(pMnode, pStb); TAOS_RETURN(code); } sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname); pStream = NULL; code = mndAcquireStream(pMnode, streamName, &pStream); - if (!pStream || (code != 0)) { + if (!pStream) { + shouldRetry = true; sdbRelease(pSdb, pSma); + mndReleaseStb(pMnode, pStb); continue; } + if (code != 0) { + sdbRelease(pSdb, pSma); + mndReleaseStb(pMnode, pStb); + TAOS_RETURN(code); + } int64_t streamId = pStream->uid; mndReleaseStream(pMnode, pStream); @@ -2522,6 +2532,9 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt } *exist = true; } + if (shouldRetry) { + return TSDB_CODE_NEED_RETRY; + } return TSDB_CODE_SUCCESS; } @@ -2562,6 +2575,9 @@ static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq) { code = mndGetTSMA(pMnode, tsmaReq.name, &rsp, &exist); } else { code = mndGetTableTSMA(pMnode, tsmaReq.name, &rsp, &exist); + if (TSDB_CODE_NEED_RETRY == code) { + code = TSDB_CODE_SUCCESS; + } } if (code) { goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index cca1e71f6a..cd5584022f 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -223,7 +223,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S code = TSDB_CODE_OUT_OF_MEMORY; TAOS_RETURN(code); } - tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); @@ -251,7 +251,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S code = TSDB_CODE_OUT_OF_MEMORY; TAOS_RETURN(code); } - tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); @@ -383,7 +383,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn code = TSDB_CODE_OUT_OF_MEMORY; TAOS_RETURN(code); } - tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); @@ -482,16 +482,16 @@ static int32_t mndRetrieveSnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false); char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)ep, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)ep, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); numOfRows++; sdbRelease(pSdb, pObj); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 1616d5fac7..a76dfa1b51 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -278,7 +278,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { for (int32_t i = 0; i < pStb->numOfFuncs; ++i) { char funcName[TSDB_FUNC_NAME_LEN] = {0}; SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER) - taosArrayPush(pStb->pFuncs, funcName); + (void)taosArrayPush(pStb->pFuncs, funcName); } if (pStb->commentLen > 0) { @@ -479,10 +479,10 @@ void mndReleaseStb(SMnode *pMnode, SStbObj *pStb) { SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) { SName name = {0}; - tNameFromString(&name, stbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + if ((terrno = tNameFromString(&name, stbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0) return NULL; char db[TSDB_TABLE_FNAME_LEN] = {0}; - tNameGetFullDbName(&name, db); + (void)tNameGetFullDbName(&name, db); return mndAcquireDb(pMnode, db); } @@ -503,9 +503,11 @@ void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int3 SName name = {0}; SVCreateStbReq req = {0}; - tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + if ((terrno = tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0) { + goto _err; + } char dbFName[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(&name, dbFName); + (void)tNameGetFullDbName(&name, dbFName); req.name = (char *)tNameGetTableName(&name); req.suid = pStb->uid; @@ -600,7 +602,9 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, SMsgHead *pHead = NULL; SEncoder encoder = {0}; - tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + if ((terrno = tNameFromString(&name, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0) { + return NULL; + } req.name = (char *)tNameGetTableName(&name); req.suid = pStb->uid; @@ -621,7 +625,7 @@ static void *mndBuildVDropStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead)); tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead)); - tEncodeSVDropStbReq(&encoder, &req); + (void)tEncodeSVDropStbReq(&encoder, &req); tEncoderClear(&encoder); *pContLen = contLen; @@ -948,7 +952,9 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat } static int32_t mndGenIdxNameForFirstTag(char *fullname, char *dbname, char *stbname, char *tagname) { SName name = {0}; - tNameFromString(&name, stbname, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + if ((terrno = tNameFromString(&name, stbname, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)) != 0) { + return -1; + } return snprintf(fullname, TSDB_INDEX_FNAME_LEN, "%s.%s_%s", dbname, tagname, tNameGetTableName(&name)); } @@ -969,7 +975,9 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea TAOS_CHECK_GOTO(mndBuildStbFromReq(pMnode, &stbObj, pCreate, pDb), NULL, _OVER); SSchema *pSchema = &(stbObj.pTags[0]); - mndGenIdxNameForFirstTag(fullIdxName, pDb->name, stbObj.name, pSchema->name); + if (mndGenIdxNameForFirstTag(fullIdxName, pDb->name, stbObj.name, pSchema->name) < 0) { + goto _OVER; + } SSIdx idx = {0}; if (mndAcquireGlobalIdx(pMnode, fullIdxName, SDB_IDX, &idx) == 0 && idx.pIdx != NULL) { code = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST; @@ -995,7 +1003,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SRpcMsg *pReq, SMCreateStbReq *pCrea _OVER: mndTransDrop(pTrans); - mndStbActionDelete(pMnode->pSdb, &stbObj); + (void)mndStbActionDelete(pMnode->pSdb, &stbObj); TAOS_RETURN(code); } @@ -1031,7 +1039,7 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) { } pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq); + (void)tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq); SRpcMsg rpcMsg = { .msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info}; @@ -1069,7 +1077,7 @@ static int32_t mndProcessTrimDbTimer(SRpcMsg *pReq) { } pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSVTrimDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &trimReq); + (void)tSerializeSVTrimDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &trimReq); SRpcMsg rpcMsg = {.msgType = TDMT_VND_TRIM, .pCont = pHead, .contLen = contLen}; SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup); @@ -1106,7 +1114,7 @@ static int32_t mndProcessS3MigrateDbTimer(SRpcMsg *pReq) { } pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSVS3MigrateDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &s3migrateReq); + (void)tSerializeSVS3MigrateDbReq((char *)pHead + sizeof(SMsgHead), reqLen, &s3migrateReq); SRpcMsg rpcMsg = {.msgType = TDMT_VND_S3MIGRATE, .pCont = pHead, .contLen = contLen}; SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup); @@ -1335,7 +1343,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; SName name = {0}; - tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + TAOS_CHECK_RETURN(tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)); if (createReq.sql == NULL && createReq.sqlLen == 0) { char detail[1000] = {0}; @@ -1499,7 +1507,12 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName, } SNodeList *pNodeList = NULL; - nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + if ((code = nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList)) != + 0) { + sdbRelease(pSdb, pTopic); + sdbCancelFetch(pSdb, pIter); + TAOS_RETURN(code); + } SNode *pNode = NULL; FOREACH(pNode, pNodeList) { SColumnNode *pCol = (SColumnNode *)pNode; @@ -1549,7 +1562,13 @@ static int32_t mndCheckAlterColForStream(SMnode *pMnode, const char *stbFullName } SNodeList *pNodeList = NULL; - nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + if ((code = nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList)) != + 0) { + sdbRelease(pSdb, pStream); + sdbCancelFetch(pSdb, pIter); + TAOS_RETURN(code); + } + SNode *pNode = NULL; FOREACH(pNode, pNodeList) { SColumnNode *pCol = (SColumnNode *)pNode; @@ -1600,7 +1619,11 @@ static int32_t mndCheckAlterColForTSma(SMnode *pMnode, const char *stbFullName, } SNodeList *pNodeList = NULL; - nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + if ((code = nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList)) != + 0) { + sdbCancelFetch(pSdb, pIter); + TAOS_RETURN(code); + } SNode *pNode = NULL; FOREACH(pNode, pNodeList) { SColumnNode *pCol = (SColumnNode *)pNode; @@ -2291,7 +2314,7 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i uint32_t contLen = 0; SMAlterStbRsp alterRsp = {0}; SName name = {0}; - tNameFromString(&name, pObj->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + TAOS_CHECK_RETURN(tNameFromString(&name, pObj->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE)); alterRsp.pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp)); if (NULL == alterRsp.pMeta) { @@ -2313,7 +2336,7 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, SStbObj *pObj, void **pCont, i void *cont = taosMemoryMalloc(contLen); tEncoderInit(&ec, cont, contLen); - tEncodeSMAlterStbRsp(&ec, &alterRsp); + (void)tEncodeSMAlterStbRsp(&ec, &alterRsp); tEncoderClear(&ec); tFreeSMAlterStbRsp(&alterRsp); @@ -2344,7 +2367,7 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, vo uint32_t contLen = 0; SMCreateStbRsp stbRsp = {0}; SName name = {0}; - tNameFromString(&name, pObj->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + TAOS_CHECK_GOTO(tNameFromString(&name, pObj->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE), NULL, _OVER); stbRsp.pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp)); if (NULL == stbRsp.pMeta) { @@ -2366,7 +2389,7 @@ int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, vo void *cont = taosMemoryMalloc(contLen); tEncoderInit(&ec, cont, contLen); - tEncodeSMCreateStbRsp(&ec, &stbRsp); + (void)tEncodeSMCreateStbRsp(&ec, &stbRsp); tEncoderClear(&ec); tFreeSMCreateStbRsp(&stbRsp); @@ -2605,7 +2628,8 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) { if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; SName name = {0}; - tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + // TODO check return value + (void)tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); auditRecord(pReq, pMnode->clusterId, "alterStb", name.dbname, name.tname, alterReq.sql, alterReq.sqlLen); @@ -2755,7 +2779,12 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName, } SNodeList *pNodeList = NULL; - nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + if ((code = nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList)) != + 0) { + sdbRelease(pSdb, pTopic); + sdbCancelFetch(pSdb, pIter); + TAOS_RETURN(code); + } SNode *pNode = NULL; FOREACH(pNode, pNodeList) { SColumnNode *pCol = (SColumnNode *)pNode; @@ -2803,7 +2832,12 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, } SNodeList *pNodeList = NULL; - nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList); + if ((code = nodesCollectColumns((SSelectStmt *)pAst, SQL_CLAUSE_FROM, NULL, COLLECT_COL_TYPE_ALL, &pNodeList)) != + 0) { + sdbCancelFetch(pSdb, pIter); + sdbRelease(pSdb, pStream); + TAOS_RETURN(code); + } SNode *pNode = NULL; FOREACH(pNode, pNodeList) { SColumnNode *pCol = (SColumnNode *)pNode; @@ -2882,7 +2916,8 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; SName name = {0}; - tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + // TODO check return value + (void)tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); auditRecord(pReq, pMnode->clusterId, "dropStb", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen); @@ -2933,7 +2968,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) { goto _OVER; } - tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp); + (void)tSerializeSTableMetaRsp(pRsp, rspLen, &metaRsp); pReq->info.rsp = pRsp; pReq->info.rspLen = rspLen; code = 0; @@ -2984,7 +3019,7 @@ static int32_t mndProcessTableCfgReq(SRpcMsg *pReq) { goto _OVER; } - tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp); + (void)tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp); pReq->info.rsp = pRsp; pReq->info.rspLen = rspLen; code = 0; @@ -3034,7 +3069,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t tstrncpy(metaRsp.dbFName, pStbVersion->dbFName, sizeof(metaRsp.dbFName)); tstrncpy(metaRsp.tbName, pStbVersion->stbName, sizeof(metaRsp.tbName)); tstrncpy(metaRsp.stbName, pStbVersion->stbName, sizeof(metaRsp.stbName)); - taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + (void)taosArrayPush(hbRsp.pMetaRsp, &metaRsp); continue; } @@ -3047,11 +3082,11 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t tstrncpy(metaRsp.dbFName, pStbVersion->dbFName, sizeof(metaRsp.dbFName)); tstrncpy(metaRsp.tbName, pStbVersion->stbName, sizeof(metaRsp.tbName)); tstrncpy(metaRsp.stbName, pStbVersion->stbName, sizeof(metaRsp.stbName)); - taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + (void)taosArrayPush(hbRsp.pMetaRsp, &metaRsp); continue; } - taosArrayPush(hbRsp.pMetaRsp, &metaRsp); + (void)taosArrayPush(hbRsp.pMetaRsp, &metaRsp); } if (sma) { @@ -3075,7 +3110,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t strcpy(indexRsp.dbFName, pStbVersion->dbFName); strcpy(indexRsp.tbName, pStbVersion->stbName); - taosArrayPush(hbRsp.pIndexRsp, &indexRsp); + (void)taosArrayPush(hbRsp.pIndexRsp, &indexRsp); } } @@ -3093,7 +3128,7 @@ int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t TAOS_RETURN(code); } - tSerializeSSTbHbRsp(pRsp, rspLen, &hbRsp); + (void)tSerializeSSTbHbRsp(pRsp, rspLen, &hbRsp); tFreeSSTbHbRsp(&hbRsp); *ppRsp = pRsp; *pRspLen = rspLen; @@ -3130,23 +3165,23 @@ int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs) { void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst) { SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - tNameGetFullDbName(&name, dst); + (void)tNameGetFullDbName(&name, dst); } void mndExtractShortDbNameFromStbFullName(const char *stbFullName, char *dst) { SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - tNameGetDbName(&name, dst); + (void)tNameGetDbName(&name, dst); } void mndExtractShortDbNameFromDbFullName(const char *stbFullName, char *dst) { SName name = {0}; - tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB); + (void)tNameFromString(&name, stbFullName, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, dst); + (void)tNameGetDbName(&name, dst); } void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize) { @@ -3473,37 +3508,37 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc varDataSetLen(stbName, strlen(&stbName[VARSTR_HEADER_SIZE])); SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false); char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, varDataVal(db)); + (void)tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB); + (void)tNameGetDbName(&name, varDataVal(db)); varDataSetLen(db, strlen(varDataVal(db))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)db, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->createdTime, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfColumns, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfColumns, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfTags, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->numOfTags, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->updateTime, false); // number of tables + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->updateTime, false); // number of tables pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); if (pStb->commentLen > 0) { char comment[TSDB_TB_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(comment, pStb->comment); - colDataSetVal(pColInfo, numOfRows, comment, false); + (void)colDataSetVal(pColInfo, numOfRows, comment, false); } else if (pStb->commentLen == 0) { char comment[VARSTR_HEADER_SIZE + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(comment, ""); - colDataSetVal(pColInfo, numOfRows, comment, false); + (void)colDataSetVal(pColInfo, numOfRows, comment, false); } else { colDataSetNULL(pColInfo, numOfRows); } @@ -3513,14 +3548,14 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc varDataSetLen(watermark, strlen(varDataVal(watermark))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)watermark, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)watermark, false); char maxDelay[64 + VARSTR_HEADER_SIZE] = {0}; sprintf(varDataVal(maxDelay), "%" PRId64 "a,%" PRId64 "a", pStb->maxdelay[0], pStb->maxdelay[1]); varDataSetLen(maxDelay, strlen(varDataVal(maxDelay))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)maxDelay, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)maxDelay, false); char rollup[160 + VARSTR_HEADER_SIZE] = {0}; int32_t rollupNum = (int32_t)taosArrayGetSize(pStb->pFuncs); @@ -3530,16 +3565,16 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc for (int32_t i = 0; i < rollupNum; ++i) { char *funcName = taosArrayGet(pStb->pFuncs, i); if (i) { - strncat(varDataVal(rollup), sep, rollupLen); + (void)strncat(varDataVal(rollup), sep, rollupLen); rollupLen -= sepLen; } - strncat(varDataVal(rollup), funcName, rollupLen); + (void)strncat(varDataVal(rollup), funcName, rollupLen); rollupLen -= strlen(funcName); } varDataSetLen(rollup, strlen(varDataVal(rollup))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)rollup, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)rollup, false); numOfRows++; sdbRelease(pSdb, pStb); @@ -3577,20 +3612,20 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p for (int32_t j = 0; j < pm->colNum; j++) { // table name SColumnInfoData *pColInfoData = taosArrayGet(p->pDataBlock, 0); - colDataSetVal(pColInfoData, numOfRows, tName, false); + (void)colDataSetVal(pColInfoData, numOfRows, tName, false); // database name pColInfoData = taosArrayGet(p->pDataBlock, 1); - colDataSetVal(pColInfoData, numOfRows, dName, false); + (void)colDataSetVal(pColInfoData, numOfRows, dName, false); pColInfoData = taosArrayGet(p->pDataBlock, 2); - colDataSetVal(pColInfoData, numOfRows, typeName, false); + (void)colDataSetVal(pColInfoData, numOfRows, typeName, false); // col name char colName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(colName, pm->schema[j].name); pColInfoData = taosArrayGet(p->pDataBlock, 3); - colDataSetVal(pColInfoData, numOfRows, colName, false); + (void)colDataSetVal(pColInfoData, numOfRows, colName, false); // col type int8_t colType = pm->schema[j].type; @@ -3605,10 +3640,10 @@ static int32_t buildDbColsInfoBlock(const SSDataBlock *p, const SSysTableMeta *p (int32_t)((pm->schema[j].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } varDataSetLen(colTypeStr, colTypeLen); - colDataSetVal(pColInfoData, numOfRows, (char *)colTypeStr, false); + (void)colDataSetVal(pColInfoData, numOfRows, (char *)colTypeStr, false); pColInfoData = taosArrayGet(p->pDataBlock, 5); - colDataSetVal(pColInfoData, numOfRows, (const char *)&pm->schema[j].bytes, false); + (void)colDataSetVal(pColInfoData, numOfRows, (const char *)&pm->schema[j].bytes, false); for (int32_t k = 6; k <= 8; ++k) { pColInfoData = taosArrayGet(p->pDataBlock, k); colDataSetNULL(pColInfoData, numOfRows); @@ -3724,26 +3759,26 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB mDebug("mndRetrieveStbCol get stable cols, stable name:%s, db:%s", pStb->name, pStb->db); char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, varDataVal(db)); + (void)tNameFromString(&name, pStb->db, T_NAME_ACCT | T_NAME_DB); + (void)tNameGetDbName(&name, varDataVal(db)); varDataSetLen(db, strlen(varDataVal(db))); for (int i = 0; i < pStb->numOfColumns; i++) { int32_t cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)stbName, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)db, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, typeName, false); + (void)colDataSetVal(pColInfo, numOfRows, typeName, false); // col name char colName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(colName, pStb->pColumns[i].name); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, colName, false); + (void)colDataSetVal(pColInfo, numOfRows, colName, false); // col type int8_t colType = pStb->pColumns[i].type; @@ -3758,10 +3793,10 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB (int32_t)((pStb->pColumns[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } varDataSetLen(colTypeStr, colTypeLen); - colDataSetVal(pColInfo, numOfRows, (char *)colTypeStr, false); + (void)colDataSetVal(pColInfo, numOfRows, (char *)colTypeStr, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->pColumns[i].bytes, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pStb->pColumns[i].bytes, false); while (cols < pShow->numOfColumns) { pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetNULL(pColInfo, numOfRows); @@ -4064,7 +4099,7 @@ static void *mndBuildVDropTbsReq(SMnode *pMnode, const SVgroupInfo *pVgInfo, con void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead)); tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead)); - tEncodeSVDropTbBatchReq(&encoder, pReq); + (void)tEncodeSVDropTbBatchReq(&encoder, pReq); tEncoderClear(&encoder); *len = contLen; @@ -4155,10 +4190,19 @@ static int32_t mndDropTbAdd(SMnode *pMnode, SHashObj *pVgHashMap, const SVgroupI if (pReqs == NULL) { reqs.info = *pVgInfo; reqs.req.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVDropTbReq)); - taosArrayPush(reqs.req.pArray, &req); - taosHashPut(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId), &reqs, sizeof(reqs)); + if (reqs.req.pArray == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + if (taosArrayPush(reqs.req.pArray, &req) == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + if (taosHashPut(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId), &reqs, sizeof(reqs)) != 0) { + return TSDB_CODE_OUT_OF_MEMORY; + } } else { - taosArrayPush(pReqs->req.pArray, &req); + if (taosArrayPush(pReqs->req.pArray, &req) == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } return 0; } @@ -4231,7 +4275,10 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWith code = TSDB_CODE_OUT_OF_MEMORY; goto _end; } - taosHashPut(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid), &infos, sizeof(infos)); + if (taosHashPut(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid), &infos, sizeof(infos)) != 0) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } } } @@ -4258,11 +4305,15 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWith sdbRelease(pMnode->pSdb, pSma); goto _end; } - taosHashPut(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN, &info.dbInfo, sizeof(SMDropTbDbInfo)); + if (taosHashPut(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN, &info.dbInfo, sizeof(SMDropTbDbInfo)) != 0) { + sdbCancelFetch(pMnode->pSdb, pIter); + sdbRelease(pMnode->pSdb, pSma); + goto _end; + } } else { info.dbInfo = *pDbInfo; } - taosArrayPush(pInfos->pTsmaInfos, &info); + (void)taosArrayPush(pInfos->pTsmaInfos, &info); } sdbRelease(pMnode->pSdb, pSma); } @@ -4270,7 +4321,7 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWith // generate vg req map for (int32_t i = 0; i < pTbs->size; ++i) { SVDropTbReq *pTb = taosArrayGet(pTbs, i); - mndDropTbAdd(pMnode, pCtx->pVgMap, &vgInfo, pTb->name, pTb->suid, pTb->igNotExists); + TAOS_CHECK_GOTO(mndDropTbAdd(pMnode, pCtx->pVgMap, &vgInfo, pTb->name, pTb->suid, pTb->igNotExists), NULL, _end); SMDropTbTsmaInfos *pInfos = taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid)); SArray *pVgInfos = NULL; @@ -4282,8 +4333,8 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWith taosGetTbHashVal(buf, len, pInfo->dbInfo.hashMethod, pInfo->dbInfo.hashPrefix, pInfo->dbInfo.hashSuffix); const SVgroupInfo *pVgInfo = taosArraySearch(pInfo->dbInfo.dbVgInfos, &hashVal, vgHashValCmp, TD_EQ); void *p = taosStrdup(buf + strlen(pInfo->tsmaResTbDbFName) + TSDB_NAME_DELIMITER_LEN); - taosArrayPush(pCtx->pResTbNames, &p); - mndDropTbAdd(pMnode, pCtx->pVgMap, pVgInfo, p, pInfo->suid, true); + (void)taosArrayPush(pCtx->pResTbNames, &p); + TAOS_CHECK_GOTO(mndDropTbAdd(pMnode, pCtx->pVgMap, pVgInfo, p, pInfo->suid, true), NULL, _end); } } _end: diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index bb59af2808..d45346516b 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -1375,7 +1375,7 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t *numOfRows, int64_t cons if (data) { // vg id char buf[TSDB_OFFSET_LEN * 2 + VARSTR_HEADER_SIZE] = {0}; - tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset); + (void)tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset); (void)sprintf(varDataVal(buf) + strlen(varDataVal(buf)), "/%" PRId64, data->ever); varDataSetLen(buf, strlen(varDataVal(buf))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 70d0b858f6..89f3c6e253 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -212,8 +212,7 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) { mndTransRefresh(pMnode, pTrans); sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex); - sdbWriteFile(pMnode->pSdb, tsMndSdbWriteDelta); - code = 0; + code = sdbWriteFile(pMnode->pSdb, tsMndSdbWriteDelta); _OUT: if (pTrans) mndReleaseTrans(pMnode, pTrans); @@ -222,7 +221,7 @@ _OUT: static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId == 0) { goto _OUT; } @@ -232,7 +231,7 @@ static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) { pMgmt->transSec = 0; pMgmt->transSeq = 0; pMgmt->errCode = code; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); if (pMgmt->errCode != 0) { mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode)); @@ -241,7 +240,7 @@ static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) { } _OUT: - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); return 0; } @@ -304,7 +303,7 @@ void mndRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) { } else { mInfo("vgId:1, sync restore finished"); } - mndRefreshUserIpWhiteList(pMnode); + (void)mndRefreshUserIpWhiteList(pMnode); ASSERT(commitIdx == mndSyncAppliedIndex(pFsm)); } @@ -350,16 +349,16 @@ static void mndBecomeFollower(const SSyncFSM *pFsm) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; mInfo("vgId:1, become follower"); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { mInfo("vgId:1, become follower and post sem, trans:%d, failed to propose since not leader", pMgmt->transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } static void mndBecomeLearner(const SSyncFSM *pFsm) { @@ -367,16 +366,16 @@ static void mndBecomeLearner(const SSyncFSM *pFsm) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; mInfo("vgId:1, become learner"); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { mInfo("vgId:1, become learner and post sem, trans:%d, failed to propose since not leader", pMgmt->transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } static void mndBecomeLeader(const SSyncFSM *pFsm) { @@ -435,12 +434,12 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) { int32_t mndInitSync(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexInit(&pMgmt->lock, NULL); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexInit(&pMgmt->lock, NULL); + (void)taosThreadMutexLock(&pMgmt->lock); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); SSyncInfo syncInfo = { .snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT, @@ -477,7 +476,7 @@ int32_t mndInitSync(SMnode *pMnode) { } int32_t code = 0; - tsem_init(&pMgmt->syncSem, 0, 0); + (void)tsem_init(&pMgmt->syncSem, 0, 0); pMgmt->sync = syncOpen(&syncInfo, true); if (pMgmt->sync <= 0) { if (terrno != 0) code = terrno; @@ -495,15 +494,15 @@ void mndCleanupSync(SMnode *pMnode) { syncStop(pMgmt->sync); mInfo("mnode-sync is stopped, id:%" PRId64, pMgmt->sync); - tsem_destroy(&pMgmt->syncSem); - taosThreadMutexDestroy(&pMgmt->lock); + (void)tsem_destroy(&pMgmt->syncSem); + (void)taosThreadMutexDestroy(&pMgmt->lock); memset(pMgmt, 0, sizeof(SSyncMgmt)); } void mndSyncCheckTimeout(SMnode *pMnode) { mTrace("check sync timeout"); SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { int32_t curSec = taosGetTimestampSec(); int32_t delta = curSec - pMgmt->transSec; @@ -515,7 +514,7 @@ void mndSyncCheckTimeout(SMnode *pMnode) { pMgmt->transSeq = 0; terrno = TSDB_CODE_SYN_TIMEOUT; pMgmt->errCode = TSDB_CODE_SYN_TIMEOUT; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } else { mDebug("trans:%d, waiting for sync confirm, start:%d cur:%d delta:%d seq:%" PRId64, pMgmt->transId, pMgmt->transSec, curSec, curSec - pMgmt->transSec, pMgmt->transSeq); @@ -523,7 +522,7 @@ void mndSyncCheckTimeout(SMnode *pMnode) { } else { // mTrace("check sync timeout msg, no trans waiting for confirm"); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { @@ -536,12 +535,12 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { if (req.pCont == NULL) return TSDB_CODE_OUT_OF_MEMORY; memcpy(req.pCont, pRaw, req.contLen); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); pMgmt->errCode = 0; if (pMgmt->transId != 0) { mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId); - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); rpcFreeCont(req.pCont); TAOS_RETURN(TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED); } @@ -555,23 +554,24 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { if (code == 0) { mInfo("trans:%d, is proposing and wait sem, seq:%" PRId64, transId, seq); pMgmt->transSeq = seq; - taosThreadMutexUnlock(&pMgmt->lock); - tsem_wait(&pMgmt->syncSem); + (void)taosThreadMutexUnlock(&pMgmt->lock); + (void)tsem_wait(&pMgmt->syncSem); } else if (code > 0) { mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; - taosThreadMutexUnlock(&pMgmt->lock); - sdbWriteWithoutFree(pMnode->pSdb, pRaw); - sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID); - code = 0; + (void)taosThreadMutexUnlock(&pMgmt->lock); + code = sdbWriteWithoutFree(pMnode->pSdb, pRaw); + if (code == 0) { + sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID); + } } else { mError("trans:%d, failed to proposed since %s", transId, terrstr()); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); if (terrno == 0) { terrno = TSDB_CODE_APP_ERROR; } @@ -600,15 +600,15 @@ void mndSyncStart(SMnode *pMnode) { void mndSyncStop(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { mInfo("vgId:1, is stopped and post sem, trans:%d", pMgmt->transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } bool mndIsLeader(SMnode *pMnode) { diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index ac379a9f94..f766c00f7d 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -70,16 +70,16 @@ static void mndBuildRuntimeInfo(SMnode* pMnode, SJson* pJson) { SMnodeStat mstat = {0}; mndGetStat(pMnode, &mstat); - tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode); - tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode); - tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup); - tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase); - tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable); - tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable); - tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn); - tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints); - tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage); - tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage); + (void)tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode); + (void)tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode); + (void)tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup); + (void)tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase); + (void)tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable); + (void)tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable); + (void)tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn); + (void)tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints); + (void)tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage); + (void)tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage); } static char* mndBuildTelemetryReport(SMnode* pMnode) { @@ -90,29 +90,29 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) { if (pJson == NULL) return NULL; char clusterName[64] = {0}; - mndGetClusterName(pMnode, clusterName, sizeof(clusterName)); - tjsonAddStringToObject(pJson, "instanceId", clusterName); - tjsonAddDoubleToObject(pJson, "reportVersion", 1); + if ((terrno = mndGetClusterName(pMnode, clusterName, sizeof(clusterName))) != 0) return NULL; + (void)tjsonAddStringToObject(pJson, "instanceId", clusterName); + (void)tjsonAddDoubleToObject(pJson, "reportVersion", 1); if (taosGetOsReleaseName(tmp, NULL, NULL, sizeof(tmp)) == 0) { - tjsonAddStringToObject(pJson, "os", tmp); + (void)tjsonAddStringToObject(pJson, "os", tmp); } float numOfCores = 0; if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) { - tjsonAddStringToObject(pJson, "cpuModel", tmp); - tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores); + (void)tjsonAddStringToObject(pJson, "cpuModel", tmp); + (void)tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores); } else { - tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores); + (void)tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores); } snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB); - tjsonAddStringToObject(pJson, "memory", tmp); + (void)tjsonAddStringToObject(pJson, "memory", tmp); - tjsonAddStringToObject(pJson, "version", version); - tjsonAddStringToObject(pJson, "buildInfo", buildinfo); - tjsonAddStringToObject(pJson, "gitInfo", gitinfo); - tjsonAddStringToObject(pJson, "email", pMgmt->email); + (void)tjsonAddStringToObject(pJson, "version", version); + (void)tjsonAddStringToObject(pJson, "buildInfo", buildinfo); + (void)tjsonAddStringToObject(pJson, "gitInfo", gitinfo); + (void)tjsonAddStringToObject(pJson, "email", pMgmt->email); mndBuildRuntimeInfo(pMnode, pJson); @@ -126,9 +126,9 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) { STelemMgmt* pMgmt = &pMnode->telemMgmt; if (!tsEnableTelem) return 0; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); char* pCont = mndBuildTelemetryReport(pMnode); - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); if (pCont != NULL) { if (taosSendHttpReport(tsTelemServer, tsTelemUri, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) { @@ -142,10 +142,12 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) { } int32_t mndInitTelem(SMnode* pMnode) { + int32_t code = 0; STelemMgmt* pMgmt = &pMnode->telemMgmt; - taosThreadMutexInit(&pMgmt->lock, NULL); - taosGetEmail(pMgmt->email, sizeof(pMgmt->email)); + (void)taosThreadMutexInit(&pMgmt->lock, NULL); + if ((code = taosGetEmail(pMgmt->email, sizeof(pMgmt->email))) != 0) + mWarn("failed to get email since %s", tstrerror(code)); mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer); return 0; @@ -153,5 +155,5 @@ int32_t mndInitTelem(SMnode* pMnode) { void mndCleanupTelem(SMnode* pMnode) { STelemMgmt* pMgmt = &pMnode->telemMgmt; - taosThreadMutexDestroy(&pMgmt->lock); + (void)taosThreadMutexDestroy(&pMgmt->lock); } diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 871c8989ff..8ed3f66009 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -376,7 +376,7 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) { for (int32_t i = 0; i < arbgroupIdNum; ++i) { int32_t arbGroupId = 0; SDB_GET_INT32(pRaw, dataPos, &arbGroupId, _OVER) - taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0); + if ((terrno = taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0)) != 0) goto _OVER; } SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER) @@ -461,7 +461,7 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) { mInfo("trans:%d, perform insert action, row:%p stage:%s, callfunc:1, startFunc:%d", pTrans->id, pTrans, mndTransStr(pTrans->stage), pTrans->startFunc); - taosThreadMutexInit(&pTrans->mutex, NULL); + (void)taosThreadMutexInit(&pTrans->mutex, NULL); if (pTrans->startFunc > 0) { TransCbFp fp = mndTransGetCbFp(pTrans->startFunc); @@ -616,7 +616,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo)); pTrans->mTraceId = pReq ? TRACE_GET_ROOTID(&pReq->info.traceId) : tGenIdPI64(); taosInitRWLatch(&pTrans->lockRpcArray); - taosThreadMutexInit(&pTrans->mutex, NULL); + (void)taosThreadMutexInit(&pTrans->mutex, NULL); if (pTrans->redoActions == NULL || pTrans->undoActions == NULL || pTrans->commitActions == NULL || pTrans->pRpcArray == NULL) { @@ -627,7 +627,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, } if (pReq != NULL) { - taosArrayPush(pTrans->pRpcArray, &pReq->info); + if (taosArrayPush(pTrans->pRpcArray, &pReq->info) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } pTrans->originRpcType = pReq->msgType; } @@ -765,7 +768,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname) } void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId) { - taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0); + (void)taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0); } void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; } @@ -1505,9 +1508,9 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr pTrans->actionPos++; mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage), pAction->id); - taosThreadMutexUnlock(&pTrans->mutex); + (void)taosThreadMutexUnlock(&pTrans->mutex); code = mndTransSync(pMnode, pTrans); - taosThreadMutexLock(&pTrans->mutex); + (void)taosThreadMutexLock(&pTrans->mutex); if (code != 0) { pTrans->actionPos--; pTrans->code = terrno; @@ -1540,21 +1543,21 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { int32_t code = TSDB_CODE_ACTION_IN_PROGRESS; - taosThreadMutexLock(&pTrans->mutex); + (void)taosThreadMutexLock(&pTrans->mutex); if (pTrans->stage == TRN_STAGE_REDO_ACTION) { code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->redoActions, topHalf); } - taosThreadMutexUnlock(&pTrans->mutex); + (void)taosThreadMutexUnlock(&pTrans->mutex); return code; } static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { int32_t code = TSDB_CODE_ACTION_IN_PROGRESS; - taosThreadMutexLock(&pTrans->mutex); + (void)taosThreadMutexLock(&pTrans->mutex); if (pTrans->stage == TRN_STAGE_UNDO_ACTION) { code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->undoActions, topHalf); } - taosThreadMutexUnlock(&pTrans->mutex); + (void)taosThreadMutexUnlock(&pTrans->mutex); return code; } @@ -1894,7 +1897,7 @@ void mndTransPullup(SMnode *pMnode) { STrans *pTrans = NULL; pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans); if (pIter == NULL) break; - taosArrayPush(pArray, &pTrans->id); + (void)taosArrayPush(pArray, &pTrans->id); sdbRelease(pSdb, pTrans); } @@ -1925,36 +1928,36 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false); char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)stage, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)stage, false); char opername[TSDB_TRANS_OPER_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(opername, pTrans->opername, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)opername, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)opername, false); char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false); char stbname[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0}; char detail[TSDB_TRANS_ERROR_LEN + 1] = {0}; @@ -1970,7 +1973,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl } STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false); numOfRows++; sdbRelease(pSdb, pTrans); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 2095f80f0f..8bb2f11e7c 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -682,7 +682,7 @@ static void ipRangeToStr(SIpV4Range *range, char *buf) { struct in_addr addr; addr.s_addr = range->ip; - uv_inet_ntop(AF_INET, &addr, buf, 32); + (void)uv_inet_ntop(AF_INET, &addr, buf, 32); if (range->mask != 32) { (void)sprintf(buf + strlen(buf), "/%d", range->mask); } @@ -2188,7 +2188,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode mndReleaseDb(pMnode, pDb); TAOS_CHECK_GOTO(terrno, &lino, _OVER); // TODO: refactor the terrno to code } - taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len); + (void)taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len); mndReleaseDb(pMnode, pDb); } else { taosHashClear(pNewUser->readDbs); @@ -2204,7 +2204,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode mndReleaseDb(pMnode, pDb); TAOS_CHECK_GOTO(terrno, &lino, _OVER); // TODO: refactor the terrno to code } - taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len); + (void)taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len); mndReleaseDb(pMnode, pDb); } else { taosHashClear(pNewUser->writeDbs); @@ -2311,7 +2311,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { TAOS_CHECK_GOTO(mndAcquireUser(pMnode, alterReq.user, &pUser), &lino, _OVER); - mndAcquireUser(pMnode, pReq->info.conn.user, &pOperUser); + (void)mndAcquireUser(pMnode, pReq->info.conn.user, &pOperUser); if (pOperUser == NULL) { TAOS_CHECK_GOTO(TSDB_CODE_MND_NO_USER_FROM_CONN, &lino, _OVER); } @@ -2517,7 +2517,7 @@ static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) { mndTransDrop(pTrans); TAOS_RETURN(terrno); } - ipWhiteMgtRemove(pUser->user); + (void)ipWhiteMgtRemove(pUser->user); mndTransDrop(pTrans); TAOS_RETURN(0); @@ -2830,7 +2830,10 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i } if (nodesStringToNode(value, &pAst) == 0) { - nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen); + if (nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen) != 0) { + sqlLen = 5; + (void)sprintf(*sql, "error"); + } nodesDestroyNode(pAst); } else { sqlLen = 5; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 30c11c09ce..57a7453eac 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -390,7 +390,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg return NULL; } - tSerializeSCreateVnodeReq(pReq, contLen, &createReq); + (void)tSerializeSCreateVnodeReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; } @@ -436,7 +436,7 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); + (void)tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -514,7 +514,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p return NULL; } - tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); + (void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -587,7 +587,7 @@ static void *mndBuildCheckLearnCatchupReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p return NULL; } - tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); + (void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); *pContLen = contLen; return pReq; } @@ -611,7 +611,7 @@ static void *mndBuildDisableVnodeWriteReq(SMnode *pMnode, SDbObj *pDb, int32_t v return NULL; } - tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); + (void)tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); *pContLen = contLen; return pReq; } @@ -639,7 +639,7 @@ static void *mndBuildAlterVnodeHashRangeReq(SMnode *pMnode, int32_t srcVgId, SVg return NULL; } - tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); + (void)tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -664,7 +664,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb return NULL; } - tSerializeSDropVnodeReq(pReq, contLen, &dropReq); + (void)tSerializeSDropVnodeReq(pReq, contLen, &dropReq); *pContLen = contLen; return pReq; } @@ -699,7 +699,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 } if (online && pDnode->numOfSupportVnodes > 0) { - taosArrayPush(pArray, pDnode); + if (taosArrayPush(pArray, pDnode) == NULL) return false; } return true; } @@ -907,7 +907,7 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) { epset.inUse = epset.numOfEps; } - addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + (void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); mndReleaseDnode(pMnode, pDnode); } epsetSort(&epset); @@ -930,7 +930,7 @@ SEpSet mndGetVgroupEpsetById(SMnode *pMnode, int32_t vgId) { epset.inUse = epset.numOfEps; } - addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + (void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); mndReleaseDnode(pMnode, pDnode); } @@ -965,26 +965,26 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); SName name = {0}; char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, varDataVal(db)); + (void)tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); + (void)tNameGetDbName(&name, varDataVal(db)); varDataSetLen(db, strlen(varDataVal(db))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)db, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); // default 3 replica, add 1 replica if move vnode for (int32_t i = 0; i < 4; ++i) { pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); if (i < pVgroup->replica) { int16_t dnodeId = (int16_t)pVgroup->vnodeGid[i].dnodeId; - colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); bool exist = false; bool online = false; @@ -1038,7 +1038,7 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); } else { colDataSetNULL(pColInfo, numOfRows); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); @@ -1048,19 +1048,19 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); int32_t cacheUsage = (int32_t)pVgroup->cacheUsage; - colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); // pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); // if (pDb == NULL || pDb->compactStartTime <= 0) { // colDataSetNULL(pColInfo, numOfRows); // } else { - // colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false); + // (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false); // } numOfRows++; @@ -1158,10 +1158,10 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB cols = 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); // db_name const char *dbname = mndGetDbStr(pVgroup->dbName); @@ -1172,7 +1172,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB STR_WITH_MAXSIZE_TO_VARSTR(b1, "NULL", TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE); } pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); // dnode is online? SDnodeObj *pDnode = mndAcquireDnode(pMnode, pGid->dnodeId); @@ -1186,18 +1186,18 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB ESyncState syncState = (isDnodeOnline) ? pGid->syncState : TAOS_SYNC_STATE_OFFLINE; STR_TO_VARSTR(buf, syncStr(syncState)); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); int64_t roleTimeMs = (isDnodeOnline) ? pGid->roleTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); int64_t startTimeMs = (isDnodeOnline) ? pGid->startTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); numOfRows++; sdbRelease(pSdb, pDnode); @@ -2452,7 +2452,7 @@ static void *mndBuildSForceBecomeFollowerReq(SMnode *pMnode, SVgObj *pVgroup, in pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); + (void)tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); *pContLen = contLen; return pReq; } @@ -3366,7 +3366,7 @@ static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgrou pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); + (void)tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); *pContLen = contLen; return pReq; } diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index c1d4ba7893..7244f2d7c9 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -46,7 +46,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { } for (ESdbType i = 0; i < SDB_MAX; ++i) { - taosThreadRwlockInit(&pSdb->locks[i], NULL); + (void)taosThreadRwlockInit(&pSdb->locks[i], NULL); pSdb->maxId[i] = 0; pSdb->tableVer[i] = 0; pSdb->keyTypes[i] = SDB_KEY_INT32; @@ -60,7 +60,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { pSdb->commitTerm = -1; pSdb->commitConfig = -1; pSdb->pMnode = pOption->pMnode; - taosThreadMutexInit(&pSdb->filelock, NULL); + (void)taosThreadMutexInit(&pSdb->filelock, NULL); mInfo("sdb init success"); return pSdb; } @@ -68,7 +68,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { void sdbCleanup(SSdb *pSdb) { mInfo("start to cleanup sdb"); - sdbWriteFile(pSdb, 0); + (void)sdbWriteFile(pSdb, 0); if (pSdb->currDir != NULL) { taosMemoryFreeClear(pSdb->currDir); @@ -99,14 +99,14 @@ void sdbCleanup(SSdb *pSdb) { taosHashClear(hash); taosHashCleanup(hash); - taosThreadRwlockDestroy(&pSdb->locks[i]); + (void)taosThreadRwlockDestroy(&pSdb->locks[i]); pSdb->hashObjs[i] = NULL; memset(&pSdb->locks[i], 0, sizeof(pSdb->locks[i])); mInfo("sdb table:%s is cleaned up", sdbTableName(i)); } - taosThreadMutexDestroy(&pSdb->filelock); + (void)taosThreadMutexDestroy(&pSdb->filelock); taosMemoryFree(pSdb); mInfo("sdb is cleaned up"); } @@ -188,19 +188,19 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config void sdbWriteLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d start write lock:%p", type, pLock); - taosThreadRwlockWrlock(pLock); + (void)taosThreadRwlockWrlock(pLock); // mTrace("sdb table:%d stop write lock:%p", type, pLock); } void sdbReadLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d start read lock:%p", type, pLock); - taosThreadRwlockRdlock(pLock); + (void)taosThreadRwlockRdlock(pLock); // mTrace("sdb table:%d stop read lock:%p", type, pLock); } void sdbUnLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d unlock:%p", type, pLock); - taosThreadRwlockUnlock(pLock); + (void)taosThreadRwlockUnlock(pLock); } diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 0952fbe7a3..6fb395e63f 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -258,7 +258,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { if (code != 0) { mError("failed to read sdb file:%s head since %s", file, tstrerror(code)); taosMemoryFree(pRaw); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return -1; } @@ -361,14 +361,14 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { pSdb->commitTerm, pSdb->commitConfig); _OVER: - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); sdbFreeRaw(pRaw); TAOS_RETURN(code); } int32_t sdbReadFile(SSdb *pSdb) { - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); sdbResetData(pSdb); int32_t code = sdbReadFileImp(pSdb); @@ -377,7 +377,7 @@ int32_t sdbReadFile(SSdb *pSdb) { sdbResetData(pSdb); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); return code; } @@ -404,7 +404,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { code = sdbWriteFileHead(pSdb, pFile); if (code != 0) { mError("failed to write sdb file:%s head since %s", tmpfile, tstrerror(code)); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return -1; } @@ -507,7 +507,9 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { } } - taosCloseFile(&pFile); + if (taosCloseFile(&pFile) != 0) { + code = taosRenameFile(tmpfile, curfile); + } if (code == 0) { code = taosRenameFile(tmpfile, curfile); @@ -541,7 +543,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { return 0; } - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); if (pSdb->pWal != NULL) { if (pSdb->sync > 0) { code = syncBeginSnapshot(pSdb->sync, pSdb->applyIndex); @@ -560,7 +562,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { if (code != 0) { mError("failed to write sdb file since %s", tstrerror(code)); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); return code; } @@ -602,7 +604,7 @@ static void sdbCloseIter(SSdbIter *pIter) { if (pIter == NULL) return; if (pIter->file != NULL) { - taosCloseFile(&pIter->file); + (void)taosCloseFile(&pIter->file); pIter->file = NULL; } @@ -624,18 +626,18 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter char datafile[PATH_MAX] = {0}; snprintf(datafile, sizeof(datafile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP); - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); int64_t commitIndex = pSdb->commitIndex; int64_t commitTerm = pSdb->commitTerm; int64_t commitConfig = pSdb->commitConfig; if (taosCopyFile(datafile, pIter->name) < 0) { - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); code = TAOS_SYSTEM_ERROR(errno); mError("failed to copy sdb file %s to %s since %s", datafile, pIter->name, tstrerror(code)); sdbCloseIter(pIter); TAOS_RETURN(code); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); pIter->file = taosOpenFile(pIter->name, TD_FILE_READ); if (pIter->file == NULL) { @@ -725,7 +727,10 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i goto _OVER; } - taosCloseFile(&pIter->file); + if (taosCloseFile(&pIter->file) != 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _OVER; + } pIter->file = NULL; char datafile[PATH_MAX] = {0}; diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 4043ff6a12..03b45c25b4 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -176,7 +176,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * if (code != 0) { if (terrno == 0) terrno = TSDB_CODE_MND_TRANS_UNKNOW_ERROR; code = terrno; - taosHashRemove(hash, pRow->pObj, keySize); + (void)taosHashRemove(hash, pRow->pObj, keySize); sdbFreeRow(pSdb, pRow, false); terrno = code; sdbUnLock(pSdb, type); @@ -239,10 +239,10 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * SSdbRow *pOldRow = *ppOldRow; pOldRow->status = pRaw->status; - atomic_add_fetch_32(&pOldRow->refCount, 1); + (void)atomic_add_fetch_32(&pOldRow->refCount, 1); sdbPrintOper(pSdb, pOldRow, "delete"); - taosHashRemove(hash, pOldRow->pObj, keySize); + TAOS_CHECK_RETURN(taosHashRemove(hash, pOldRow->pObj, keySize)); pSdb->tableVer[pOldRow->type]++; sdbUnLock(pSdb, type); @@ -309,7 +309,7 @@ void *sdbAcquireAll(SSdb *pSdb, ESdbType type, const void *pKey, bool onlyReady) SSdbRow *pRow = *ppRow; switch (pRow->status) { case SDB_STATUS_READY: - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; sdbPrintOper(pSdb, pRow, "acquire"); break; @@ -327,7 +327,7 @@ void *sdbAcquireAll(SSdb *pSdb, ESdbType type, const void *pKey, bool onlyReady) if (pRet == NULL) { if (!onlyReady) { terrno = 0; - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; sdbPrintOper(pSdb, pRow, "acquire"); } @@ -395,7 +395,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) { continue; } - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "fetch"); *ppObj = pRow->pObj; break; @@ -423,7 +423,7 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat continue; } - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "fetch"); *ppObj = pRow->pObj; *status = pRow->status; diff --git a/source/dnode/mnode/sdb/src/sdbRow.c b/source/dnode/mnode/sdb/src/sdbRow.c index c078e7eb21..da5a232851 100644 --- a/source/dnode/mnode/sdb/src/sdbRow.c +++ b/source/dnode/mnode/sdb/src/sdbRow.c @@ -42,7 +42,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc) { // remove attached object such as trans SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type]; if (deleteFp != NULL) { - (*deleteFp)(pSdb, pRow->pObj, callFunc); + (void)(*deleteFp)(pSdb, pRow->pObj, callFunc); } sdbPrintOper(pSdb, pRow, "free"); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 5e536e5fbf..ce7c8aee7f 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -36,7 +36,7 @@ int32_t sndBuildStreamTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProce streamTaskOpenAllUpstreamInput(pTask); streamTaskResetUpstreamStageInfo(pTask); - streamSetupScheduleTrigger(pTask); + (void)streamSetupScheduleTrigger(pTask); SCheckpointInfo *pChkInfo = &pTask->chkInfo; tqSetRestoreVersionInfo(pTask); @@ -91,14 +91,14 @@ FAIL: } int32_t sndInit(SSnode *pSnode) { - streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS); + (void)streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS); return 0; } void sndClose(SSnode *pSnode) { stopRsync(); streamMetaNotifyClose(pSnode->pMeta); - streamMetaCommit(pSnode->pMeta); + (void)streamMetaCommit(pSnode->pMeta); streamMetaClose(pSnode->pMeta); taosMemoryFree(pSnode); } diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index d986d63ac7..87d7d2150e 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -39,9 +39,9 @@ typedef struct SMetaCache SMetaCache; // clang-format on // metaOpen ================== -int32_t metaRLock(SMeta* pMeta); -int32_t metaWLock(SMeta* pMeta); -int32_t metaULock(SMeta* pMeta); +void metaRLock(SMeta* pMeta); +void metaWLock(SMeta* pMeta); +void metaULock(SMeta* pMeta); // metaEntry ================== int metaEncodeEntry(SEncoder* pCoder, const SMetaEntry* pME); diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 29eaa0509a..243f51ca0a 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -194,7 +194,7 @@ typedef enum { #define TD_SMA_LOOPS_CHECK(n, limit) \ if (++(n) > limit) { \ - sched_yield(); \ + (void)sched_yield(); \ (n) = 0; \ } diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 978821f890..f6f86850a4 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -378,7 +378,7 @@ struct STsdb { struct { SVHashTable *ht; SArray *arr; - } *commitInfo; + } * commitInfo; }; struct TSDBKEY { @@ -937,7 +937,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, TSDBROW *row, STsdb *pTsdb); int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, TSDBROW *row, bool dup); -int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); +void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle); int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h); @@ -945,7 +945,6 @@ int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheGetBlockS3(SLRUCache *pCache, STsdbFD *pFD, LRUHandle **handle); int32_t tsdbCacheGetPageS3(SLRUCache *pCache, STsdbFD *pFD, int64_t pgno, LRUHandle **handle); int32_t tsdbCacheSetPageS3(SLRUCache *pCache, STsdbFD *pFD, int64_t pgno, uint8_t *pPage); -int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); diff --git a/source/dnode/vnode/src/meta/metaCache.c b/source/dnode/vnode/src/meta/metaCache.c index 8af902538d..3d4067ba99 100644 --- a/source/dnode/vnode/src/meta/metaCache.c +++ b/source/dnode/vnode/src/meta/metaCache.c @@ -156,7 +156,7 @@ int32_t metaCacheOpen(SMeta* pMeta) { } taosHashSetFreeFp(pMeta->pCache->sTagFilterResCache.pTableEntry, freeCacheEntryFp); - taosThreadMutexInit(&pMeta->pCache->sTagFilterResCache.lock, NULL); + (void)taosThreadMutexInit(&pMeta->pCache->sTagFilterResCache.lock, NULL); pMeta->pCache->STbGroupResCache.pResCache = taosLRUCacheInit(5 * 1024 * 1024, -1, 0.5); if (pMeta->pCache->STbGroupResCache.pResCache == NULL) { @@ -171,7 +171,7 @@ int32_t metaCacheOpen(SMeta* pMeta) { } taosHashSetFreeFp(pMeta->pCache->STbGroupResCache.pTableEntry, freeCacheEntryFp); - taosThreadMutexInit(&pMeta->pCache->STbGroupResCache.lock, NULL); + (void)taosThreadMutexInit(&pMeta->pCache->STbGroupResCache.lock, NULL); pMeta->pCache->STbFilterCache.pStb = taosHashInit(0, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); @@ -201,11 +201,11 @@ void metaCacheClose(SMeta* pMeta) { statsCacheClose(pMeta); taosLRUCacheCleanup(pMeta->pCache->sTagFilterResCache.pUidResCache); - taosThreadMutexDestroy(&pMeta->pCache->sTagFilterResCache.lock); + (void)taosThreadMutexDestroy(&pMeta->pCache->sTagFilterResCache.lock); taosHashCleanup(pMeta->pCache->sTagFilterResCache.pTableEntry); taosLRUCacheCleanup(pMeta->pCache->STbGroupResCache.pResCache); - taosThreadMutexDestroy(&pMeta->pCache->STbGroupResCache.lock); + (void)taosThreadMutexDestroy(&pMeta->pCache->STbGroupResCache.lock); taosHashCleanup(pMeta->pCache->STbGroupResCache.pTableEntry); taosHashCleanup(pMeta->pCache->STbFilterCache.pStb); @@ -495,7 +495,7 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv return TSDB_CODE_OUT_OF_MEMORY; } } else { - taosLRUCacheRelease(pCache, pRes, false); + (void)taosLRUCacheRelease(pCache, pRes, false); } } @@ -552,7 +552,9 @@ int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pK int32_t size = *(int32_t*)p; // set the result into the buffer - taosArrayAddBatch(pList1, p + sizeof(int32_t), size); + if (taosArrayAddBatch(pList1, p + sizeof(int32_t), size) == NULL) { + return terrno; + } (*pEntry)->hitTimes += 1; @@ -562,7 +564,7 @@ int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pK ((double)(*pEntry)->hitTimes) / acc); } - taosLRUCacheRelease(pCache, pHandle, false); + (void)taosLRUCacheRelease(pCache, pHandle, false); // unlock meta (void)taosThreadMutexUnlock(pLock); @@ -618,7 +620,7 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL p->hitTimes = 0; tdListInit(&p->list, keyLen); TAOS_CHECK_RETURN(taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES)); - tdListAppend(&p->list, pKey); + (void)tdListAppend(&p->list, pKey); return 0; } @@ -662,7 +664,7 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int } else { // check if it exists or not size_t size = listNEles(&(*pEntry)->list); if (size == 0) { - tdListAppend(&(*pEntry)->list, pKey); + (void)tdListAppend(&(*pEntry)->list, pKey); } else { SListNode* pNode = listHead(&(*pEntry)->list); uint64_t* p = (uint64_t*)pNode->data; @@ -671,7 +673,7 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } else { // not equal, append it - tdListAppend(&(*pEntry)->list, pKey); + (void)tdListAppend(&(*pEntry)->list, pKey); } } } @@ -761,7 +763,7 @@ int32_t metaGetCachedTbGroup(void* pVnode, tb_uid_t suid, const uint8_t* pKey, i ((double)(*pEntry)->hitTimes) / acc); } - taosLRUCacheRelease(pCache, pHandle, false); + (void)taosLRUCacheRelease(pCache, pHandle, false); // unlock meta (void)taosThreadMutexUnlock(pLock); @@ -839,7 +841,7 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int } else { // check if it exists or not size_t size = listNEles(&(*pEntry)->list); if (size == 0) { - tdListAppend(&(*pEntry)->list, pKey); + (void)tdListAppend(&(*pEntry)->list, pKey); } else { SListNode* pNode = listHead(&(*pEntry)->list); uint64_t* p = (uint64_t*)pNode->data; @@ -848,14 +850,14 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } else { // not equal, append it - tdListAppend(&(*pEntry)->list, pKey); + (void)tdListAppend(&(*pEntry)->list, pKey); } } } // add to cache. - taosLRUCacheInsert(pCache, key, TAG_FILTER_RES_KEY_LEN, pPayload, payloadLen, freeTbGroupCachePayload, NULL, - TAOS_LRU_PRIORITY_LOW, NULL); + (void)taosLRUCacheInsert(pCache, key, TAG_FILTER_RES_KEY_LEN, pPayload, payloadLen, freeTbGroupCachePayload, NULL, + TAOS_LRU_PRIORITY_LOW, NULL); _end: (void)taosThreadMutexUnlock(pLock); metaDebug("vgId:%d, suid:%" PRIu64 " tb group added into cache, total:%d, tables:%d", vgId, suid, diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index ec26e94c5a..13163aef05 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -29,10 +29,10 @@ static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen static int32_t metaInitLock(SMeta *pMeta) { TdThreadRwlockAttr attr; - taosThreadRwlockAttrInit(&attr); - taosThreadRwlockAttrSetKindNP(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); - taosThreadRwlockInit(&pMeta->lock, &attr); - taosThreadRwlockAttrDestroy(&attr); + (void)taosThreadRwlockAttrInit(&attr); + (void)taosThreadRwlockAttrSetKindNP(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + (void)taosThreadRwlockInit(&pMeta->lock, &attr); + (void)taosThreadRwlockAttrDestroy(&attr); return 0; } static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); } @@ -48,7 +48,7 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) { char indexFullPath[128] = {0}; // create handle - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN); offset = strlen(path); snprintf(path + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VNODE_META_DIR); @@ -56,16 +56,16 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) { TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); } - metaInitLock(pMeta); + (void)metaInitLock(pMeta); pMeta->path = (char *)&pMeta[1]; strcpy(pMeta->path, path); - taosRealPath(pMeta->path, NULL, strlen(path) + 1); + (void)taosRealPath(pMeta->path, NULL, strlen(path) + 1); pMeta->pVnode = pVnode; // create path if not created yet - taosMkDir(pMeta->path); + (void)taosMkDir(pMeta->path); // open env code = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback, @@ -186,31 +186,19 @@ int metaAlterCache(SMeta *pMeta, int32_t nPage) { return code; } -int32_t metaRLock(SMeta *pMeta) { +void metaRLock(SMeta *pMeta) { metaTrace("meta rlock %p", &pMeta->lock); - int32_t code = taosThreadRwlockRdlock(&pMeta->lock); - if (code) { - return TAOS_SYSTEM_ERROR(code); - } - return 0; + (void)taosThreadRwlockRdlock(&pMeta->lock); } -int32_t metaWLock(SMeta *pMeta) { +void metaWLock(SMeta *pMeta) { metaTrace("meta wlock %p", &pMeta->lock); - int32_t code = taosThreadRwlockWrlock(&pMeta->lock); - if (code) { - return TAOS_SYSTEM_ERROR(code); - } - return 0; + (void)taosThreadRwlockWrlock(&pMeta->lock); } -int32_t metaULock(SMeta *pMeta) { +void metaULock(SMeta *pMeta) { metaTrace("meta ulock %p", &pMeta->lock); - int32_t code = taosThreadRwlockUnlock(&pMeta->lock); - if (code) { - return TAOS_SYSTEM_ERROR(code); - } - return 0; + (void)taosThreadRwlockUnlock(&pMeta->lock); } static void metaCleanup(SMeta **ppMeta) { @@ -235,7 +223,7 @@ static void metaCleanup(SMeta **ppMeta) { if (pMeta->pSkmDb) tdbTbClose(pMeta->pSkmDb); if (pMeta->pTbDb) tdbTbClose(pMeta->pTbDb); if (pMeta->pEnv) tdbClose(pMeta->pEnv); - metaDestroyLock(pMeta); + (void)metaDestroyLock(pMeta); taosMemoryFreeClear(*ppMeta); } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index ee616d7a0d..d4ff980311 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -252,7 +252,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) { if (!pTbCur->paused) { metaReaderClear(&pTbCur->mr); if (pTbCur->pDbc) { - tdbTbcClose((TBC *)pTbCur->pDbc); + (void)tdbTbcClose((TBC *)pTbCur->pDbc); } } taosMemoryFree(pTbCur); @@ -262,7 +262,7 @@ void metaCloseTbCursor(SMTbCursor *pTbCur) { void metaPauseTbCursor(SMTbCursor *pTbCur) { if (!pTbCur->paused) { metaReaderClear(&pTbCur->mr); - tdbTbcClose((TBC *)pTbCur->pDbc); + (void)tdbTbcClose((TBC *)pTbCur->pDbc); pTbCur->paused = 1; } } @@ -270,19 +270,19 @@ void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) { if (pTbCur->paused) { metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK); - tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL); + (void)tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL); if (first) { - tdbTbcMoveToFirst((TBC *)pTbCur->pDbc); + (void)tdbTbcMoveToFirst((TBC *)pTbCur->pDbc); } else { int c = 1; - tdbTbcMoveTo(pTbCur->pDbc, pTbCur->pKey, pTbCur->kLen, &c); + (void)tdbTbcMoveTo(pTbCur->pDbc, pTbCur->pKey, pTbCur->kLen, &c); if (c == 0) { if (move) tdbTbcMoveToNext(pTbCur->pDbc); } else if (c < 0) { - tdbTbcMoveToPrev(pTbCur->pDbc); + (void)tdbTbcMoveToPrev(pTbCur->pDbc); } else { - tdbTbcMoveToNext(pTbCur->pDbc); + (void)tdbTbcMoveToNext(pTbCur->pDbc); } } @@ -303,7 +303,7 @@ int32_t metaTbCursorNext(SMTbCursor *pTbCur, ETableType jumpTableType) { tDecoderClear(&pTbCur->mr.coder); - metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey); + (void)metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey); if (pTbCur->mr.me.type == jumpTableType) { continue; } @@ -327,7 +327,7 @@ int32_t metaTbCursorPrev(SMTbCursor *pTbCur, ETableType jumpTableType) { tDecoderClear(&pTbCur->mr.coder); - metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey); + (void)metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey); if (pTbCur->mr.me.type == jumpTableType) { continue; } @@ -355,11 +355,11 @@ _query: version = ((SUidIdxVal *)pData)[0].version; - tdbTbGet(pMeta->pTbDb, &(STbDbKey){.uid = uid, .version = version}, sizeof(STbDbKey), &pData, &nData); + (void)tdbTbGet(pMeta->pTbDb, &(STbDbKey){.uid = uid, .version = version}, sizeof(STbDbKey), &pData, &nData); SMetaEntry me = {0}; tDecoderInit(&dc, pData, nData); - metaDecodeEntry(&dc, &me); + (void)metaDecodeEntry(&dc, &me); if (me.type == TSDB_SUPER_TABLE) { if (sver == -1 || sver == me.stbEntry.schemaRow.version) { pSchema = tCloneSSchemaWrapper(&me.stbEntry.schemaRow); @@ -385,7 +385,7 @@ _query: } tDecoderInit(&dc, pData, nData); - tDecodeSSchemaWrapperEx(&dc, &schema); + (void)tDecodeSSchemaWrapperEx(&dc, &schema); pSchema = tCloneSSchemaWrapper(&schema); tDecoderClear(&dc); @@ -433,7 +433,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) { if (!pCtbCur->paused) { if (pCtbCur->pMeta && pCtbCur->lock) metaULock(pCtbCur->pMeta); if (pCtbCur->pCur) { - tdbTbcClose(pCtbCur->pCur); + (void)tdbTbcClose(pCtbCur->pCur); } } tdbFree(pCtbCur->pKey); @@ -444,7 +444,7 @@ void metaCloseCtbCursor(SMCtbCursor *pCtbCur) { void metaPauseCtbCursor(SMCtbCursor *pCtbCur) { if (!pCtbCur->paused) { - tdbTbcClose((TBC *)pCtbCur->pCur); + (void)tdbTbcClose((TBC *)pCtbCur->pCur); if (pCtbCur->lock) { metaULock(pCtbCur->pMeta); } @@ -472,17 +472,17 @@ int32_t metaResumeCtbCursor(SMCtbCursor *pCtbCur, int8_t first) { ctbIdxKey.suid = pCtbCur->suid; ctbIdxKey.uid = INT64_MIN; int c = 0; - tdbTbcMoveTo(pCtbCur->pCur, &ctbIdxKey, sizeof(ctbIdxKey), &c); + (void)tdbTbcMoveTo(pCtbCur->pCur, &ctbIdxKey, sizeof(ctbIdxKey), &c); if (c > 0) { - tdbTbcMoveToNext(pCtbCur->pCur); + (void)tdbTbcMoveToNext(pCtbCur->pCur); } } else { int c = 0; ret = tdbTbcMoveTo(pCtbCur->pCur, pCtbCur->pKey, pCtbCur->kLen, &c); if (c < 0) { - tdbTbcMoveToPrev(pCtbCur->pCur); + (void)tdbTbcMoveToPrev(pCtbCur->pCur); } else { - tdbTbcMoveToNext(pCtbCur->pCur); + (void)tdbTbcMoveToNext(pCtbCur->pCur); } } } @@ -540,9 +540,9 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) { } // move to the suid - tdbTbcMoveTo(pStbCur->pCur, &suid, sizeof(suid), &c); + (void)tdbTbcMoveTo(pStbCur->pCur, &suid, sizeof(suid), &c); if (c > 0) { - tdbTbcMoveToNext(pStbCur->pCur); + (void)tdbTbcMoveToNext(pStbCur->pCur); } return pStbCur; @@ -552,7 +552,7 @@ void metaCloseStbCursor(SMStbCursor *pStbCur) { if (pStbCur) { if (pStbCur->pMeta) metaULock(pStbCur->pMeta); if (pStbCur->pCur) { - tdbTbcClose(pStbCur->pCur); + (void)tdbTbcClose(pStbCur->pCur); tdbFree(pStbCur->pKey); tdbFree(pStbCur->pVal); @@ -603,35 +603,35 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv skmDbKey.uid = suid ? suid : uid; skmDbKey.sver = INT32_MAX; - tdbTbcOpen(pMeta->pSkmDb, &pSkmDbC, NULL); + (void)tdbTbcOpen(pMeta->pSkmDb, &pSkmDbC, NULL); metaRLock(pMeta); if (tdbTbcMoveTo(pSkmDbC, &skmDbKey, sizeof(skmDbKey), &c) < 0) { metaULock(pMeta); - tdbTbcClose(pSkmDbC); + (void)tdbTbcClose(pSkmDbC); code = TSDB_CODE_NOT_FOUND; goto _exit; } if (c == 0) { metaULock(pMeta); - tdbTbcClose(pSkmDbC); + (void)tdbTbcClose(pSkmDbC); code = TSDB_CODE_FAILED; metaError("meta/query: incorrect c: %" PRId32 ".", c); goto _exit; } if (c < 0) { - tdbTbcMoveToPrev(pSkmDbC); + (void)tdbTbcMoveToPrev(pSkmDbC); } const void *pKey = NULL; int32_t nKey = 0; - tdbTbcGet(pSkmDbC, &pKey, &nKey, NULL, NULL); + (void)tdbTbcGet(pSkmDbC, &pKey, &nKey, NULL, NULL); if (((SSkmDbKey *)pKey)->uid != skmDbKey.uid) { metaULock(pMeta); - tdbTbcClose(pSkmDbC); + (void)tdbTbcClose(pSkmDbC); code = TSDB_CODE_NOT_FOUND; goto _exit; } @@ -639,7 +639,7 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv sver = ((SSkmDbKey *)pKey)->sver; metaULock(pMeta); - tdbTbcClose(pSkmDbC); + (void)tdbTbcClose(pSkmDbC); } } @@ -753,9 +753,9 @@ SMSmaCursor *metaOpenSmaCursor(SMeta *pMeta, tb_uid_t uid) { // move to the suid smaIdxKey.uid = uid; smaIdxKey.smaUid = INT64_MIN; - tdbTbcMoveTo(pSmaCur->pCur, &smaIdxKey, sizeof(smaIdxKey), &c); + (void)tdbTbcMoveTo(pSmaCur->pCur, &smaIdxKey, sizeof(smaIdxKey), &c); if (c > 0) { - tdbTbcMoveToNext(pSmaCur->pCur); + (void)tdbTbcMoveToNext(pSmaCur->pCur); } return pSmaCur; @@ -765,7 +765,7 @@ void metaCloseSmaCursor(SMSmaCursor *pSmaCur) { if (pSmaCur) { if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta); if (pSmaCur->pCur) { - tdbTbcClose(pSmaCur->pCur); + (void)tdbTbcClose(pSmaCur->pCur); tdbFree(pSmaCur->pKey); tdbFree(pSmaCur->pVal); @@ -863,7 +863,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) { _err: metaReaderClear(&mr); taosArrayDestroy(pSmaIds); - tFreeTSmaWrapper(pSW, deepCopy); + (void)tFreeTSmaWrapper(pSW, deepCopy); return NULL; } @@ -1086,7 +1086,7 @@ int32_t metaFilterCreateTime(void *pVnode, SMetaFltParam *arg, SArray *pUids) { END: if (pCursor->pMeta) metaULock(pCursor->pMeta); - if (pCursor->pCur) tdbTbcClose(pCursor->pCur); + if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur); taosMemoryFree(pCursor); return ret; } @@ -1153,7 +1153,7 @@ int32_t metaFilterTableName(void *pVnode, SMetaFltParam *arg, SArray *pUids) { END: if (pCursor->pMeta) metaULock(pCursor->pMeta); - if (pCursor->pCur) tdbTbcClose(pCursor->pCur); + if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur); taosMemoryFree(buf); taosMemoryFree(pKey); @@ -1182,7 +1182,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) { END: if (pCursor->pMeta) metaULock(pCursor->pMeta); - if (pCursor->pCur) tdbTbcClose(pCursor->pCur); + if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur); taosMemoryFree(buf); taosMemoryFree(pKey); @@ -1221,7 +1221,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) { } tbDbKey.uid = param->suid; tbDbKey.version = ((SUidIdxVal *)pData)[0].version; - tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); + (void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); ret = metaDecodeEntry(&dc, &oStbEntry); @@ -1353,7 +1353,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) { END: if (pCursor->pMeta) metaULock(pCursor->pMeta); - if (pCursor->pCur) tdbTbcClose(pCursor->pCur); + if (pCursor->pCur) (void)tdbTbcClose(pCursor->pCur); if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); tDecoderClear(&dc); tdbFree(pData); @@ -1427,7 +1427,7 @@ int32_t metaGetTableTags(void *pVnode, uint64_t suid, SArray *pUidTagInfo) { taosHashInit(numOfElems / 0.7, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); for (int i = 0; i < numOfElems; i++) { STUidTagInfo *pTagInfo = taosArrayGet(pUidTagInfo, i); - taosHashPut(pSepecifiedUidMap, &pTagInfo->uid, sizeof(uint64_t), &i, sizeof(int32_t)); + (void)taosHashPut(pSepecifiedUidMap, &pTagInfo->uid, sizeof(uint64_t), &i, sizeof(int32_t)); } } @@ -1513,7 +1513,7 @@ int32_t metaGetInfo(SMeta *pMeta, int64_t uid, SMetaInfo *pInfo, SMetaReader *pR } // upsert the cache metaWLock(pMeta); - metaCacheUpsert(pMeta, pInfo); + (void)metaCacheUpsert(pMeta, pInfo); metaULock(pMeta); if (lock) { @@ -1565,7 +1565,7 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t // upsert the cache metaWLock(pVnodeObj->pMeta); - metaStatsCacheUpsert(pVnodeObj->pMeta, &state); + (void)metaStatsCacheUpsert(pVnodeObj->pMeta, &state); metaULock(pVnodeObj->pMeta); _exit: @@ -1578,6 +1578,6 @@ void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t deltaCtb, int32_t del if (metaStatsCacheGet(pMeta, uid, &stats) == TSDB_CODE_SUCCESS) { stats.ctbNum += deltaCtb; stats.colNum += deltaCol; - metaStatsCacheUpsert(pMeta, &stats); + (void)metaStatsCacheUpsert(pMeta, &stats); } } diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index b8043c00de..3f99bcb5b2 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -59,7 +59,7 @@ _exit: void metaSnapReaderClose(SMetaSnapReader** ppReader) { if (ppReader && *ppReader) { - tdbTbcClose((*ppReader)->pTbc); + (void)tdbTbcClose((*ppReader)->pTbc); taosMemoryFree(*ppReader); *ppReader = NULL; } @@ -87,7 +87,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) { if (key.version < pReader->sver // || metaGetInfo(pReader->pMeta, key.uid, &info, NULL) == TSDB_CODE_NOT_FOUND) { - tdbTbcMoveToNext(pReader->pTbc); + (void)tdbTbcMoveToNext(pReader->pTbc); continue; } @@ -110,7 +110,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) { metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d", TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData); - tdbTbcMoveToNext(pReader->pTbc); + (void)tdbTbcMoveToNext(pReader->pTbc); break; } @@ -223,17 +223,17 @@ static int32_t MoveToSnapShotVersion(SSnapContext* ctx) { int32_t code = 0; (void)tdbTbcClose((TBC*)ctx->pCur); code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL); - if (code != 0){ + if (code != 0) { return TAOS_GET_TERRNO(code); } STbDbKey key = {.version = ctx->snapVersion, .uid = INT64_MAX}; int c = 0; code = tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c); - if (code != 0){ + if (code != 0) { return TAOS_GET_TERRNO(code); } if (c < 0) { - tdbTbcMoveToPrev((TBC*)ctx->pCur); + (void)tdbTbcMoveToPrev((TBC*)ctx->pCur); } return 0; } @@ -241,13 +241,13 @@ static int32_t MoveToSnapShotVersion(SSnapContext* ctx) { static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) { (void)tdbTbcClose((TBC*)ctx->pCur); int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL); - if (code != 0){ + if (code != 0) { return TAOS_GET_TERRNO(code); } STbDbKey key = {.version = ver, .uid = uid}; int c = 0; code = tdbTbcMoveTo((TBC*)ctx->pCur, &key, sizeof(key), &c); - if (code != 0){ + if (code != 0) { return TAOS_GET_TERRNO(code); } return c; @@ -256,11 +256,11 @@ static int32_t MoveToPosition(SSnapContext* ctx, int64_t ver, int64_t uid) { static int32_t MoveToFirst(SSnapContext* ctx) { (void)tdbTbcClose((TBC*)ctx->pCur); int32_t code = tdbTbcOpen(ctx->pMeta->pTbDb, (TBC**)&ctx->pCur, NULL); - if (code != 0){ + if (code != 0) { return TAOS_GET_TERRNO(code); } code = tdbTbcMoveToFirst((TBC*)ctx->pCur); - if (code != 0){ + if (code != 0) { return TAOS_GET_TERRNO(code); } return 0; @@ -271,38 +271,39 @@ static int32_t saveSuperTableInfoForChildTable(SMetaEntry* me, SHashObj* suidInf if (data) { return 0; } - int32_t code = 0; + int32_t code = 0; STableInfoForChildTable dataTmp = {0}; dataTmp.tableName = taosStrdup(me->name); - if (dataTmp.tableName == NULL){ + if (dataTmp.tableName == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto END; } dataTmp.schemaRow = tCloneSSchemaWrapper(&me->stbEntry.schemaRow); - if (dataTmp.schemaRow == NULL){ + if (dataTmp.schemaRow == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto END; } dataTmp.tagRow = tCloneSSchemaWrapper(&me->stbEntry.schemaTag); - if (dataTmp.tagRow == NULL){ + if (dataTmp.tagRow == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto END; } code = taosHashPut(suidInfo, &me->uid, sizeof(tb_uid_t), &dataTmp, sizeof(STableInfoForChildTable)); - if (code != 0){ + if (code != 0) { goto END; } return 0; END: destroySTableInfoForChildTable(&dataTmp); - return TAOS_GET_TERRNO(code);; + return TAOS_GET_TERRNO(code); + ; } int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8_t subType, int8_t withMeta, SSnapContext** ctxRet) { SSnapContext* ctx = taosMemoryCalloc(1, sizeof(SSnapContext)); - if (ctx == NULL){ + if (ctx == NULL) { return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } *ctxRet = ctx; @@ -319,14 +320,16 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 ctx->suidInfo = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); if (ctx->suidInfo == NULL) { - return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);; + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + ; } taosHashSetFreeFp(ctx->suidInfo, destroySTableInfoForChildTable); ctx->index = 0; ctx->idList = taosArrayInit(100, sizeof(int64_t)); - if (ctx->idList == NULL){ - return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);; + if (ctx->idList == NULL) { + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + ; } void* pKey = NULL; void* pVal = NULL; @@ -334,7 +337,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 metaDebug("tmqsnap init snapVersion:%" PRIi64, ctx->snapVersion); int32_t code = MoveToFirst(ctx); - if (code != 0){ + if (code != 0) { return code; } while (1) { @@ -348,7 +351,8 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 continue; } - if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) < 0) { // check if table exist for now, need optimize later + if (tdbTbGet(ctx->pMeta->pUidIdx, &tmp->uid, sizeof(tb_uid_t), NULL, NULL) < + 0) { // check if table exist for now, need optimize later continue; } @@ -356,7 +360,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 SMetaEntry me = {0}; tDecoderInit(&dc, pVal, vLen); ret = metaDecodeEntry(&dc, &me); - if (ret < 0){ + if (ret < 0) { tDecoderClear(&dc); return TAOS_GET_TERRNO(ret); } @@ -368,7 +372,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 } } - if (taosArrayPush(ctx->idList, &tmp->uid) == NULL){ + if (taosArrayPush(ctx->idList, &tmp->uid) == NULL) { tDecoderClear(&dc); return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } @@ -383,7 +387,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 taosHashClear(ctx->idVersion); code = MoveToSnapShotVersion(ctx); - if (code != 0){ + if (code != 0) { return code; } while (1) { @@ -405,7 +409,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 SMetaEntry me = {0}; tDecoderInit(&dc, pVal, vLen); ret = metaDecodeEntry(&dc, &me); - if (ret < 0){ + if (ret < 0) { tDecoderClear(&dc); return TAOS_GET_TERRNO(ret); } @@ -421,7 +425,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_SUPER_TABLE) || (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.uid == ctx->suid)) { ret = saveSuperTableInfoForChildTable(&me, ctx->suidInfo); - if (ret != 0){ + if (ret != 0) { tDecoderClear(&dc); return ret; } @@ -431,7 +435,7 @@ int32_t buildSnapContext(SVnode* pVnode, int64_t snapVersion, int64_t suid, int8 for (int i = 0; i < taosArrayGetSize(ctx->idList); i++) { int64_t* uid = taosArrayGet(ctx->idList, i); - if (uid == NULL){ + if (uid == NULL) { return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } SIdInfo* idData = (SIdInfo*)taosHashGet(ctx->idVersion, uid, sizeof(int64_t)); @@ -467,7 +471,7 @@ static int32_t buildNormalChildTableInfo(SVCreateTbReq* req, void** pBuf, int32_ ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); goto end; } - if (taosArrayPush(reqs.pArray, req) == NULL){ + if (taosArrayPush(reqs.pArray, req) == NULL) { ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); goto end; } @@ -540,10 +544,10 @@ int32_t setForSnapShot(SSnapContext* ctx, int64_t uid) { return 0; } -void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid){ - bool ret = false; - SSchemaWrapper *schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1); - if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY){ +void taosXSetTablePrimaryKey(SSnapContext* ctx, int64_t uid) { + bool ret = false; + SSchemaWrapper* schema = metaGetTableSchema(ctx->pMeta, uid, -1, 1); + if (schema && schema->nCols >= 2 && schema->pSchema[1].flags & COL_IS_KEY) { ret = true; } tDeleteSchemaWrapper(schema); @@ -639,7 +643,7 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe ret = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); goto END; } - STag* p = (STag*)me.ctbEntry.pTags; + STag* p = (STag*)me.ctbEntry.pTags; if (tTagIsJson(p)) { if (p->nTag != 0) { SSchema* schema = &data->tagRow->pSchema[0]; @@ -651,7 +655,7 @@ int32_t getTableInfoFromSnapshot(SSnapContext* ctx, void** pBuf, int32_t* contLe } } else { SArray* pTagVals = NULL; - ret = tTagToValArray((const STag*)p, &pTagVals); + ret = tTagToValArray((const STag*)p, &pTagVals); if (ret != 0) { metaError("meta/snap: tag to val array failed."); taosArrayDestroy(pTagVals); @@ -701,9 +705,9 @@ END: } int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) { - void* pKey = NULL; - void* pVal = NULL; - int vLen, kLen; + void* pKey = NULL; + void* pVal = NULL; + int vLen, kLen; while (1) { if (ctx->index >= taosArrayGetSize(ctx->idList)) { @@ -711,7 +715,7 @@ int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) return 0; } int64_t* uidTmp = taosArrayGet(ctx->idList, ctx->index); - if (uidTmp == NULL){ + if (uidTmp == NULL) { return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } ctx->index++; @@ -728,21 +732,21 @@ int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) continue; } ret = tdbTbcGet((TBC*)ctx->pCur, (const void**)&pKey, &kLen, (const void**)&pVal, &vLen); - if (ret != 0){ + if (ret != 0) { return TAOS_GET_TERRNO(ret); } SDecoder dc = {0}; SMetaEntry me = {0}; tDecoderInit(&dc, pVal, vLen); ret = metaDecodeEntry(&dc, &me); - if (ret != 0){ + if (ret != 0) { tDecoderClear(&dc); return TAOS_GET_TERRNO(ret); } metaDebug("tmqsnap get uid info uid:%" PRIi64 " name:%s index:%d", me.uid, me.name, ctx->index - 1); if ((ctx->subType == TOPIC_SUB_TYPE__DB && me.type == TSDB_CHILD_TABLE) || - (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)){ + (ctx->subType == TOPIC_SUB_TYPE__TABLE && me.type == TSDB_CHILD_TABLE && me.ctbEntry.suid == ctx->suid)) { STableInfoForChildTable* data = (STableInfoForChildTable*)taosHashGet(ctx->suidInfo, &me.ctbEntry.suid, sizeof(tb_uid_t)); if (data == NULL) { @@ -763,7 +767,7 @@ int32_t getMetaTableInfoFromSnapshot(SSnapContext* ctx, SMetaTableInfo* result) result->uid = me.uid; tstrncpy(result->tbName, me.name, TSDB_TABLE_NAME_LEN); tDecoderClear(&dc); - if(result->schema == NULL){ + if (result->schema == NULL) { return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } break; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 04447fd3ce..2badeec2c9 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -161,10 +161,10 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_BOOL, key, nKey, (const char *)&val, len); } if (term != NULL) { - indexMultiTermAdd(terms, term); + (void)indexMultiTermAdd(terms, term); } } - indexJsonPut(pMeta->pTagIvtIdx, terms, tuid); + (void)indexJsonPut(pMeta->pTagIvtIdx, terms, tuid); indexMultiTermDestroy(terms); taosArrayDestroy(pTagVals); @@ -223,10 +223,10 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche term = indexTermCreate(suid, DEL_VALUE, TSDB_DATA_TYPE_BOOL, key, nKey, (const char *)&val, len); } if (term != NULL) { - indexMultiTermAdd(terms, term); + (void)indexMultiTermAdd(terms, term); } } - indexJsonPut(pMeta->pTagIvtIdx, terms, tuid); + (void)indexJsonPut(pMeta->pTagIvtIdx, terms, tuid); indexMultiTermDestroy(terms); taosArrayDestroy(pTagVals); #endif @@ -239,7 +239,7 @@ static inline void metaTimeSeriesNotifyCheck(SMeta *pMeta) { int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries; if (deltaTS > tsTimeSeriesThreshold) { if (0 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) { - tsem_post(&dmNotifyHdl.sem); + (void)tsem_post(&dmNotifyHdl.sem); } } #endif @@ -323,10 +323,10 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb // drop all child tables TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); + (void)(void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); if (rc < 0) { - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); metaWLock(pMeta); goto _drop_super_table; } @@ -344,7 +344,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb (void)taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)); } - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); (void)tsdbCacheDropSubTables(pMeta->pVnode->pTsdb, tbUidList, pReq->suid); @@ -352,19 +352,19 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb for (int32_t iChild = 0; iChild < taosArrayGetSize(tbUidList); iChild++) { tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUidList, iChild); - metaDropTableByUid(pMeta, uid, NULL, NULL, NULL); + (void)metaDropTableByUid(pMeta, uid, NULL, NULL, NULL); } // drop super table _drop_super_table: tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData); - tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid}, - sizeof(STbDbKey), pMeta->txn); - tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn); - tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); - tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); + (void)tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid}, + sizeof(STbDbKey), pMeta->txn); + (void)tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn); + (void)tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); + (void)tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); - metaStatsCacheDrop(pMeta, pReq->suid); + (void)metaStatsCacheDrop(pMeta, pReq->suid); metaULock(pMeta); @@ -387,10 +387,10 @@ static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) { int nKey = 0; TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); + (void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); if (rc < 0) { - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); metaWLock(pMeta); return; } @@ -410,7 +410,7 @@ static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) { tdbFree(pKey); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); } int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { @@ -425,28 +425,28 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { int32_t ret; int32_t c = -2; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); + (void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c); if (ret < 0 || c) { - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pUidIdxc); return terrno = TSDB_CODE_TDB_STB_NOT_EXIST; } ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); if (ret < 0) { - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pUidIdxc); return terrno = TSDB_CODE_TDB_STB_NOT_EXIST; } oversion = ((SUidIdxVal *)pData)[0].version; - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); + (void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c); if (!(ret == 0 && c == 0)) { - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c); return terrno = TSDB_CODE_TDB_STB_NOT_EXIST; @@ -454,8 +454,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); if (ret < 0) { - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); return terrno = TSDB_CODE_TDB_STB_NOT_EXIST; } @@ -463,7 +463,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { oStbEntry.pBuf = taosMemoryMalloc(nData); memcpy(oStbEntry.pBuf, pData, nData); tDecoderInit(&dc, oStbEntry.pBuf, nData); - metaDecodeEntry(&dc, &oStbEntry); + (void)metaDecodeEntry(&dc, &oStbEntry); nStbEntry.version = version; nStbEntry.type = TSDB_SUPER_TABLE; @@ -487,7 +487,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { int8_t col_type = pReq->schemaRow.pSchema[nCols - 1].type; metaGetSubtables(pMeta, pReq->suid, uids); - tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type); + (void)tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type); } else if (deltaCol == -1) { int16_t cid = -1; bool hasPrimaryKey = false; @@ -503,7 +503,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { if (cid != -1) { metaGetSubtables(pMeta, pReq->suid, uids); - tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey); + (void)tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey); } } if (uids) taosArrayDestroy(uids); @@ -512,25 +512,25 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { metaWLock(pMeta); // compare two entry if (oStbEntry.stbEntry.schemaRow.version != pReq->schemaRow.version) { - metaSaveToSkmDb(pMeta, &nStbEntry); + (void)metaSaveToSkmDb(pMeta, &nStbEntry); } // update table.db - metaSaveToTbDb(pMeta, &nStbEntry); + (void)metaSaveToTbDb(pMeta, &nStbEntry); // update uid index - metaUpdateUidIdx(pMeta, &nStbEntry); + (void)metaUpdateUidIdx(pMeta, &nStbEntry); // metaStatsCacheDrop(pMeta, nStbEntry.uid); if (updStat) { - metaUpdateStbStats(pMeta, pReq->suid, 0, deltaCol); + (void)metaUpdateStbStats(pMeta, pReq->suid, 0, deltaCol); } metaULock(pMeta); if (updStat) { int64_t ctbNum; - metaGetStbStats(pMeta->pVnode, pReq->suid, &ctbNum, NULL); + (void)metaGetStbStats(pMeta->pVnode, pReq->suid, &ctbNum, NULL); pMeta->pVnode->config.vndStats.numOfTimeSeries += (ctbNum * deltaCol); metaTimeSeriesNotifyCheck(pMeta); } @@ -540,8 +540,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { _exit: if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); tDecoderClear(&dc); - tdbTbcClose(pTbDbc); - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); return 0; } int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { @@ -568,7 +568,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { tbDbKey.uid = suid; tbDbKey.version = ((SUidIdxVal *)pData)[0].version; - tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); + (void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); ret = metaDecodeEntry(&dc, &oStbEntry); @@ -619,10 +619,10 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { * iterator all pTdDbc by uid and version */ TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); + (void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); if (rc < 0) { - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); goto _err; } for (;;) { @@ -632,7 +632,7 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { if (rc < 0) { tdbFree(pKey); tdbFree(pVal); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); pCtbIdxc = NULL; break; } @@ -667,12 +667,12 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { tdbFree(pVal); if (rc < 0) { metaDestroyTagIdxKey(pTagIdxKey); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); goto _err; } metaWLock(pMeta); - tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); + (void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); metaULock(pMeta); metaDestroyTagIdxKey(pTagIdxKey); pTagIdxKey = NULL; @@ -688,16 +688,16 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { metaWLock(pMeta); // update table.db - metaSaveToTbDb(pMeta, &nStbEntry); + (void)metaSaveToTbDb(pMeta, &nStbEntry); // update uid index - metaUpdateUidIdx(pMeta, &nStbEntry); + (void)metaUpdateUidIdx(pMeta, &nStbEntry); metaULock(pMeta); if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); tDecoderClear(&dc); tdbFree(pData); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); return TSDB_CODE_SUCCESS; _err: if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); @@ -729,7 +729,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) tbDbKey.uid = suid; tbDbKey.version = ((SUidIdxVal *)pData)[0].version; - tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); + (void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); ret = metaDecodeEntry(&dc, &oStbEntry); if (ret < 0) { @@ -756,10 +756,10 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) * iterator all pTdDbc by uid and version */ TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); + (void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); if (rc < 0) { - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); goto _err; } for (;;) { @@ -769,7 +769,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) if (rc < 0) { tdbFree(pKey); tdbFree(pVal); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); pCtbIdxc = NULL; break; } @@ -804,12 +804,12 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) tdbFree(pVal); if (rc < 0) { metaDestroyTagIdxKey(pTagIdxKey); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); goto _err; } metaWLock(pMeta); - tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); + (void)tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); metaULock(pMeta); metaDestroyTagIdxKey(pTagIdxKey); pTagIdxKey = NULL; @@ -836,9 +836,9 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) metaWLock(pMeta); // update table.db - metaSaveToTbDb(pMeta, &nStbEntry); + (void)metaSaveToTbDb(pMeta, &nStbEntry); // update uid index - metaUpdateUidIdx(pMeta, &nStbEntry); + (void)metaUpdateUidIdx(pMeta, &nStbEntry); metaULock(pMeta); tDeleteSchemaWrapper(tag); @@ -849,7 +849,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq) tDecoderClear(&dc); tdbFree(pData); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); return TSDB_CODE_SUCCESS; _err: if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); @@ -937,18 +937,18 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs if (!sysTbl) { int32_t nCols = 0; - metaGetStbStats(pMeta->pVnode, me.ctbEntry.suid, 0, &nCols); + (void)metaGetStbStats(pMeta->pVnode, me.ctbEntry.suid, 0, &nCols); pStats->numOfTimeSeries += nCols - 1; } metaWLock(pMeta); - metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1, 0); - metaUidCacheClear(pMeta, me.ctbEntry.suid); - metaTbGroupCacheClear(pMeta, me.ctbEntry.suid); + (void)metaUpdateStbStats(pMeta, me.ctbEntry.suid, 1, 0); + (void)metaUidCacheClear(pMeta, me.ctbEntry.suid); + (void)metaTbGroupCacheClear(pMeta, me.ctbEntry.suid); metaULock(pMeta); if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { - tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, me.ctbEntry.suid, NULL); + (void)tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, me.ctbEntry.suid, NULL); } } else { me.ntbEntry.btime = pReq->btime; @@ -964,7 +964,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs pStats->numOfNTimeSeries += me.ntbEntry.schemaRow.nCols - 1; if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { - tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, -1, &me.ntbEntry.schemaRow); + (void)tsdbCacheNewTable(pMeta->pVnode->pTsdb, me.uid, -1, &me.ntbEntry.schemaRow); } } @@ -982,7 +982,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs (*pMetaRsp)->suid = pReq->ctb.suid; strcpy((*pMetaRsp)->tbName, pReq->name); } else { - metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp); + (void)metaUpdateMetaRsp(pReq->uid, pReq->name, &pReq->ntb.schemaRow, *pMetaRsp); for (int32_t i = 0; i < pReq->colCmpr.nCols; i++) { SColCmpr *p = &pReq->colCmpr.pColCmpr[i]; (*pMetaRsp)->pSchemaExt[i].colId = p->id; @@ -1036,7 +1036,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi (void)taosArrayPush(tbUids, &uid); if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { - tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL); + (void)tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL); } } @@ -1062,7 +1062,7 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) { tb_uid_t suid = 0; int8_t sysTbl = 0; int type; - metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl); + (void)metaDropTableByUid(pMeta, uid, &type, &suid, &sysTbl); if (!sysTbl && type == TSDB_CHILD_TABLE && suid != 0 && suidHash) { int64_t *pVal = tSimpleHashGet(suidHash, &suid, sizeof(tb_uid_t)); if (pVal) { @@ -1070,7 +1070,7 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) { } else { nCtbDropped = 1; } - tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t)); + (void)tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t)); } /* if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { @@ -1111,7 +1111,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) { code = tdbTbcMoveToFirst(pCur); if (code) { - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return code; } @@ -1127,7 +1127,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) { SMetaEntry me = {0}; SDecoder dc = {0}; tDecoderInit(&dc, pData, nData); - metaDecodeEntry(&dc, &me); + (void)metaDecodeEntry(&dc, &me); if (me.type != TSDB_SUPER_TABLE) { char tbFName[TSDB_TABLE_FNAME_LEN + 1]; @@ -1142,7 +1142,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) { } tdbFree(pData); tdbFree(pKey); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -1237,7 +1237,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p } int64_t version = ((SUidIdxVal *)pData)[0].version; - tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData); + (void)tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); rc = metaDecodeEntry(&dc, &e); @@ -1260,7 +1260,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p SMetaEntry stbEntry = {0}; tDecoderInit(&tdc, tData, tLen); - metaDecodeEntry(&tdc, &stbEntry); + (void)metaDecodeEntry(&tdc, &stbEntry); if (pSysTbl) *pSysTbl = metaTbInFilterCache(pMeta, stbEntry.name, 1) ? 1 : 0; @@ -1268,7 +1268,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag; if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) { pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0]; - metaDelJsonVarFromIdx(pMeta, &e, pTagColumn); + (void)metaDelJsonVarFromIdx(pMeta, &e, pTagColumn); } else { for (int i = 0; i < pTagSchema->nCols; i++) { pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[i]; @@ -1296,7 +1296,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid, &pTagIdxKey, &nTagIdxKey) == 0) { - tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); + (void)tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); } metaDestroyTagIdxKey(pTagIdxKey); pTagIdxKey = NULL; @@ -1308,9 +1308,9 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p } } - tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn); - tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn); - tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn); + (void)tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn); + (void)tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn); + (void)tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn); if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteBtimeIdx(pMeta, &e); if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e); @@ -1318,12 +1318,13 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p if (e.type != TSDB_SUPER_TABLE) metaDeleteTtl(pMeta, &e); if (e.type == TSDB_CHILD_TABLE) { - tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn); + (void)tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), + pMeta->txn); --pMeta->pVnode->config.vndStats.numOfCTables; - metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0); - metaUidCacheClear(pMeta, e.ctbEntry.suid); - metaTbGroupCacheClear(pMeta, e.ctbEntry.suid); + (void)metaUpdateStbStats(pMeta, e.ctbEntry.suid, -1, 0); + (void)metaUidCacheClear(pMeta, e.ctbEntry.suid); + (void)metaTbGroupCacheClear(pMeta, e.ctbEntry.suid); /* if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { tsdbCacheDropTable(pMeta->pVnode->pTsdb, e.uid, e.ctbEntry.suid, NULL); @@ -1341,16 +1342,16 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *p } */ } else if (e.type == TSDB_SUPER_TABLE) { - tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn); + (void)tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn); // drop schema.db (todo) - metaStatsCacheDrop(pMeta, uid); - metaUidCacheClear(pMeta, uid); - metaTbGroupCacheClear(pMeta, uid); + (void)metaStatsCacheDrop(pMeta, uid); + (void)metaUidCacheClear(pMeta, uid); + (void)metaTbGroupCacheClear(pMeta, uid); --pMeta->pVnode->config.vndStats.numOfSTables; } - metaCacheDrop(pMeta, uid); + (void)metaCacheDrop(pMeta, uid); tDecoderClear(&dc); tdbFree(pData); @@ -1423,30 +1424,30 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl // search uid index TBC *pUidIdxc = NULL; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); - tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); + (void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); + (void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); if (c != 0) { - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pUidIdxc); metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c); return TSDB_CODE_FAILED; } - tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); + (void)tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); oversion = ((SUidIdxVal *)pData)[0].version; // search table.db TBC *pTbDbc = NULL; - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); - tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); + (void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); + (void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); if (c != 0) { - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c); return TSDB_CODE_FAILED; } - tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); + (void)tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); // get table entry SDecoder dc = {0}; @@ -1455,8 +1456,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl tDecoderInit(&dc, entry.pBuf, nData); ret = metaDecodeEntry(&dc, &entry); if (ret != 0) { - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); tDecoderClear(&dc); metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret); return ret; @@ -1536,7 +1537,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl SSchema *pCol = &pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1]; uint32_t compress = pAlterTbReq->action == TSDB_ALTER_TABLE_ADD_COLUMN ? createDefaultColCmprByType(pCol->type) : pAlterTbReq->compress; - updataTableColCmpr(&entry.colCmpr, pCol, 1, compress); + (void)updataTableColCmpr(&entry.colCmpr, pCol, 1, compress); freeColCmpr = true; ASSERT(entry.colCmpr.nCols == pSchema->nCols); break; @@ -1574,7 +1575,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl (void)tsdbCacheDropNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, hasPrimayKey); } - updataTableColCmpr(&entry.colCmpr, &tScheam, 0, 0); + (void)updataTableColCmpr(&entry.colCmpr, &tScheam, 0, 0); ASSERT(entry.colCmpr.nCols == pSchema->nCols); break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: @@ -1620,20 +1621,20 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl // do actual write metaWLock(pMeta); - metaDeleteNcolIdx(pMeta, &oldEntry); - metaUpdateNcolIdx(pMeta, &entry); + (void)metaDeleteNcolIdx(pMeta, &oldEntry); + (void)metaUpdateNcolIdx(pMeta, &entry); // save to table db - metaSaveToTbDb(pMeta, &entry); + (void)metaSaveToTbDb(pMeta, &entry); - metaUpdateUidIdx(pMeta, &entry); + (void)metaUpdateUidIdx(pMeta, &entry); - metaSaveToSkmDb(pMeta, &entry); + (void)metaSaveToSkmDb(pMeta, &entry); - metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs); + (void)metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs); metaULock(pMeta); - metaUpdateMetaRsp(uid, pAlterTbReq->tbName, pSchema, pMetaRsp); + (void)metaUpdateMetaRsp(uid, pAlterTbReq->tbName, pSchema, pMetaRsp); for (int32_t i = 0; i < entry.colCmpr.nCols; i++) { SColCmpr *p = &entry.colCmpr.pColCmpr[i]; pMetaRsp->pSchemaExt[i].colId = p->id; @@ -1644,16 +1645,16 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl if (pNewSchema) taosMemoryFree(pNewSchema); if (freeColCmpr) taosMemoryFree(entry.colCmpr.pColCmpr); - tdbTbcClose(pTbDbc); - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); tDecoderClear(&dc); return 0; _err: if (entry.pBuf) taosMemoryFree(entry.pBuf); - tdbTbcClose(pTbDbc); - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); tDecoderClear(&dc); return TSDB_CODE_FAILED; @@ -1688,15 +1689,15 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA // search uid index TBC *pUidIdxc = NULL; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); - tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); + (void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); + (void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); if (c != 0) { - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pUidIdxc); metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c); return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST; } - tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); + (void)tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); oversion = ((SUidIdxVal *)pData)[0].version; // search table.db @@ -1705,34 +1706,34 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA SDecoder dc2 = {0}; /* get ctbEntry */ - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); - tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); + (void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); + (void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); if (c != 0) { - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c); return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST; } - tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); + (void)tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); ctbEntry.pBuf = taosMemoryMalloc(nData); memcpy(ctbEntry.pBuf, pData, nData); tDecoderInit(&dc1, ctbEntry.pBuf, nData); - metaDecodeEntry(&dc1, &ctbEntry); + (void)metaDecodeEntry(&dc1, &ctbEntry); /* get stbEntry*/ - tdbTbGet(pMeta->pUidIdx, &ctbEntry.ctbEntry.suid, sizeof(tb_uid_t), &pVal, &nVal); + (void)tdbTbGet(pMeta->pUidIdx, &ctbEntry.ctbEntry.suid, sizeof(tb_uid_t), &pVal, &nVal); if (!pVal) { terrno = TSDB_CODE_INVALID_MSG; goto _err; } - tdbTbGet(pMeta->pTbDb, &((STbDbKey){.uid = ctbEntry.ctbEntry.suid, .version = ((SUidIdxVal *)pVal)[0].version}), - sizeof(STbDbKey), (void **)&stbEntry.pBuf, &nVal); + (void)tdbTbGet(pMeta->pTbDb, &((STbDbKey){.uid = ctbEntry.ctbEntry.suid, .version = ((SUidIdxVal *)pVal)[0].version}), + sizeof(STbDbKey), (void **)&stbEntry.pBuf, &nVal); tdbFree(pVal); tDecoderInit(&dc2, stbEntry.pBuf, nVal); - metaDecodeEntry(&dc2, &stbEntry); + (void)metaDecodeEntry(&dc2, &stbEntry); SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag; SSchema *pColumn = NULL; @@ -1802,12 +1803,12 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA metaWLock(pMeta); // save to table.db - metaSaveToTbDb(pMeta, &ctbEntry); + (void)metaSaveToTbDb(pMeta, &ctbEntry); // save to uid.idx - metaUpdateUidIdx(pMeta, &ctbEntry); + (void)metaUpdateUidIdx(pMeta, &ctbEntry); - metaUpdateTagIdx(pMeta, &ctbEntry); + (void)metaUpdateTagIdx(pMeta, &ctbEntry); if (NULL == ctbEntry.ctbEntry.pTags) { metaError("meta/table: null tags, update tag val failed."); @@ -1815,13 +1816,13 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA } SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid}; - tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, - ((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn); + (void)tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, + ((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn); - metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid); - metaTbGroupCacheClear(pMeta, ctbEntry.ctbEntry.suid); + (void)metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid); + (void)metaTbGroupCacheClear(pMeta, ctbEntry.ctbEntry.suid); - metaUpdateChangeTime(pMeta, ctbEntry.uid, pAlterTbReq->ctimeMs); + (void)metaUpdateChangeTime(pMeta, ctbEntry.uid, pAlterTbReq->ctimeMs); metaULock(pMeta); @@ -1830,8 +1831,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA taosMemoryFree((void *)ctbEntry.ctbEntry.pTags); if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf); if (stbEntry.pBuf) tdbFree(stbEntry.pBuf); - tdbTbcClose(pTbDbc); - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); return 0; _err: @@ -1839,8 +1840,8 @@ _err: tDecoderClear(&dc2); if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf); if (stbEntry.pBuf) tdbFree(stbEntry.pBuf); - tdbTbcClose(pTbDbc); - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); return -1; } @@ -1868,30 +1869,30 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p // search uid index TBC *pUidIdxc = NULL; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); - tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); + (void)tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); + (void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); if (c != 0) { - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pUidIdxc); metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c); return TSDB_CODE_FAILED; } - tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); + (void)tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); oversion = ((SUidIdxVal *)pData)[0].version; // search table.db TBC *pTbDbc = NULL; - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); - tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); + (void)tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); + (void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); if (c != 0) { - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c); return TSDB_CODE_FAILED; } - tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); + (void)tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); // get table entry SDecoder dc = {0}; @@ -1901,8 +1902,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p ret = metaDecodeEntry(&dc, &entry); if (ret != 0) { tDecoderClear(&dc); - tdbTbcClose(pUidIdxc); - tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); metaError("meta/table: invalide ret: %" PRId32 " alt tb options failed.", ret); return TSDB_CODE_FAILED; } @@ -1912,9 +1913,9 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p // build SMetaEntry if (entry.type == TSDB_CHILD_TABLE) { if (pAlterTbReq->updateTTL) { - metaDeleteTtl(pMeta, &entry); + (void)metaDeleteTtl(pMeta, &entry); entry.ctbEntry.ttlDays = pAlterTbReq->newTTL; - metaUpdateTtl(pMeta, &entry); + (void)metaUpdateTtl(pMeta, &entry); } if (pAlterTbReq->newCommentLen >= 0) { entry.ctbEntry.commentLen = pAlterTbReq->newCommentLen; @@ -1922,9 +1923,9 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p } } else { if (pAlterTbReq->updateTTL) { - metaDeleteTtl(pMeta, &entry); + (void)metaDeleteTtl(pMeta, &entry); entry.ntbEntry.ttlDays = pAlterTbReq->newTTL; - metaUpdateTtl(pMeta, &entry); + (void)metaUpdateTtl(pMeta, &entry); } if (pAlterTbReq->newCommentLen >= 0) { entry.ntbEntry.commentLen = pAlterTbReq->newCommentLen; @@ -1933,14 +1934,14 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p } // save to table db - metaSaveToTbDb(pMeta, &entry); - metaUpdateUidIdx(pMeta, &entry); - metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs); + (void)metaSaveToTbDb(pMeta, &entry); + (void)metaUpdateUidIdx(pMeta, &entry); + (void)metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs); metaULock(pMeta); - tdbTbcClose(pTbDbc); - tdbTbcClose(pUidIdxc); + (void)tdbTbcClose(pTbDbc); + (void)tdbTbcClose(pUidIdxc); tDecoderClear(&dc); if (entry.pBuf) taosMemoryFree(entry.pBuf); return 0; @@ -1981,7 +1982,7 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb STbDbKey tbDbKey = {0}; tbDbKey.uid = suid; tbDbKey.version = ((SUidIdxVal *)pVal)[0].version; - tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal); + (void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal); tDecoderInit(&dc, pVal, nVal); ret = metaDecodeEntry(&dc, &stbEntry); if (ret < 0) { @@ -2017,10 +2018,10 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb * iterator all pTdDbc by uid and version */ TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); + (void)tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); int rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); if (rc < 0) { - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); goto _err; } for (;;) { @@ -2057,14 +2058,14 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb tdbFree(pKey); tdbFree(pVal); metaDestroyTagIdxKey(pTagIdxKey); - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); goto _err; } - tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); + (void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); metaDestroyTagIdxKey(pTagIdxKey); pTagIdxKey = NULL; } - tdbTbcClose(pCtbIdxc); + (void)tdbTbcClose(pCtbIdxc); return 0; _err: @@ -2115,7 +2116,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT STbDbKey tbDbKey = {0}; tbDbKey.uid = suid; tbDbKey.version = ((SUidIdxVal *)pVal)[0].version; - tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal); + (void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal); tDecoderInit(&dc, pVal, nVal); ret = metaDecodeEntry(&dc, &stbEntry); @@ -2156,7 +2157,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT SArray *tagIdxList = taosArrayInit(512, sizeof(SMetaPair)); TBC *pTagIdxc = NULL; - tdbTbcOpen(pMeta->pTagIdx, &pTagIdxc, NULL); + (void)tdbTbcOpen(pMeta->pTagIdx, &pTagIdxc, NULL); int rc = tdbTbcMoveTo(pTagIdxc, &(STagIdxKey){.suid = suid, .cid = INT32_MIN, .type = pCol->type}, sizeof(STagIdxKey), &c); for (;;) { @@ -2173,12 +2174,12 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT SMetaPair pair = {.key = pKey, nKey = nKey}; (void)taosArrayPush(tagIdxList, &pair); } - tdbTbcClose(pTagIdxc); + (void)tdbTbcClose(pTagIdxc); metaWLock(pMeta); for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) { SMetaPair *pair = taosArrayGet(tagIdxList, i); - tdbTbDelete(pMeta->pTagIdx, pair->key, pair->nkey, pMeta->txn); + (void)tdbTbDelete(pMeta->pTagIdx, pair->key, pair->nkey, pMeta->txn); } metaULock(pMeta); @@ -2265,9 +2266,9 @@ int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq * tbEntry.version = version; metaWLock(pMeta); - metaSaveToTbDb(pMeta, &tbEntry); - metaUpdateUidIdx(pMeta, &tbEntry); - metaUpdateChangeTime(pMeta, suid, pReq->ctimeMs); + (void)metaSaveToTbDb(pMeta, &tbEntry); + (void)metaUpdateUidIdx(pMeta, &tbEntry); + (void)metaUpdateChangeTime(pMeta, suid, pReq->ctimeMs); metaULock(pMeta); @@ -2362,7 +2363,7 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) { // upsert cache SMetaInfo info; metaGetEntryInfo(pME, &info); - metaCacheUpsert(pMeta, &info); + (void)metaCacheUpsert(pMeta, &info); SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer}; @@ -2478,7 +2479,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { } tbDbKey.uid = pCtbEntry->ctbEntry.suid; tbDbKey.version = ((SUidIdxVal *)pData)[0].version; - tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); + (void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); ret = metaDecodeEntry(&dc, &stbEntry); @@ -2525,7 +2526,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { ret = -1; goto end; } - tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); + (void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); metaDestroyTagIdxKey(pTagIdxKey); pTagIdxKey = NULL; } @@ -2574,7 +2575,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) { } tEncoderInit(&coder, pVal, vLen); - tEncodeSSchemaWrapper(&coder, pSW); + (void)tEncodeSSchemaWrapper(&coder, pSW); if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, pMeta->txn) < 0) { rcode = -1; @@ -2662,7 +2663,7 @@ int32_t colCompressDebug(SHashObj *pColCmprObj) { p = taosHashIterate(pColCmprObj, p); uint8_t l1, l2, lvl; - tcompressDebug(cmprAlg, &l1, &l2, &lvl); + (void)tcompressDebug(cmprAlg, &l1, &l2, &lvl); const char *l1str = columnEncodeStr(l1); const char *l2str = columnCompressStr(l2); @@ -2711,7 +2712,7 @@ int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) { SColCmprWrapper *p = &e.colCmpr; for (int32_t i = 0; i < p->nCols; i++) { SColCmpr *pCmpr = &p->pColCmpr[i]; - taosHashPut(pColCmprObj, &pCmpr->id, sizeof(pCmpr->id), &pCmpr->alg, sizeof(pCmpr->alg)); + (void)taosHashPut(pColCmprObj, &pCmpr->id, sizeof(pCmpr->id), &pCmpr->alg, sizeof(pCmpr->alg)); } } else { tDecoderClear(&dc); @@ -2725,7 +2726,7 @@ int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) { metaULock(pMeta); *ppColCmprObj = pColCmprObj; - colCompressDebug(pColCmprObj); + (void)colCompressDebug(pColCmprObj); return 0; } diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index e707f2150d..75b112f42b 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -257,7 +257,7 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) { if (RSMA_INFO_IS_DEL(pRSmaInfo)) { int32_t refVal = T_REF_VAL_GET(pRSmaInfo); if (refVal == 0) { - taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(*pSuid)); + (void)taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(*pSuid)); } else { smaDebug( "vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for " diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index e7a8de17a0..a219da33db 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -46,7 +46,7 @@ int32_t smaInit() { old = atomic_val_compare_exchange_8(&smaMgmt.inited, 0, 2); if (old != 2) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -69,7 +69,7 @@ int32_t smaInit() { if (!smaMgmt.refHash || !smaMgmt.tmrHandle) { code = terrno; - taosCloseRef(smaMgmt.rsetId); + (void)taosCloseRef(smaMgmt.rsetId); if (smaMgmt.refHash) { taosHashCleanup(smaMgmt.refHash); smaMgmt.refHash = NULL; @@ -97,7 +97,7 @@ void smaCleanUp() { old = atomic_val_compare_exchange_8(&smaMgmt.inited, 1, 2); if (old != 2) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -130,7 +130,7 @@ static int32_t tdNewSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv) { : atomic_store_ptr(&SMA_RSMA_ENV(pSma), *ppEnv); if ((code = tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma)) != TSDB_CODE_SUCCESS) { - tdFreeSmaEnv(pEnv); + (void)tdFreeSmaEnv(pEnv); *ppEnv = NULL; (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), NULL) : atomic_store_ptr(&SMA_RSMA_ENV(pSma), NULL); @@ -179,7 +179,7 @@ static void tRSmaInfoHashFreeNode(void *data) { if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 1)) && pItem->level) { (void)taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES); } - tdFreeRSmaInfo(pRSmaInfo->pSma, pRSmaInfo); + (void)tdFreeRSmaInfo(pRSmaInfo->pSma, pRSmaInfo); } } @@ -207,7 +207,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS SRSmaStat *pRSmaStat = (SRSmaStat *)(*pSmaStat); pRSmaStat->pSma = (SSma *)pSma; atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_INIT); - tsem_init(&pRSmaStat->notEmpty, 0, 0); + (void)tsem_init(&pRSmaStat->notEmpty, 0, 0); if (!(pRSmaStat->blocks = taosArrayInit(1, sizeof(SSDataBlock)))) { code = TSDB_CODE_OUT_OF_MEMORY; TAOS_CHECK_GOTO(code, &lino, _exit); @@ -216,7 +216,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS (void)taosArrayPush(pRSmaStat->blocks, &datablock); // init smaMgmt - smaInit(); + TAOS_CHECK_GOTO(smaInit(), &lino, _exit); int64_t refId = taosAddRef(smaMgmt.rsetId, pRSmaStat); if (refId < 0) { @@ -285,20 +285,20 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { } // step 3: - tdRsmaStopExecutor(pSma); + (void)tdRsmaStopExecutor(pSma); // step 4: destroy the rsma info and associated fetch tasks taosHashCleanup(RSMA_INFO_HASH(pStat)); // step 5: free pStat - tsem_destroy(&(pStat->notEmpty)); + (void)tsem_destroy(&(pStat->notEmpty)); taosArrayDestroy(pStat->blocks); taosMemoryFreeClear(pStat); } } static void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { - tdDestroySmaState(pSmaStat, smaType); + (void)tdDestroySmaState(pSmaStat, smaType); if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { taosMemoryFreeClear(pSmaStat); } @@ -438,7 +438,7 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) { pthread = (TdThread *)&pStat->data; for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) { - tsem_post(&(pRSmaStat->notEmpty)); + (void)tsem_post(&(pRSmaStat->notEmpty)); } for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) { diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index d5409cf268..ebff03ff99 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -412,7 +412,7 @@ int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con _exit: if (code != 0) { - tdFreeRSmaInfo(pSma, pRSmaInfo); + (void)tdFreeRSmaInfo(pSma, pRSmaInfo); } else { smaDebug("vgId:%d, register rsma info succeed for table %" PRIi64, SMA_VID(pSma), suid); } @@ -1264,7 +1264,7 @@ _checkpoint: if (pItem && pItem->pStreamTask) { SStreamTask *pTask = pItem->pStreamTask; // atomic_store_32(&pTask->pMeta->chkptNotReadyTasks, 1); - streamTaskSetActiveCheckpointInfo(pTask, checkpointId); + (void)streamTaskSetActiveCheckpointInfo(pTask, checkpointId); pTask->chkInfo.checkpointId = checkpointId; // 1pTask->checkpointingId; pTask->chkInfo.checkpointVer = pItem->submitReqVer; @@ -1373,7 +1373,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { ", rsetId:%d refId:%" PRIi64, SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId); if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) { - taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); + (void)taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); } tdReleaseRSmaInfo(pSma, pRSmaInfo); (void)tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); @@ -1629,7 +1629,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { batchMax = TMAX(batchMax, 4); } while (occupied || (++batchCnt < batchMax)) { // greedy mode - taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock + (void)taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock int32_t qallItemSize = taosQallItemSize(pInfo->qall); if (qallItemSize > 0) { if ((code = tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type)) != 0) { @@ -1663,7 +1663,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { } if (qallItemSize > 0) { - atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize); + (void)atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize); continue; } if (RSMA_NEED_FETCH(pInfo)) { @@ -1673,7 +1673,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { break; } } - atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); + (void)atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); } } } else { diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 918fd9e5d3..96010728c2 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -123,7 +123,7 @@ static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t ver, const char *pMsg TAOS_CHECK_EXIT(metaCreateTSma(SMA_META(pSma), ver, pCfg)); // create stable to save tsma result in dstVgId - tNameFromString(&stbFullName, pCfg->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&stbFullName, pCfg->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); pReq.name = (char *)tNameGetTableName(&stbFullName); pReq.suid = pCfg->dstTbUid; pReq.schemaRow = pCfg->schemaRow; @@ -283,7 +283,7 @@ static int32_t tsmaProcessDelReq(SSma *pSma, int64_t indexUid, SBatchDeleteReq * SEncoder encoder; tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len); - tEncodeSBatchDeleteReq(&encoder, pDelReq); + (void)tEncodeSBatchDeleteReq(&encoder, pDelReq); tEncoderClear(&encoder); ((SMsgHead *)pBuf)->vgId = TD_VID(pSma->pVnode); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 0ab420ce63..8a4571a4af 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -169,7 +169,7 @@ void tqPushEmptyDataRsp(STqHandle* pHandle, int32_t vgId) { } dataRsp.common.blockNum = 0; char buf[TSDB_OFFSET_LEN] = {0}; - tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset); + (void) tFormatOffset(buf, TSDB_OFFSET_LEN, &dataRsp.common.reqOffset); tqInfo("tqPushEmptyDataRsp to consumer:0x%" PRIx64 " vgId:%d, offset:%s, reqId:0x%" PRIx64, req.consumerId, vgId, buf, req.reqId); @@ -187,8 +187,8 @@ int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* char buf1[TSDB_OFFSET_LEN] = {0}; char buf2[TSDB_OFFSET_LEN] = {0}; - tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset); - tFormatOffset(buf2, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->rspOffset); + (void) tFormatOffset(buf1, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->reqOffset); + (void) tFormatOffset(buf2, TSDB_OFFSET_LEN, &((SMqDataRspCommon*)pRsp)->rspOffset); tqDebug("tmq poll vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64, vgId, pReq->consumerId, pReq->epoch, ((SMqDataRspCommon*)pRsp)->blockNum, buf1, buf2, pReq->reqId); @@ -412,7 +412,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { } char buf[TSDB_OFFSET_LEN] = {0}; - tFormatOffset(buf, TSDB_OFFSET_LEN, &reqOffset); + (void) tFormatOffset(buf, TSDB_OFFSET_LEN, &reqOffset); tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, recv poll req vgId:%d, req:%s, reqId:0x%" PRIx64, consumerId, req.epoch, pHandle->subKey, vgId, buf, req.reqId); @@ -745,7 +745,7 @@ int32_t tqBuildStreamTask(void* pTqObj, SStreamTask* pTask, int64_t nextProcessV } streamTaskResetUpstreamStageInfo(pTask); - streamSetupScheduleTrigger(pTask); + (void) streamSetupScheduleTrigger(pTask); SCheckpointInfo* pChkInfo = &pTask->chkInfo; tqSetRestoreVersionInfo(pTask); @@ -801,8 +801,11 @@ static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask if (done) { qDebug("s-task:%s scan wal(step 2) verRange:%" PRId64 "-%" PRId64 " ended, elapsed time:%.2fs", id, pStep2Range->minVer, pStep2Range->maxVer, 0.0); - streamTaskPutTranstateIntoInputQ(pTask); - streamExecTask(pTask); // exec directly + int32_t code = streamTaskPutTranstateIntoInputQ(pTask); // todo: msg lost. + if (code) { + qError("s-task:%s failed put trans-state into inputQ, code:%s", id, tstrerror(code)); + } + (void) streamExecTask(pTask); // exec directly } else { STimeWindow* pWindow = &pTask->dataRange.window; tqDebug("s-task:%s level:%d verRange:%" PRId64 "-%" PRId64 " window:%" PRId64 "-%" PRId64 @@ -811,7 +814,10 @@ static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask pStreamTask->id.idStr); ASSERT(pTask->status.schedStatus == TASK_SCHED_STATUS__WAITING); - streamSetParamForStreamScannerStep2(pTask, pStep2Range, pWindow); + int32_t code = streamSetParamForStreamScannerStep2(pTask, pStep2Range, pWindow); + if (code) { + tqError("s-task:%s level:%d failed to set step2 param", id, pTask->info.taskLevel); + } int64_t dstVer = pStep2Range->minVer; pTask->chkInfo.nextProcessVer = dstVer; @@ -820,12 +826,12 @@ static void doStartFillhistoryStep2(SStreamTask* pTask, SStreamTask* pStreamTask tqDebug("s-task:%s wal reader start scan WAL verRange:%" PRId64 "-%" PRId64 ", set sched-status:%d", id, dstVer, pStep2Range->maxVer, TASK_SCHED_STATUS__INACTIVE); - /*int8_t status = */ streamTaskSetSchedStatusInactive(pTask); + (void) streamTaskSetSchedStatusInactive(pTask); // now the fill-history task starts to scan data from wal files. - int32_t code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_SCANHIST_DONE); + code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_SCANHIST_DONE); if (code == TSDB_CODE_SUCCESS) { - tqScanWalAsync(pTq, false); + (void) tqScanWalAsync(pTq, false); } } } @@ -949,11 +955,11 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { pTask->streamTaskId.taskId, pTask->id.idStr); tqDebug("s-task:%s fill-history task set status to be dropping", id); - streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, 0); + code = streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, 0); atomic_store_32(&pTask->status.inScanHistorySentinel, 0); streamMetaReleaseTask(pMeta, pTask); - return -1; + return code; // todo: handle failure } ASSERT(pStreamTask->info.taskLevel == TASK_LEVEL__SOURCE); @@ -971,15 +977,14 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { // extracted submit data from wal files for all tasks if (pReq->reqType == STREAM_EXEC_T_EXTRACT_WAL_DATA) { - tqScanWal(pTq); - return 0; + return tqScanWal(pTq); } int32_t code = tqStreamTaskProcessRunReq(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode)); // let's continue scan data in the wal files if (code == 0 && (pReq->reqType >= 0 || pReq->reqType == STREAM_EXEC_T_RESUME_TASK)) { - tqScanWalAsync(pTq, false); + (void) tqScanWalAsync(pTq, false); // it's ok to failed } return code; @@ -1044,7 +1049,11 @@ int32_t tqStreamProgressRetrieveReq(STQ *pTq, SRpcMsg *pMsg) { pRsp->subFetchIdx = req.subFetchIdx; pRsp->vgId = req.vgId; pRsp->streamId = req.streamId; - tSerializeStreamProgressRsp(pRsp, sizeof(SStreamProgressRsp) + sizeof(SMsgHead), pRsp); + code = tSerializeStreamProgressRsp(pRsp, sizeof(SStreamProgressRsp) + sizeof(SMsgHead), pRsp); + if (code) { + goto _OVER; + } + SRpcMsg rsp = {.info = pMsg->info, .code = 0}; rsp.pCont = pRspBuf; pRspBuf = NULL; @@ -1079,18 +1088,18 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) tqError("vgId:%d failed to decode checkpoint-source msg, code:%s", vgId, tstrerror(code)); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs - return code; + return TSDB_CODE_SUCCESS; // always return success to mnode, todo: handle failure of build and send msg to mnode } tDecoderClear(&decoder); if (!vnodeIsRoleLeader(pTq->pVnode)) { tqDebug("vgId:%d not leader, ignore checkpoint-source msg, s-task:0x%x", vgId, req.taskId); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; // always return success to mnode, todo: handle failure of build and send msg to mnode } if (!pTq->pVnode->restored) { @@ -1098,9 +1107,9 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) ", transId:%d s-task:0x%x ignore it", vgId, req.checkpointId, req.transId, req.taskId); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; // always return success to mnode, , todo: handle failure of build and send msg to mnode } SStreamTask* pTask = NULL; @@ -1110,7 +1119,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) " transId:%d it may have been destroyed", vgId, req.taskId, req.checkpointId, req.transId); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs return TSDB_CODE_SUCCESS; } @@ -1123,13 +1132,13 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) streamMetaReleaseTask(pMeta, pTask); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; // todo retry handle error } // todo save the checkpoint failed info - taosThreadMutexLock(&pTask->lock); + streamMutexLock(&pTask->lock); ETaskStatus status = streamTaskGetStatus(pTask).state; if (req.mndTrigger == 1) { @@ -1137,13 +1146,12 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) tqError("s-task:%s not ready for checkpoint, since it is halt, ignore checkpointId:%" PRId64 ", set it failure", pTask->id.idStr, req.checkpointId); - taosThreadMutexUnlock(&pTask->lock); + streamMutexUnlock(&pTask->lock); streamMetaReleaseTask(pMeta, pTask); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs - return TSDB_CODE_SUCCESS; } } else { @@ -1162,7 +1170,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) " transId:%d already handled, ignore msg and continue process checkpoint", pTask->id.idStr, checkpointId, req.transId); - taosThreadMutexUnlock(&pTask->lock); + streamMutexUnlock(&pTask->lock); streamMetaReleaseTask(pMeta, pTask); return TSDB_CODE_SUCCESS; @@ -1171,19 +1179,24 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) tqWarn("s-task:%s repeatly recv checkpoint-source msg checkpointId:%" PRId64 " transId:%d already handled, return success", pTask->id.idStr, req.checkpointId, req.transId); - taosThreadMutexUnlock(&pTask->lock); + streamMutexUnlock(&pTask->lock); streamMetaReleaseTask(pMeta, pTask); SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs return TSDB_CODE_SUCCESS; } } - streamProcessCheckpointSourceReq(pTask, &req); - taosThreadMutexUnlock(&pTask->lock); + code = streamProcessCheckpointSourceReq(pTask, &req); + streamMutexUnlock(&pTask->lock); + + if (code) { + qError("s-task:%s (vgId:%d) failed to process checkpoint-source req, code:%s", pTask->id.idStr, vgId, tstrerror(code)); + return code; + } if (req.mndTrigger) { qInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64 ", transId:%d, ", pTask->id.idStr, @@ -1198,13 +1211,13 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) code = streamAddCheckpointSourceRspMsg(&req, &pMsg->info, pTask); if (code != TSDB_CODE_SUCCESS) { SRpcMsg rsp = {0}; - streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); + (void) streamTaskBuildCheckpointSourceRsp(&req, &pMsg->info, &rsp, TSDB_CODE_SUCCESS); tmsgSendRsp(&rsp); // error occurs - return code; + return TSDB_CODE_SUCCESS; } streamMetaReleaseTask(pMeta, pTask); - return code; + return TSDB_CODE_SUCCESS; } // downstream task has complete the stream task checkpoint procedure, let's start the handle the rsp by execute task diff --git a/source/dnode/vnode/src/tq/tqScan.c b/source/dnode/vnode/src/tq/tqScan.c index 5df8c97962..d072d7199c 100644 --- a/source/dnode/vnode/src/tq/tqScan.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -115,14 +115,15 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* if (pDataBlock == NULL) { break; } + STqOffsetVal offset = {0}; - qStreamExtractOffset(task, &offset); + code = qStreamExtractOffset(task, &offset); + TSDB_CHECK_CODE(code, line, END); + pHandle->block = NULL; code = createOneDataBlock(pDataBlock, true, &pHandle->block); - if (code) { - return code; - } + TSDB_CHECK_CODE(code, line, END); pHandle->blockTime = offset.ts; tOffsetDestroy(&offset); @@ -140,8 +141,11 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* } else { code = copyDataBlock(pHandle->block, pDataBlock); TSDB_CHECK_CODE(code, line, END); + STqOffsetVal offset = {0}; - qStreamExtractOffset(task, &offset); + code = qStreamExtractOffset(task, &offset); + TSDB_CHECK_CODE(code, line, END); + pRsp->sleepTime = offset.ts - pHandle->blockTime; pHandle->blockTime = offset.ts; tOffsetDestroy(&offset); @@ -164,10 +168,11 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* tqDebug("consumer:0x%" PRIx64 " vgId:%d tmq task executed finished, total blocks:%d, totalRows:%d", pHandle->consumerId, vgId, pRsp->common.blockNum, totalRows); - qStreamExtractOffset(task, &pRsp->common.rspOffset); + code = qStreamExtractOffset(task, &pRsp->common.rspOffset); END: - if ( code!= 0){ - tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line, code); + if (code != 0) { + tqError("consumer:0x%" PRIx64 " vgId:%d tmq task executed error, line:%d code:%d", pHandle->consumerId, vgId, line, + code); } return code; } @@ -241,31 +246,40 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqBatc // get meta SMqBatchMetaRsp* tmp = qStreamExtractMetaMsg(task); if (taosArrayGetSize(tmp->batchMetaReq) > 0) { - qStreamExtractOffset(task, &tmp->rspOffset); + code = qStreamExtractOffset(task, &tmp->rspOffset); + if (code) { + return code; + } + *pBatchMetaRsp = *tmp; tqDebug("tmqsnap task get meta"); break; } if (pDataBlock == NULL) { - qStreamExtractOffset(task, pOffset); + code = qStreamExtractOffset(task, pOffset); + if (code) { + break; + } + if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { continue; } + tqDebug("tmqsnap vgId: %d, tsdb consume over, switch to wal, ver %" PRId64, TD_VID(pTq->pVnode), pHandle->snapshotVer + 1); - qStreamExtractOffset(task, &pRsp->common.rspOffset); + code = qStreamExtractOffset(task, &pRsp->common.rspOffset); break; } if (pRsp->common.blockNum > 0) { tqDebug("tmqsnap task exec exited, get data"); - qStreamExtractOffset(task, &pRsp->common.rspOffset); + code = qStreamExtractOffset(task, &pRsp->common.rspOffset); break; } } - return 0; + return code; } diff --git a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c index dda5173ad9..c89ad807c7 100644 --- a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c +++ b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c @@ -39,19 +39,21 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa // alloc pReader = (SStreamTaskReader*)taosMemoryCalloc(1, sizeof(SStreamTaskReader)); if (pReader == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY); } pReader->pTq = pTq; pReader->sver = sver; pReader->ever = ever; pReader->tdbTbList = taosArrayInit(4, sizeof(STablePair)); + if (pReader->tdbTbList == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _err); + } STablePair pair1 = {.tbl = pTq->pStreamMeta->pTaskDb, .type = SNAP_DATA_STREAM_TASK}; - taosArrayPush(pReader->tdbTbList, &pair1); + (void)taosArrayPush(pReader->tdbTbList, &pair1); STablePair pair2 = {.tbl = pTq->pStreamMeta->pCheckpointDb, .type = SNAP_DATA_STREAM_TASK_CHECKPOINT}; - taosArrayPush(pReader->tdbTbList, &pair2); + (void)taosArrayPush(pReader->tdbTbList, &pair2); pReader->pos = 0; @@ -60,16 +62,14 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa if (code) { tqInfo("vgId:%d, vnode stream-task snapshot reader failed to open, reason: %s", TD_VID(pTq->pVnode), tstrerror(code)); - taosMemoryFree(pReader); - goto _err; + TAOS_CHECK_GOTO(code, NULL, _err); } code = tdbTbcMoveToFirst(pReader->pCur); if (code) { tqInfo("vgId:%d, vnode stream-task snapshot reader failed to iterate, reason: %s", TD_VID(pTq->pVnode), tstrerror(code)); - taosMemoryFree(pReader); - goto _err; + TAOS_CHECK_GOTO(code, NULL, _err); } tqDebug("vgId:%d, vnode stream-task snapshot reader opened", TD_VID(pTq->pVnode)); @@ -79,15 +79,18 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa _err: tqError("vgId:%d, vnode stream-task snapshot reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code)); + (void)streamTaskSnapReaderClose(pReader); *ppReader = NULL; return code; } int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) { + if (pReader == NULL) return 0; + int32_t code = 0; tqInfo("vgId:%d, vnode stream-task snapshot reader closed", TD_VID(pReader->pTq->pVnode)); taosArrayDestroy(pReader->tdbTbList); - tdbTbcClose(pReader->pCur); + (void)tdbTbcClose(pReader->pCur); taosMemoryFree(pReader); return code; } @@ -116,20 +119,24 @@ NextTbl: break; } else { pVal = taosMemoryCalloc(1, tLen); + if (pVal == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } memcpy(pVal, tVal, tLen); vLen = tLen; } - tdbTbcMoveToNext(pReader->pCur); + (void)tdbTbcMoveToNext(pReader->pCur); break; } if (except == 1) { if (pReader->pos + 1 < taosArrayGetSize(pReader->tdbTbList)) { - tdbTbcClose(pReader->pCur); + (void)tdbTbcClose(pReader->pCur); pReader->pos += 1; pPair = taosArrayGet(pReader->tdbTbList, pReader->pos); code = tdbTbcOpen(pPair->tbl, &pReader->pCur, NULL); - tdbTbcMoveToFirst(pReader->pCur); + (void)tdbTbcMoveToFirst(pReader->pCur); goto NextTbl; } @@ -174,8 +181,7 @@ int32_t streamTaskSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa // alloc pWriter = (SStreamTaskWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); if (pWriter == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY); } pWriter->pTq = pTq; pWriter->sver = sver; @@ -184,12 +190,6 @@ int32_t streamTaskSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa *ppWriter = pWriter; tqDebug("vgId:%d, vnode stream-task snapshot writer opened", TD_VID(pTq->pVnode)); return code; - -_err: - tqError("vgId:%d, vnode stream-task snapshot writer failed to write since %s", TD_VID(pTq->pVnode), tstrerror(code)); - *ppWriter = NULL; - return code; - return 0; } int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback) { @@ -199,7 +199,7 @@ int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback) { streamMetaWLock(pTq->pStreamMeta); tqDebug("vgId:%d, vnode stream-task snapshot writer closed", TD_VID(pTq->pVnode)); if (rollback) { - tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn); + (void)tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn); } else { code = tdbCommit(pTq->pStreamMeta->db, pTq->pStreamMeta->txn); if (code) goto _err; @@ -207,8 +207,7 @@ int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback) { if (code) goto _err; } - if (tdbBegin(pTq->pStreamMeta->db, &pTq->pStreamMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { - code = -1; + if ((code = tdbBegin(pTq->pStreamMeta->db, &pTq->pStreamMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0)) < 0) { taosMemoryFree(pWriter); goto _err; } @@ -241,10 +240,11 @@ int32_t streamTaskSnapWrite(SStreamTaskWriter* pWriter, uint8_t* pData, uint32_t int64_t key[2] = {taskId.streamId, taskId.taskId}; streamMetaWLock(pTq->pStreamMeta); - if (tdbTbUpsert(pTq->pStreamMeta->pTaskDb, key, sizeof(int64_t) << 1, (uint8_t*)pData + sizeof(SSnapDataHdr), - nData - sizeof(SSnapDataHdr), pTq->pStreamMeta->txn) < 0) { + if ((code = + tdbTbUpsert(pTq->pStreamMeta->pTaskDb, key, sizeof(int64_t) << 1, (uint8_t*)pData + sizeof(SSnapDataHdr), + nData - sizeof(SSnapDataHdr), pTq->pStreamMeta->txn)) < 0) { streamMetaWUnLock(pTq->pStreamMeta); - return -1; + return code; } streamMetaWUnLock(pTq->pStreamMeta); } else if (pHdr->type == SNAP_DATA_STREAM_TASK_CHECKPOINT) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 5073b3e9ee..8d5fa8b0b3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -117,7 +117,7 @@ typedef struct { static void tsdbGetRocksPath(STsdb *pTsdb, char *path) { SVnode *pVnode = pTsdb->pVnode; - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN); int32_t offset = strlen(path); snprintf(path + offset, TSDB_FILENAME_LEN - offset - 1, "%scache.rdb", TD_DIRSEP); @@ -722,20 +722,14 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; { SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[0], klen); } taosMemoryFreeClear(pLastCol); pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[1], klen); } @@ -748,7 +742,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[0], klen); if (h) { erase = true; - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[0], klen); @@ -758,7 +752,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[1], klen); if (h) { erase = true; - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[1], klen); @@ -1066,12 +1060,12 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray if (cmp_res < 0 || (cmp_res == 0 && !COL_VAL_IS_NONE(pColVal))) { tsdbCacheUpdateLastCol(pLastCol, pRowKey, pColVal); } - taosLRUCacheRelease(pCache, h, false); + (void)taosLRUCacheRelease(pCache, h, false); } else { if (!remainCols) { remainCols = taosArrayInit(num_keys * 2, sizeof(SIdxKey)); } - taosArrayPush(remainCols, &(SIdxKey){i, *key}); + (void)taosArrayPush(remainCols, &(SIdxKey){i, *key}); } } @@ -1123,10 +1117,12 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray SColVal *pColVal = &updCtx->colVal; SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + /* if (code) { tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); } + */ SLastCol *PToFree = pLastCol; if (IS_LAST_KEY(idxKey->key) && !COL_VAL_IS_VALUE(pColVal)) { @@ -1242,18 +1238,18 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 tsdbRowGetKey(&lRow, &tsdbRowKey); STSDBRowIter iter = {0}; - tsdbRowIterOpen(&iter, &lRow, pTSchema); + (void)tsdbRowIterOpen(&iter, &lRow, pTSchema); int32_t iCol = 0; for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal && iCol < nCol; pColVal = tsdbRowIterNext(&iter), iCol++) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); if (!COL_VAL_IS_VALUE(pColVal)) { - tSimpleHashPut(iColHash, &iCol, sizeof(iCol), NULL, 0); + (void)tSimpleHashPut(iColHash, &iCol, sizeof(iCol), NULL, 0); continue; } updateCtx.lflag = LFLAG_LAST; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); } tsdbRowClose(&iter); @@ -1277,14 +1273,14 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 if (COL_VAL_IS_VALUE(&colVal)) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST, .tsdbRowKey = tsdbRowKey, .colVal = colVal}; - taosArrayPush(ctxArray, &updateCtx); - tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter); + (void)taosArrayPush(ctxArray, &updateCtx); + (void)tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter); } } } // 3. do update - tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + (void)tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); _exit: taosMemoryFreeClear(pTSchema); @@ -1317,7 +1313,7 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo .tsdbRowKey = tsdbRowKey, .colVal = COL_VAL_VALUE(PRIMARYKEY_TIMESTAMP_COL_ID, ((SValue){.type = TSDB_DATA_TYPE_TIMESTAMP, .val = lRow.pBlockData->aTSKEY[lRow.iRow]}))}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); } TSDBROW tRow = tsdbRowFromBlockData(pBlockData, 0); @@ -1338,7 +1334,7 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo tColDataGetValue(pColData, tRow.iRow, &colVal); SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST, .tsdbRowKey = tsdbRowKey, .colVal = colVal}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); break; } } @@ -1346,15 +1342,15 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo // 2. prepare last row STSDBRowIter iter = {0}; - tsdbRowIterOpen(&iter, &lRow, pTSchema); + (void)tsdbRowIterOpen(&iter, &lRow, pTSchema); for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal; pColVal = tsdbRowIterNext(&iter)) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); } tsdbRowClose(&iter); // 3. do update - tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + (void)tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); _exit: taosMemoryFreeClear(pTSchema); @@ -1379,7 +1375,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr if (idxKey->key.cid != PRIMARYKEY_TIMESTAMP_COL_ID) { SLastKey *key = &(SLastKey){.lflag = ltype, .uid = uid, .cid = PRIMARYKEY_TIMESTAMP_COL_ID}; - taosArrayInsert(remainCols, 0, &(SIdxKey){0, *key}); + (void)taosArrayInsert(remainCols, 0, &(SIdxKey){0, *key}); } int num_keys = TARRAY_SIZE(remainCols); @@ -1416,7 +1412,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr if (NULL == lastTmpIndexArray) { lastTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t)); } - taosArrayPush(lastTmpIndexArray, &(i)); + (void)taosArrayPush(lastTmpIndexArray, &(i)); lastColIds[lastIndex] = idxKey->key.cid; lastSlotIds[lastIndex] = pr->pSlotIds[idxKey->idx]; lastIndex++; @@ -1424,7 +1420,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr if (NULL == lastrowTmpIndexArray) { lastrowTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t)); } - taosArrayPush(lastrowTmpIndexArray, &(i)); + (void)taosArrayPush(lastrowTmpIndexArray, &(i)); lastrowColIds[lastrowIndex] = idxKey->key.cid; lastrowSlotIds[lastrowIndex] = pr->pSlotIds[idxKey->idx]; lastrowIndex++; @@ -1434,17 +1430,18 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr pTmpColArray = taosArrayInit(lastIndex + lastrowIndex, sizeof(SLastCol)); if (lastTmpIndexArray != NULL) { - mergeLastCid(uid, pTsdb, &lastTmpColArray, pr, lastColIds, lastIndex, lastSlotIds); + (void)mergeLastCid(uid, pTsdb, &lastTmpColArray, pr, lastColIds, lastIndex, lastSlotIds); for (int i = 0; i < taosArrayGetSize(lastTmpColArray); i++) { - taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastTmpIndexArray, i), taosArrayGet(lastTmpColArray, i)); + (void)taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastTmpIndexArray, i), + taosArrayGet(lastTmpColArray, i)); } } if (lastrowTmpIndexArray != NULL) { - mergeLastRowCid(uid, pTsdb, &lastrowTmpColArray, pr, lastrowColIds, lastrowIndex, lastrowSlotIds); + (void)mergeLastRowCid(uid, pTsdb, &lastrowTmpColArray, pr, lastrowColIds, lastrowIndex, lastrowSlotIds); for (int i = 0; i < taosArrayGetSize(lastrowTmpColArray); i++) { - taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastrowTmpIndexArray, i), - taosArrayGet(lastrowTmpColArray, i)); + (void)taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastrowTmpIndexArray, i), + taosArrayGet(lastrowTmpColArray, i)); } } @@ -1586,10 +1583,7 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA SLRUCache *pCache = pTsdb->lruCache; for (int i = 0, j = 0; i < num_keys && j < TARRAY_SIZE(remainCols); ++i) { SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); SLastCol *PToFree = pLastCol; SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j]; if (pLastCol) { @@ -1682,19 +1676,19 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache TAOS_CHECK_RETURN(reallocVarDataVal(&lastCol.rowKey.pks[j])); } TAOS_CHECK_RETURN(reallocVarData(&lastCol.colVal)); - taosArrayPush(pLastArray, &lastCol); + (void)taosArrayPush(pLastArray, &lastCol); - taosLRUCacheRelease(pCache, h, false); + (void)taosLRUCacheRelease(pCache, h, false); } else { SLastCol noneCol = {.rowKey.ts = TSKEY_MIN, .colVal = COL_VAL_NONE(cid, pr->pSchema->columns[pr->pSlotIds[i]].type)}; - taosArrayPush(pLastArray, &noneCol); + (void)taosArrayPush(pLastArray, &noneCol); if (!remainCols) { remainCols = taosArrayInit(num_keys, sizeof(SIdxKey)); } - taosArrayPush(remainCols, &(SIdxKey){i, key}); + (void)taosArrayPush(remainCols, &(SIdxKey){i, key}); } } @@ -1721,7 +1715,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache } taosArraySet(pLastArray, idxKey->idx, &lastCol); - taosLRUCacheRelease(pCache, h, false); + (void)taosLRUCacheRelease(pCache, h, false); taosArrayRemove(remainCols, i); } else { @@ -1810,10 +1804,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; for (int i = 0; i < num_keys; ++i) { SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); (void)taosThreadMutexLock(&pTsdb->rCache.rMutex); if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) { rocksdb_writebatch_delete(wb, keys_list[i], klen); @@ -1821,10 +1812,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE taosMemoryFreeClear(pLastCol); pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i + num_keys], values_list_sizes[i + num_keys], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[i + num_keys], values_list_sizes[i + num_keys], &pLastCol); if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) { rocksdb_writebatch_delete(wb, keys_list[num_keys + i], klen); } @@ -1846,7 +1834,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE if (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey) { erase = true; } - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen); @@ -1862,7 +1850,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE if (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey) { erase = true; } - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[num_keys + i], klen); @@ -1982,7 +1970,7 @@ static int32_t getTableDelDataFromTbData(STbData *pTbData, SArray *aDelData) { SDelData *pDelData = pTbData ? pTbData->pHead : NULL; for (; pDelData; pDelData = pDelData->pNext) { - taosArrayPush(aDelData, pDelData); + (void)taosArrayPush(aDelData, pDelData); } return code; @@ -2005,7 +1993,7 @@ static STableLoadInfo *getTableLoadInfo(SCacheRowsReader *pReader, uint64_t uid) if (!ppInfo) { pInfo = taosMemoryCalloc(1, sizeof(STableLoadInfo)); if (pInfo) { - tSimpleHashPut(pReader->pTableMap, &uid, sizeof(uint64_t), &pInfo, POINTER_BYTES); + (void)tSimpleHashPut(pReader->pTableMap, &uid, sizeof(uint64_t), &pInfo, POINTER_BYTES); } return pInfo; @@ -2117,11 +2105,11 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea TD_VID(pReader->pTsdb->pVnode), pReader->pCurFileSet->fid, record.skey, record.ekey, uid);*/ SDelData delData = {.version = record.version, .sKey = record.skey, .eKey = record.ekey}; - taosArrayPush(pInfo->pTombData, &delData); + (void)taosArrayPush(pInfo->pTombData, &delData); } } - tTombBlockDestroy(&block); + (void)tTombBlockDestroy(&block); if (finished) { TAOS_RETURN(code); @@ -2312,7 +2300,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie state->pr->pCurFileSet = state->pFileSet; - loadDataTomb(state->pr, state->pr->pFileReader); + (void)loadDataTomb(state->pr, state->pr->pFileReader); TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlk(state->pr->pFileReader, &state->pr->pBlkArray), &lino, _err); } @@ -2329,7 +2317,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie SBrinBlk *pBrinBlk = &pBlkArray->data[i]; if (state->suid >= pBrinBlk->minTbid.suid && state->suid <= pBrinBlk->maxTbid.suid) { if (state->uid >= pBrinBlk->minTbid.uid && state->uid <= pBrinBlk->maxTbid.uid) { - taosArrayPush(state->pIndexList, pBrinBlk); + (void)taosArrayPush(state->pIndexList, pBrinBlk); } } else if (state->suid > pBrinBlk->maxTbid.suid || (state->suid == pBrinBlk->maxTbid.suid && state->uid > pBrinBlk->maxTbid.uid)) { @@ -2385,7 +2373,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pLastRow) { if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } clearLastFileSet(state); @@ -2493,7 +2481,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pLastRow) { if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } *ppRow = &state->row; @@ -2517,7 +2505,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie } else { // TODO: merge rows and *ppRow = mergedRow SRowMerger *pMerger = &state->rowMerger; - tsdbRowMergerInit(pMerger, state->pTSchema); + (void)tsdbRowMergerInit(pMerger, state->pTSchema); TAOS_CHECK_GOTO(tsdbRowMergerAdd(pMerger, &state->row, state->pTSchema), &lino, _err); TAOS_CHECK_GOTO(tsdbRowMergerAdd(pMerger, state->pLastRow, state->pTSchema), &lino, _err); @@ -2682,7 +2670,7 @@ int32_t clearNextRowFromFS(void *iter) { } if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } if (state->pBlockData) { @@ -2715,7 +2703,7 @@ int32_t clearNextRowFromFS(void *iter) { static void clearLastFileSet(SFSNextRowIter *state) { if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } if (state->pBlockData) { @@ -2724,7 +2712,7 @@ static void clearLastFileSet(SFSNextRowIter *state) { } if (state->pr->pFileReader) { - tsdbDataFileReaderClose(&state->pr->pFileReader); + (void)tsdbDataFileReaderClose(&state->pr->pFileReader); state->pr->pFileReader = NULL; state->pr->pCurFileSet = NULL; @@ -2814,7 +2802,7 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) { for (int i = 0; i < 3; ++i) { if (pIter->input[i].nextRowClearFn) { - pIter->input[i].nextRowClearFn(pIter->input[i].iter); + (void)pIter->input[i].nextRowClearFn(pIter->input[i].iter); } } @@ -2898,7 +2886,7 @@ static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pI pInfo->pTombData = taosArrayInit(4, sizeof(SDelData)); } - taosArrayAddAll(pInfo->pTombData, pIter->pMemDelData); + (void)taosArrayAddAll(pInfo->pTombData, pIter->pMemDelData); size_t delSize = TARRAY_SIZE(pInfo->pTombData); if (delSize > 0) { @@ -2944,7 +2932,7 @@ static int32_t initLastColArrayPartial(STSchema *pTSchema, SArray **ppColArray, int16_t slotId = slotIds[i]; SLastCol col = {.rowKey.ts = 0, .colVal = COL_VAL_NULL(pTSchema->columns[slotId].colId, pTSchema->columns[slotId].type)}; - taosArrayPush(pColArray, &col); + (void)taosArrayPush(pColArray, &col); } *ppColArray = pColArray; @@ -2998,18 +2986,18 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC } for (int i = 0; i < nCols; ++i) { - taosArrayPush(aColArray, &aCols[i]); + (void)taosArrayPush(aColArray, &aCols[i]); } STsdbRowKey lastRowKey = {.key.ts = TSKEY_MAX}; // inverse iterator CacheNextRowIter iter = {0}; - nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); + (void)nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); do { TSDBROW *pRow = NULL; - nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, true, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); + (void)nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, true, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); if (!pRow) { break; @@ -3142,7 +3130,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC } *ppLastArray = pColArray; - nextRowIterClose(&iter); + (void)nextRowIterClose(&iter); taosArrayDestroy(aColArray); TAOS_RETURN(code); @@ -3184,16 +3172,16 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, } for (int i = 0; i < nCols; ++i) { - taosArrayPush(aColArray, &aCols[i]); + (void)taosArrayPush(aColArray, &aCols[i]); } // inverse iterator CacheNextRowIter iter = {0}; - nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); + (void)nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); do { TSDBROW *pRow = NULL; - nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, false, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); + (void)nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, false, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); if (!pRow) { break; @@ -3266,7 +3254,7 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, } *ppLastArray = pColArray; - nextRowIterClose(&iter); + (void)nextRowIterClose(&iter); taosArrayDestroy(aColArray); TAOS_RETURN(code); @@ -3286,13 +3274,7 @@ _err: TAOS_RETURN(code); } -int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { - int32_t code = 0; - - taosLRUCacheRelease(pCache, h, false); - - return code; -} +void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { (void)taosLRUCacheRelease(pCache, h, false); } void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) { taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 0c3fc95d6c..4467102d6f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -251,7 +251,7 @@ static int32_t tsdbCommitOpenReader(SCommitter2 *committer) { _exit: if (code) { - tsdbCommitCloseReader(committer); + TAOS_UNUSED(tsdbCommitCloseReader(committer)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(committer->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } @@ -259,8 +259,8 @@ _exit: } static int32_t tsdbCommitCloseIter(SCommitter2 *committer) { - tsdbIterMergerClose(&committer->tombIterMerger); - tsdbIterMergerClose(&committer->dataIterMerger); + TAOS_UNUSED(tsdbIterMergerClose(&committer->tombIterMerger)); + TAOS_UNUSED(tsdbIterMergerClose(&committer->dataIterMerger)); TARRAY2_CLEAR(committer->tombIterArray, tsdbIterClose); TARRAY2_CLEAR(committer->dataIterArray, tsdbIterClose); return 0; @@ -322,7 +322,7 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) { _exit: if (code) { - tsdbCommitCloseIter(committer); + TAOS_UNUSED(tsdbCommitCloseIter(committer)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(committer->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } @@ -335,7 +335,7 @@ static int32_t tsdbCommitFileSetBegin(SCommitter2 *committer) { STsdb *tsdb = committer->tsdb; // check if can commit - tsdbFSCheckCommit(tsdb, committer->ctx->info->fid); + TAOS_UNUSED(tsdbFSCheckCommit(tsdb, committer->ctx->info->fid)); committer->ctx->expLevel = tsdbFidLevel(committer->ctx->info->fid, &tsdb->keepCfg, committer->now); tsdbFidKeyRange(committer->ctx->info->fid, committer->minutes, committer->precision, &committer->ctx->minKey, @@ -344,7 +344,7 @@ static int32_t tsdbCommitFileSetBegin(SCommitter2 *committer) { TAOS_CHECK_GOTO(tfsAllocDisk(committer->tsdb->pVnode->pTfs, committer->ctx->expLevel, &committer->ctx->did), &lino, _exit); - tfsMkdirRecurAt(committer->tsdb->pVnode->pTfs, committer->tsdb->path, committer->ctx->did); + TAOS_UNUSED(tfsMkdirRecurAt(committer->tsdb->pVnode->pTfs, committer->tsdb->path, committer->ctx->did)); committer->ctx->tbid->suid = 0; committer->ctx->tbid->uid = 0; @@ -430,12 +430,12 @@ static int32_t tsdbCommitInfoDestroy(STsdb *pTsdb) { if (pTsdb->commitInfo) { for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i); - vHashDrop(pTsdb->commitInfo->ht, info); + TAOS_UNUSED(vHashDrop(pTsdb->commitInfo->ht, info)); tsdbTFileSetClear(&info->fset); taosMemoryFree(info); } - vHashDestroy(&pTsdb->commitInfo->ht); + TAOS_UNUSED(vHashDestroy(&pTsdb->commitInfo->ht)); taosArrayDestroy(pTsdb->commitInfo->arr); pTsdb->commitInfo->arr = NULL; taosMemoryFreeClear(pTsdb->commitInfo); @@ -461,7 +461,7 @@ static int32_t tsdbCommitInfoInit(STsdb *pTsdb) { _exit: if (code) { - tsdbCommitInfoDestroy(pTsdb); + TAOS_UNUSED(tsdbCommitInfoDestroy(pTsdb)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(pTsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } return code; @@ -531,7 +531,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { SFileSetCommitInfo tinfo = { .fid = fid, }; - vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info); + TAOS_UNUSED(vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info)); if (info == NULL) { TAOS_CHECK_GOTO(tsdbCommitInfoAdd(tsdb, fid), &lino, _exit); } @@ -555,7 +555,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { }; // check if the file set already on the commit list - vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info); + TAOS_UNUSED(vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info)); if (info != NULL) { continue; } @@ -589,7 +589,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); - tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset); + TAOS_UNUSED(tsdbBeginTaskOnFileSet(tsdb, info->fid, &fset)); if (fset) { code = tsdbTFileSetInitCopy(tsdb, fset, &info->fset); if (code) { @@ -603,7 +603,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { _exit: if (code) { - tsdbCommitInfoDestroy(tsdb); + TAOS_UNUSED(tsdbCommitInfoDestroy(tsdb)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } return code; @@ -689,7 +689,7 @@ int32_t tsdbCommitBegin(STsdb *tsdb, SCommitInfo *info) { (void)taosThreadMutexLock(&tsdb->mutex); tsdb->imem = NULL; (void)taosThreadMutexUnlock(&tsdb->mutex); - tsdbUnrefMemTable(imem, NULL, true); + TAOS_UNUSED(tsdbUnrefMemTable(imem, NULL, true)); } else { SCommitter2 committer = {0}; @@ -730,14 +730,14 @@ 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) { - tsdbFinishTaskOnFileSet(tsdb, info->fid); + TAOS_UNUSED(tsdbFinishTaskOnFileSet(tsdb, info->fid)); } } (void)taosThreadMutexUnlock(&tsdb->mutex); - tsdbCommitInfoDestroy(tsdb); - tsdbUnrefMemTable(pMemTable, NULL, true); + TAOS_UNUSED(tsdbCommitInfoDestroy(tsdb)); + TAOS_UNUSED(tsdbUnrefMemTable(pMemTable, NULL, true)); } _exit: @@ -761,11 +761,11 @@ 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) { - tsdbFinishTaskOnFileSet(pTsdb, info->fid); + TAOS_UNUSED(tsdbFinishTaskOnFileSet(pTsdb, info->fid)); } } (void)taosThreadMutexUnlock(&pTsdb->mutex); - tsdbCommitInfoDestroy(pTsdb); + TAOS_UNUSED(tsdbCommitInfoDestroy(pTsdb)); _exit: if (code) { diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c index e358b8f87e..6469160536 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRAW.c @@ -35,7 +35,7 @@ int32_t tsdbDataFileRAWReaderOpen(const char *fname, const SDataFileRAWReaderCon } } else { char fname1[TSDB_FILENAME_LEN]; - tsdbTFileName(config->tsdb, &config->file, fname1); + (void)tsdbTFileName(config->tsdb, &config->file, fname1); TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd, lcn), &lino, _exit); } @@ -159,7 +159,7 @@ static int32_t tsdbDataFileRAWWriterOpenDataFD(SDataFileRAWWriter *writer) { flag |= (TD_FILE_CREATE | TD_FILE_TRUNC); } - tsdbTFileName(writer->config->tsdb, &writer->file, fname); + (void)tsdbTFileName(writer->config->tsdb, &writer->file, fname); TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd, writer->file.lcn), &lino, _exit); _exit: @@ -202,7 +202,7 @@ int32_t tsdbDataFileRAWWriterClose(SDataFileRAWWriter **writer, bool abort, TFil } else { TAOS_CHECK_GOTO(tsdbDataFileRAWWriterCloseCommit(writer[0], opArr), &lino, _exit); } - tsdbDataFileRAWWriterDoClose(writer[0]); + (void)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 28598f23f7..2665cc1aaf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c @@ -135,7 +135,7 @@ int32_t tsdbDataFileReaderOpen(const char *fname[], const SDataFileReaderConfig for (int32_t i = 0; i < TSDB_FTYPE_MAX; ++i) { if (config->files[i].exist) { char fname1[TSDB_FILENAME_LEN]; - tsdbTFileName(config->tsdb, &config->files[i].file, fname1); + (void)tsdbTFileName(config->tsdb, &config->files[i].file, fname1); int32_t lcn = config->files[i].file.lcn; TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd[i], lcn), &lino, _exit); } @@ -667,7 +667,7 @@ static int32_t tsdbDataFileWriterCloseAbort(SDataFileWriter *writer) { static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) { if (writer->ctx->reader) { - tsdbDataFileReaderClose(&writer->ctx->reader); + (void)tsdbDataFileReaderClose(&writer->ctx->reader); } tTombBlockDestroy(writer->tombBlock); @@ -857,7 +857,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr } } - tsdbWriterUpdVerRange(range, brinBlk.minVer, brinBlk.maxVer); + (void)tsdbWriterUpdVerRange(range, brinBlk.minVer, brinBlk.maxVer); // write to file for (int32_t i = 0; i < 10; ++i) { @@ -1018,7 +1018,7 @@ static int32_t tsdbDataFileDoWriteBlockData(SDataFileWriter *writer, SBlockData } } - tsdbWriterUpdVerRange(&writer->ctx->range, record->minVer, record->maxVer); + (void)tsdbWriterUpdVerRange(&writer->ctx->range, record->minVer, record->maxVer); code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, bData->suid != 0 ? bData->suid : bData->uid, &cmprInfo.pColCmpr); @@ -1371,7 +1371,7 @@ int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAl } } - tsdbWriterUpdVerRange(range, tombBlk.minVer, tombBlk.maxVer); + (void)tsdbWriterUpdVerRange(range, tombBlk.minVer, tombBlk.maxVer); for (int32_t i = 0; i < ARRAY_SIZE(tombBlock->buffers); i++) { tBufferClear(buffer0); @@ -1640,8 +1640,8 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr .fid = writer->config->fid, .nf = writer->files[ftype], }; - tsdbTFileUpdVerRange(&op.nf, ofRange); - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, ofRange); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit); // .data @@ -1652,7 +1652,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr .fid = writer->config->fid, .nf = writer->files[ftype], }; - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit); } else if (writer->config->files[ftype].file.size != writer->files[ftype].size) { op = (STFileOp){ @@ -1661,7 +1661,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr .of = writer->config->files[ftype].file, .nf = writer->files[ftype], }; - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit); } @@ -1673,7 +1673,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr .fid = writer->config->fid, .nf = writer->files[ftype], }; - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit); } else if (writer->config->files[ftype].file.size != writer->files[ftype].size) { op = (STFileOp){ @@ -1682,7 +1682,7 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr .of = writer->config->files[ftype].file, .nf = writer->files[ftype], }; - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit); } } @@ -1716,8 +1716,8 @@ static int32_t tsdbDataFileWriterCloseCommit(SDataFileWriter *writer, TFileOpArr .fid = writer->config->fid, .nf = writer->files[ftype], }; - tsdbTFileUpdVerRange(&op.nf, ofRange); - tsdbTFileUpdVerRange(&op.nf, writer->ctx->tombRange); + (void)tsdbTFileUpdVerRange(&op.nf, ofRange); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->tombRange); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArr, op), &lino, _exit); } int32_t encryptAlgorithm = writer->config->tsdb->pVnode->config.tsdbCfg.encryptAlgorithm; @@ -1754,7 +1754,7 @@ static int32_t tsdbDataFileWriterOpenDataFD(SDataFileWriter *writer) { } int32_t lcn = writer->files[ftype].lcn; - tsdbTFileName(writer->config->tsdb, &writer->files[ftype], fname); + (void)tsdbTFileName(writer->config->tsdb, &writer->files[ftype], fname); TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd[ftype], lcn), &lino, _exit); if (writer->files[ftype].size == 0) { @@ -1804,7 +1804,7 @@ int32_t tsdbDataFileWriterClose(SDataFileWriter **writer, bool abort, TFileOpArr } else { TAOS_CHECK_GOTO(tsdbDataFileWriterCloseCommit(writer[0], opArr), &lino, _exit); } - tsdbDataFileWriterDoClose(writer[0]); + (void)tsdbDataFileWriterDoClose(writer[0]); } taosMemoryFree(writer[0]); writer[0] = NULL; @@ -1915,7 +1915,7 @@ static int32_t tsdbDataFileWriterOpenTombFD(SDataFileWriter *writer) { int32_t flag = (TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); int32_t lcn = writer->files[ftype].lcn; - tsdbTFileName(writer->config->tsdb, writer->files + ftype, fname); + (void)tsdbTFileName(writer->config->tsdb, writer->files + ftype, fname); TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd[ftype], lcn), &lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index b262912f9b..cc89b106da 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -102,8 +102,8 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) { code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); } - tsdbFSToBinary(pData, pFS); - taosCalcChecksumAppend(0, pData, size); + (void)tsdbFSToBinary(pData, pFS); + (void)taosCalcChecksumAppend(0, pData, size); // save to file pFD = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH); @@ -125,7 +125,7 @@ _exit: tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname); } taosMemoryFree(pData); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); return code; } @@ -267,14 +267,14 @@ void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t) { // CURRENT if (current) { - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN); offset = strlen(current); snprintf(current + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT", TD_DIRSEP); } // CURRENT.t if (current_t) { - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN); offset = strlen(current_t); snprintf(current_t + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT.t", TD_DIRSEP); } @@ -295,26 +295,26 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) { int64_t size; if (taosFStatFile(pFD, &size, NULL) < 0) { code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } pData = taosMemoryMalloc(size); if (pData == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } if (taosReadFile(pFD, pData, size) < 0) { code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } if (!taosCheckChecksumWhole(pData, size)) { code = TSDB_CODE_FILE_CORRUPTED; - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } @@ -326,7 +326,7 @@ _exit: tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname); } taosMemoryFree(pData); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index ff97274097..c3b612b227 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -46,7 +46,7 @@ static int32_t create_fs(STsdb *pTsdb, STFileSystem **fs) { } fs[0]->tsdb = pTsdb; - tsem_init(&fs[0]->canEdit, 0, 1); + (void)tsem_init(&fs[0]->canEdit, 0, 1); fs[0]->fsstate = TSDB_FS_STATE_NORMAL; fs[0]->neid = 0; TARRAY2_INIT(fs[0]->fSetArr); @@ -60,7 +60,7 @@ static int32_t destroy_fs(STFileSystem **fs) { TARRAY2_DESTROY(fs[0]->fSetArr, NULL); TARRAY2_DESTROY(fs[0]->fSetArrTmp, NULL); - tsem_destroy(&fs[0]->canEdit); + (void)tsem_destroy(&fs[0]->canEdit); taosMemoryFree(fs[0]); fs[0] = NULL; return 0; @@ -69,7 +69,7 @@ static int32_t destroy_fs(STFileSystem **fs) { int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype) { int32_t offset = 0; - vnodeGetPrimaryDir(pTsdb->path, pTsdb->pVnode->diskPrimary, pTsdb->pVnode->pTfs, fname, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pTsdb->pVnode->diskPrimary, pTsdb->pVnode->pTfs, fname, TSDB_FILENAME_LEN); offset = strlen(fname); snprintf(fname + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, gCurrentFname[ftype]); @@ -105,7 +105,7 @@ _exit: tsdbError("%s failed at %s:%d since %s", __func__, fname, __LINE__, tstrerror(code)); } taosMemoryFree(data); - taosCloseFile(&fp); + (void)taosCloseFile(&fp); return code; } @@ -144,7 +144,7 @@ _exit: tsdbError("%s failed at %s:%d since %s", __func__, fname, __LINE__, tstrerror(code)); json[0] = NULL; } - taosCloseFile(&fp); + (void)taosCloseFile(&fp); taosMemoryFree(data); return code; } @@ -174,7 +174,7 @@ int32_t save_fs(const TFileSetArray *arr, const char *fname) { if (!item) { TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); } - cJSON_AddItemToArray(ajson, item); + (void)cJSON_AddItemToArray(ajson, item); code = tsdbTFileSetToJson(fset, item); TSDB_CHECK_CODE(code, lino, _exit); @@ -255,7 +255,7 @@ static int32_t apply_commit(STFileSystem *fs) { if (fset1 && fset2) { if (fset1->fid < fset2->fid) { // delete fset1 - tsdbTFileSetRemove(fset1); + (void)tsdbTFileSetRemove(fset1); i1++; } else if (fset1->fid > fset2->fid) { // create new file set with fid of fset2->fid @@ -274,7 +274,7 @@ static int32_t apply_commit(STFileSystem *fs) { } } else if (fset1) { // delete fset1 - tsdbTFileSetRemove(fset1); + (void)tsdbTFileSetRemove(fset1); i1++; } else { // create new file set with fid of fset2->fid @@ -298,11 +298,11 @@ static int32_t commit_edit(STFileSystem *fs) { char current[TSDB_FILENAME_LEN]; char current_t[TSDB_FILENAME_LEN]; - current_fname(fs->tsdb, current, TSDB_FCURRENT); + (void)current_fname(fs->tsdb, current, TSDB_FCURRENT); if (fs->etype == TSDB_FEDIT_COMMIT) { - current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C); + (void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C); } else { - current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M); + (void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M); } int32_t code; @@ -333,9 +333,9 @@ static int32_t abort_edit(STFileSystem *fs) { char fname[TSDB_FILENAME_LEN]; if (fs->etype == TSDB_FEDIT_COMMIT) { - current_fname(fs->tsdb, fname, TSDB_FCURRENT_C); + (void)current_fname(fs->tsdb, fname, TSDB_FCURRENT_C); } else { - current_fname(fs->tsdb, fname, TSDB_FCURRENT_M); + (void)current_fname(fs->tsdb, fname, TSDB_FCURRENT_M); } int32_t code; @@ -368,7 +368,7 @@ static int32_t tsdbFSDoScanAndFixFile(STFileSystem *fs, const STFileObj *fobj) { if (tsS3Enabled && fobj->f->lcn > 1) { char fname1[TSDB_FILENAME_LEN]; - tsdbTFileLastChunkName(fs->tsdb, fobj->f, fname1); + (void)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); @@ -419,7 +419,7 @@ static int32_t tsdbFSCreateFileObjHash(STFileSystem *fs, STFileHash *hash) { } // vnode.json - current_fname(fs->tsdb, fname, TSDB_FCURRENT); + (void)current_fname(fs->tsdb, fname, TSDB_FCURRENT); code = tsdbFSAddEntryToFileObjHash(hash, fname); TSDB_CHECK_CODE(code, lino, _exit); @@ -603,9 +603,9 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) { char cCurrent[TSDB_FILENAME_LEN]; char mCurrent[TSDB_FILENAME_LEN]; - current_fname(pTsdb, fCurrent, TSDB_FCURRENT); - current_fname(pTsdb, cCurrent, TSDB_FCURRENT_C); - current_fname(pTsdb, mCurrent, TSDB_FCURRENT_M); + (void)current_fname(pTsdb, fCurrent, TSDB_FCURRENT); + (void)current_fname(pTsdb, cCurrent, TSDB_FCURRENT_C); + (void)current_fname(pTsdb, mCurrent, TSDB_FCURRENT_M); if (taosCheckExistFile(fCurrent)) { // current.json exists code = load_fs(pTsdb, fCurrent, fs->fSetArr); @@ -744,7 +744,7 @@ int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback) { _exit: if (code) { tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); - destroy_fs(fs); + (void)destroy_fs(fs); } else { tsdbInfo("vgId:%d %s success", TD_VID(pTsdb->pVnode), __func__); } @@ -777,7 +777,7 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { } fset->channel = (SVAChannelID){0}; fset->mergeScheduled = false; - tsdbFSSetBlockCommit(fset, false); + (void)tsdbFSSetBlockCommit(fset, false); fset->channelOpened = false; } } @@ -787,12 +787,12 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { // destroy all channels for (int32_t i = 0; i < taosArrayGetSize(channelArray); i++) { SVAChannelID *channel = taosArrayGet(channelArray, i); - vnodeAChannelDestroy(channel, true); + (void)vnodeAChannelDestroy(channel, true); } taosArrayDestroy(channelArray); #ifdef TD_ENTERPRISE - tsdbStopAllCompTask(pTsdb); + (void)tsdbStopAllCompTask(pTsdb); #endif return 0; } @@ -807,9 +807,9 @@ int32_t tsdbEnableBgTask(STsdb *pTsdb) { int32_t tsdbCloseFS(STFileSystem **fs) { if (fs[0] == NULL) return 0; - tsdbDisableAndCancelAllBgTask((*fs)->tsdb); - close_file_system(fs[0]); - destroy_fs(fs); + (void)tsdbDisableAndCancelAllBgTask((*fs)->tsdb); + (void)close_file_system(fs[0]); + (void)destroy_fs(fs); return 0; } @@ -832,12 +832,12 @@ int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT e char current_t[TSDB_FILENAME_LEN]; if (etype == TSDB_FEDIT_COMMIT) { - current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C); + (void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_C); } else { - current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M); + (void)current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M); } - tsem_wait(&fs->canEdit); + (void)tsem_wait(&fs->canEdit); fs->etype = etype; // edit @@ -864,7 +864,7 @@ static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block) { } else { fset->blockCommit = false; if (fset->numWaitCommit > 0) { - taosThreadCondSignal(&fset->canCommit); + (void)taosThreadCondSignal(&fset->canCommit); } } return 0; @@ -873,11 +873,11 @@ static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block) { int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) { (void)taosThreadMutexLock(&tsdb->mutex); STFileSet *fset; - tsdbFSGetFSet(tsdb->pFS, fid, &fset); + (void)tsdbFSGetFSet(tsdb->pFS, fid, &fset); if (fset) { while (fset->blockCommit) { fset->numWaitCommit++; - taosThreadCondWait(&fset->canCommit, &tsdb->mutex); + (void)taosThreadCondWait(&fset->canCommit, &tsdb->mutex); fset->numWaitCommit--; } } @@ -901,13 +901,13 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) { STFileSet *fset; TARRAY2_FOREACH_REVERSE(fs->fSetArr, fset) { if (TARRAY2_SIZE(fset->lvlArr) == 0) { - tsdbFSSetBlockCommit(fset, false); + (void)tsdbFSSetBlockCommit(fset, false); continue; } SSttLvl *lvl = TARRAY2_FIRST(fset->lvlArr); if (lvl->level != 0) { - tsdbFSSetBlockCommit(fset, false); + (void)tsdbFSSetBlockCommit(fset, false); continue; } @@ -932,9 +932,9 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) { } if (numFile >= sttTrigger * BLOCK_COMMIT_FACTOR) { - tsdbFSSetBlockCommit(fset, true); + (void)tsdbFSSetBlockCommit(fset, true); } else { - tsdbFSSetBlockCommit(fset, false); + (void)tsdbFSSetBlockCommit(fset, false); } } } @@ -945,13 +945,13 @@ _exit: } else { tsdbInfo("vgId:%d %s done, etype:%d", TD_VID(fs->tsdb->pVnode), __func__, fs->etype); } - tsem_post(&fs->canEdit); + (void)tsem_post(&fs->canEdit); return code; } int32_t tsdbFSEditAbort(STFileSystem *fs) { int32_t code = abort_edit(fs); - tsem_post(&fs->canEdit); + (void)tsem_post(&fs->canEdit); return code; } @@ -1163,7 +1163,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev (void)taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { - tsdbTFileSetRangeClear(&fsr1); + (void)tsdbTFileSetRangeClear(&fsr1); TARRAY2_DESTROY(fsrArr[0], tsdbTFileSetRangeClear); fsrArr[0] = NULL; } @@ -1181,15 +1181,15 @@ int32_t tsdbFSDestroyRefRangedSnapshot(TFileSetRangeArray **fsrArr) { return tsd int32_t tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset) { int16_t sttTrigger = tsdb->pVnode->config.sttTrigger; - tsdbFSGetFSet(tsdb->pFS, fid, fset); + (void)tsdbFSGetFSet(tsdb->pFS, fid, fset); if (sttTrigger == 1 && (*fset)) { for (;;) { if ((*fset)->taskRunning) { (*fset)->numWaitTask++; - taosThreadCondWait(&(*fset)->beginTask, &tsdb->mutex); + (void)taosThreadCondWait(&(*fset)->beginTask, &tsdb->mutex); - tsdbFSGetFSet(tsdb->pFS, fid, fset); + (void)tsdbFSGetFSet(tsdb->pFS, fid, fset); ASSERT(fset != NULL); (*fset)->numWaitTask--; @@ -1209,11 +1209,11 @@ int32_t tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) { int16_t sttTrigger = tsdb->pVnode->config.sttTrigger; if (sttTrigger == 1) { STFileSet *fset = NULL; - tsdbFSGetFSet(tsdb->pFS, fid, &fset); + (void)tsdbFSGetFSet(tsdb->pFS, fid, &fset); if (fset != NULL && fset->taskRunning) { fset->taskRunning = false; if (fset->numWaitTask > 0) { - taosThreadCondSignal(&fset->beginTask); + (void)taosThreadCondSignal(&fset->beginTask); } tsdbInfo("vgId:%d finish task on file set:%d", TD_VID(tsdb->pVnode), fid); } diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.c b/source/dnode/vnode/src/tsdb/tsdbFSet2.c index 305ce6b56f..78e1a6a13d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.c @@ -45,7 +45,7 @@ static int32_t tsdbSttLvlInitEx(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lvl STFileObj *fobj; code = tsdbTFileObjInit(pTsdb, fobj1->f, &fobj); if (code) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return code; } @@ -61,7 +61,7 @@ static int32_t tsdbSttLvlInitRef(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lv STFileObj *fobj1; TARRAY2_FOREACH(lvl1->fobjArr, fobj1) { - tsdbTFileObjRef(fobj1); + (void)tsdbTFileObjRef(fobj1); code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj1); if (code) return code; } @@ -79,7 +79,7 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64 STFileObj *fobj; code = tsdbTFileObjInit(pTsdb, fobj1->f, &fobj); if (code) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return code; } @@ -96,7 +96,7 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64 return 0; } -static void tsdbSttLvlRemoveFObj(void *data) { tsdbTFileObjRemove(*(STFileObj **)data); } +static void tsdbSttLvlRemoveFObj(void *data) { (void)tsdbTFileObjRemove(*(STFileObj **)data); } static void tsdbSttLvlRemove(SSttLvl **lvl) { TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlRemoveFObj); taosMemoryFree(lvl[0]); @@ -173,7 +173,7 @@ static int32_t tsdbSttLvlToJson(const SSttLvl *lvl, cJSON *json) { TARRAY2_FOREACH(lvl->fobjArr, fobj) { cJSON *item = cJSON_CreateObject(); if (item == NULL) return TSDB_CODE_OUT_OF_MEMORY; - cJSON_AddItemToArray(ajson, item); + (void)cJSON_AddItemToArray(ajson, item); int32_t code = tsdbTFileToJson(fobj->f, item); if (code) return code; @@ -198,7 +198,7 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl) item1 = cJSON_GetObjectItem(json, "files"); if (!cJSON_IsArray(item1)) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return TSDB_CODE_FILE_CORRUPTED; } @@ -206,14 +206,14 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl) STFile tf; code = tsdbJsonToTFile(item2, TSDB_FTYPE_STT, &tf); if (code) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return code; } STFileObj *fobj; code = tsdbTFileObjInit(pTsdb, &tf, &fobj); if (code) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return code; } @@ -247,7 +247,7 @@ int32_t tsdbTFileSetToJson(const STFileSet *fset, cJSON *json) { TARRAY2_FOREACH(fset->lvlArr, lvl) { item2 = cJSON_CreateObject(); if (!item2) return TSDB_CODE_OUT_OF_MEMORY; - cJSON_AddItemToArray(item1, item2); + (void)cJSON_AddItemToArray(item1, item2); code = tsdbSttLvlToJson(lvl, item2); if (code) return code; @@ -347,7 +347,7 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) { TARRAY2_REMOVE(lvl->fobjArr, idx, tsdbSttLvlClearFObj); } else { ASSERT(tsdbIsSameTFile(&op->of, fset->farr[op->of.type]->f)); - tsdbTFileObjUnref(fset->farr[op->of.type]); + (void)tsdbTFileObjUnref(fset->farr[op->of.type]); fset->farr[op->of.type] = NULL; } } else { @@ -389,9 +389,9 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f } } else { if (fobj1->f->cid != fobj2->f->cid) { - tsdbTFileObjRemove(fobj2); + (void)tsdbTFileObjRemove(fobj2); } else { - tsdbTFileObjRemoveUpdateLC(fobj2); + (void)tsdbTFileObjRemoveUpdateLC(fobj2); } code = tsdbTFileObjInit(pTsdb, fobj1->f, &fset2->farr[ftype]); if (code) return code; @@ -402,7 +402,7 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f if (code) return code; } else { // remove the file - tsdbTFileObjRemove(fobj2); + (void)tsdbTFileObjRemove(fobj2); fset2->farr[ftype] = NULL; } } @@ -460,12 +460,12 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset) { TARRAY2_INIT(fset[0]->lvlArr); // background task queue - taosThreadCondInit(&(*fset)->beginTask, NULL); + (void)taosThreadCondInit(&(*fset)->beginTask, NULL); (*fset)->taskRunning = false; (*fset)->numWaitTask = 0; // block commit variables - taosThreadCondInit(&fset[0]->canCommit, NULL); + (void)taosThreadCondInit(&fset[0]->canCommit, NULL); (*fset)->numWaitCommit = 0; (*fset)->blockCommit = false; @@ -522,7 +522,8 @@ int32_t tsdbTFileSetFilteredInitDup(STsdb *pTsdb, const STFileSet *fset1, int64_ .fid = fobj->f->fid, .of = fobj->f[0], }; - TARRAY2_APPEND(fopArr, op); + code = TARRAY2_APPEND(fopArr, op); + if (code) return code; } } @@ -567,7 +568,7 @@ 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; - tsdbTFileObjRef(fset1->farr[ftype]); + (void)tsdbTFileObjRef(fset1->farr[ftype]); fset[0]->farr[ftype] = fset1->farr[ftype]; } @@ -609,13 +610,13 @@ 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; - tsdbTFileObjUnref((*fset)->farr[ftype]); + (void)tsdbTFileObjUnref((*fset)->farr[ftype]); } TARRAY2_DESTROY((*fset)->lvlArr, tsdbSttLvlClear); - taosThreadCondDestroy(&(*fset)->beginTask); - taosThreadCondDestroy(&(*fset)->canCommit); + (void)taosThreadCondDestroy(&(*fset)->beginTask); + (void)taosThreadCondDestroy(&(*fset)->canCommit); taosMemoryFreeClear(*fset); } } @@ -625,7 +626,7 @@ int32_t tsdbTFileSetRemove(STFileSet *fset) { for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if (fset->farr[ftype] != NULL) { - tsdbTFileObjRemove(fset->farr[ftype]); + (void)tsdbTFileObjRemove(fset->farr[ftype]); fset->farr[ftype] = NULL; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbFSetRW.c b/source/dnode/vnode/src/tsdb/tsdbFSetRW.c index 77d8998aa7..3ccf833ddd 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSetRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSetRW.c @@ -44,7 +44,7 @@ static int32_t tsdbFSetWriteTableDataBegin(SFSetWriter *writer, const TABLEID *t writer->ctx->tbid->uid = tbid->uid; code = tsdbUpdateSkmTb(writer->config->tsdb, writer->ctx->tbid, writer->skmTb); - TSDB_CHECK_CODE(code , lino, _exit); + TSDB_CHECK_CODE(code, lino, _exit); code = metaGetColCmpr(writer->config->tsdb->pVnode->pMeta, tbid->suid ? tbid->suid : tbid->uid, &writer->pColCmprObj); // TODO: TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 243ff662f7..cf88f9a066 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -221,7 +221,7 @@ void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]) { int32_t offset = 0; SVnode *pVnode = pTsdb->pVnode; - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, fname, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, fname, TSDB_FILENAME_LEN); offset = strlen(fname); snprintf((char *)fname + offset, TSDB_FILENAME_LEN - offset - 1, "%sv%dver%" PRId64 ".del", TD_DIRSEP, TD_VID(pTsdb->pVnode), pFile->commitID); diff --git a/source/dnode/vnode/src/tsdb/tsdbIter.c b/source/dnode/vnode/src/tsdb/tsdbIter.c index 3b5bd6d02f..0de9ba9822 100644 --- a/source/dnode/vnode/src/tsdb/tsdbIter.c +++ b/source/dnode/vnode/src/tsdb/tsdbIter.c @@ -224,7 +224,7 @@ static int32_t tsdbMemTableIterNext(STsdbIter *iter, const TABLEID *tbid) { iter->row->row = row[0]; - tsdbTbDataIterNext(iter->memtData->tbIter); + (void)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 3114c0fa04..d8ec014985 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -410,7 +410,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid pMemTable->aBucket[idx] = pTbData; pMemTable->nTbData++; - tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn); + (void)tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn); taosWUnLockLatch(&pMemTable->latch); @@ -742,7 +742,7 @@ int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode) { int32_t nRef = atomic_fetch_add_32(&pMemTable->nRef, 1); ASSERT(nRef > 0); - vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode); + (void)vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode); _exit: return code; diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index 7b40290c05..1bbda8a249 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -215,7 +215,7 @@ static int32_t tsdbMergeFileSetBeginOpenReader(SMerger *merger) { TAOS_CHECK_GOTO(tsdbSttFileReaderOpen(fobj->fname, &config, &reader), &lino, _exit); if ((code = TARRAY2_APPEND(merger->sttReaderArr, reader))) { - tsdbSttFileReaderClose(&reader); + (void)tsdbSttFileReaderClose(&reader); TSDB_CHECK_CODE(code, lino, _exit); } } @@ -230,7 +230,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(merger->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); - tsdbMergeFileSetEndCloseReader(merger); + (void)tsdbMergeFileSetEndCloseReader(merger); } return code; } @@ -282,7 +282,7 @@ static int32_t tsdbMergeFileSetBeginOpenWriter(SMerger *merger) { TAOS_CHECK_GOTO(tfsAllocDisk(merger->tsdb->pVnode->pTfs, level, &did), &lino, _exit); - tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did); + (void)tfsMkdirRecurAt(merger->tsdb->pVnode->pTfs, merger->tsdb->path, did); SFSetWriterConfig config = { .tsdb = merger->tsdb, .toSttOnly = true, @@ -355,9 +355,9 @@ static int32_t tsdbMergeFileSetEndCloseWriter(SMerger *merger) { } static int32_t tsdbMergeFileSetEndCloseIter(SMerger *merger) { - tsdbIterMergerClose(&merger->tombIterMerger); + (void)tsdbIterMergerClose(&merger->tombIterMerger); TARRAY2_CLEAR(merger->tombIterArr, tsdbIterClose); - tsdbIterMergerClose(&merger->dataIterMerger); + (void)tsdbIterMergerClose(&merger->dataIterMerger); TARRAY2_CLEAR(merger->dataIterArr, tsdbIterClose); return 0; } @@ -479,7 +479,7 @@ static int32_t tsdbMergeGetFSet(SMerger *merger) { STFileSet *fset; (void)taosThreadMutexLock(&merger->tsdb->mutex); - tsdbFSGetFSet(merger->tsdb->pFS, merger->fid, &fset); + (void)tsdbFSGetFSet(merger->tsdb->pFS, merger->fid, &fset); if (fset == NULL) { (void)taosThreadMutexUnlock(&merger->tsdb->mutex); return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 370d847a33..996b1a6425 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -57,18 +57,18 @@ int32_t tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg * snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); // taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; - taosThreadMutexInit(&pTsdb->mutex, NULL); + (void)taosThreadMutexInit(&pTsdb->mutex, NULL); if (!pKeepCfg) { - tsdbSetKeepCfg(pTsdb, &pVnode->config.tsdbCfg); + (void)tsdbSetKeepCfg(pTsdb, &pVnode->config.tsdbCfg); } else { memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg)); } // create dir if (pVnode->pTfs) { - tfsMkdir(pVnode->pTfs, pTsdb->path); + (void)tfsMkdir(pVnode->pTfs, pTsdb->path); } else { - taosMkDir(pTsdb->path); + (void)taosMkDir(pTsdb->path); } // open tsdb @@ -87,8 +87,8 @@ 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)); - tsdbCloseFS(&pTsdb->pFS); - taosThreadMutexDestroy(&pTsdb->mutex); + (void)tsdbCloseFS(&pTsdb->pFS); + (void)taosThreadMutexDestroy(&pTsdb->mutex); taosMemoryFree(pTsdb); } else { tsdbDebug("vgId:%d, tsdb is opened at %s, days:%d, keep:%d,%d,%d, keepTimeoffset:%d", TD_VID(pVnode), pTsdb->path, @@ -110,12 +110,12 @@ int32_t tsdbClose(STsdb **pTsdb) { (*pTsdb)->mem = NULL; (void)taosThreadMutexUnlock(&(*pTsdb)->mutex); - tsdbCloseFS(&(*pTsdb)->pFS); + (void)tsdbCloseFS(&(*pTsdb)->pFS); tsdbCloseCache(*pTsdb); #ifdef TD_ENTERPRISE - tsdbCloseCompMonitor(*pTsdb); + (void)tsdbCloseCompMonitor(*pTsdb); #endif - taosThreadMutexDestroy(&(*pTsdb)->mutex); + (void)taosThreadMutexDestroy(&(*pTsdb)->mutex); taosMemoryFreeClear(*pTsdb); } return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index a3210dbfd9..4fedb68a78 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -48,7 +48,7 @@ typedef struct { static int32_t getCurrentBlockInfo(SDataBlockIter* pBlockIter, SFileDataBlockInfo** pInfo); static int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity, STsdbReader* pReader); -static int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes); +static void getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes); static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, SRowKey* pKey, STsdbReader* pReader); static int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, @@ -3866,11 +3866,11 @@ bool hasBeenDropped(const SArray* pDelList, int32_t* index, int64_t key, int64_t return false; } -FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes) { +FORCE_INLINE void getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader, TSDBROW** pRes) { *pRes = NULL; if (!pIter->hasVal) { - return TSDB_CODE_SUCCESS; + return; } int32_t order = pReader->info.order; @@ -3880,20 +3880,20 @@ FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, ST TSDBROW_INIT_KEY(pRow, key); if (outOfTimeWindow(key.ts, &pReader->info.window)) { pIter->hasVal = false; - return TSDB_CODE_SUCCESS; + return; } // it is a valid data version if (key.version <= pReader->info.verRange.maxVer && key.version >= pReader->info.verRange.minVer) { if (pDelList == NULL || TARRAY_SIZE(pDelList) == 0) { *pRes = pRow; - return TSDB_CODE_SUCCESS; + return; } else { bool dropped = hasBeenDropped(pDelList, &pIter->index, key.ts, key.version, order, &pReader->info.verRange, pReader->suppInfo.numOfPks > 0); if (!dropped) { *pRes = pRow; - return TSDB_CODE_SUCCESS; + return; } } } @@ -3901,7 +3901,7 @@ FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, ST while (1) { pIter->hasVal = tsdbTbDataIterNext(pIter->iter); if (!pIter->hasVal) { - return TSDB_CODE_SUCCESS; + return; } pRow = tsdbTbDataIterGet(pIter->iter); @@ -3909,19 +3909,19 @@ FORCE_INLINE int32_t getValidMemRow(SIterInfo* pIter, const SArray* pDelList, ST TSDBROW_INIT_KEY(pRow, key); if (outOfTimeWindow(key.ts, &pReader->info.window)) { pIter->hasVal = false; - return TSDB_CODE_SUCCESS; + return; } if (key.version <= pReader->info.verRange.maxVer && key.version >= pReader->info.verRange.minVer) { if (pDelList == NULL || TARRAY_SIZE(pDelList) == 0) { *pRes = pRow; - return TSDB_CODE_SUCCESS; + return; } else { bool dropped = hasBeenDropped(pDelList, &pIter->index, key.ts, key.version, order, &pReader->info.verRange, pReader->suppInfo.numOfPks > 0); if (!dropped) { *pRes = pRow; - return TSDB_CODE_SUCCESS; + return; } } } diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 28abed1ce7..8e52074807 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -35,7 +35,7 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) { int32_t vid = 0; const char *object_name = taosDirEntryBaseName((char *)path); - sscanf(object_name, "v%df%dver%" PRId64 ".data", &vid, &pFD->fid, &pFD->cid); + (void)sscanf(object_name, "v%df%dver%" PRId64 ".data", &vid, &pFD->fid, &pFD->cid); char *dot = strrchr(lc_path, '.'); if (!dot) { @@ -124,7 +124,7 @@ void tsdbCloseFile(STsdbFD **ppFD) { if (pFD) { taosMemoryFree(pFD->pBuf); // if (!pFD->s3File) { - taosCloseFile(&pFD->pFD); + (void)taosCloseFile(&pFD->pFD); //} taosMemoryFree(pFD); *ppFD = NULL; @@ -156,7 +156,7 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit); } - taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage); + (void)taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage); if (encryptAlgorithm == DND_CA_SM4) { // if(tsiEncryptAlgorithm == DND_CA_SM4 && (tsiEncryptScope & DND_CS_TSDB) == DND_CS_TSDB){ @@ -430,7 +430,7 @@ static int32_t tsdbReadFileS3(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64 code = tsdbCacheGetPageS3(pFD->pTsdb->pgCache, pFD, pgno, &handle); if (code != TSDB_CODE_SUCCESS) { if (handle) { - tsdbCacheRelease(pFD->pTsdb->pgCache, handle); + (void)tsdbCacheRelease(pFD->pTsdb->pgCache, handle); } TSDB_CHECK_CODE(code, lino, _exit); } @@ -441,7 +441,7 @@ static int32_t tsdbReadFileS3(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64 uint8_t *pPage = (uint8_t *)taosLRUCacheValue(pFD->pTsdb->pgCache, handle); memcpy(pFD->pBuf, pPage, pFD->szPage); - tsdbCacheRelease(pFD->pTsdb->pgCache, handle); + (void)tsdbCacheRelease(pFD->pTsdb->pgCache, handle); // check if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) { @@ -477,7 +477,7 @@ static int32_t tsdbReadFileS3(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64 int nPage = pgnoEnd - pgno + 1; for (int i = 0; i < nPage; ++i) { if (pFD->szFile != pgno) { // DONOT cache last volatile page - tsdbCacheSetPageS3(pFD->pTsdb->pgCache, pFD, pgno, pBlock + i * pFD->szPage); + (void)tsdbCacheSetPageS3(pFD->pTsdb->pgCache, pFD, pgno, pBlock + i * pFD->szPage); } if (szHint > 0 && n >= size) { diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index a454f09e22..bdd174a8f8 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]; - tsdbTFileLastChunkName(rtner->tsdb, from->f, fname_from); - tsdbTFileLastChunkName(rtner->tsdb, to, fname_to); + (void)tsdbTFileLastChunkName(rtner->tsdb, from->f, fname_from); + (void)tsdbTFileLastChunkName(rtner->tsdb, to, fname_to); fdFrom = taosOpenFile(fname_from, TD_FILE_READ); if (fdFrom == NULL) { @@ -99,8 +99,8 @@ _exit: tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - taosCloseFile(&fdFrom); - taosCloseFile(&fdTo); + (void)taosCloseFile(&fdFrom); + (void)taosCloseFile(&fdTo); return code; } @@ -112,7 +112,7 @@ static int32_t tsdbDoCopyFile(SRTNer *rtner, const STFileObj *from, const STFile TdFilePtr fdFrom = NULL; TdFilePtr fdTo = NULL; - tsdbTFileName(rtner->tsdb, to, fname); + (void)tsdbTFileName(rtner->tsdb, to, fname); fdFrom = taosOpenFile(from->fname, TD_FILE_READ); if (fdFrom == NULL) { @@ -136,8 +136,8 @@ _exit: tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - taosCloseFile(&fdFrom); - taosCloseFile(&fdTo); + (void)taosCloseFile(&fdFrom); + (void)taosCloseFile(&fdTo); return code; } @@ -255,7 +255,7 @@ static int32_t tsdbDoRetention(SRTNer *rtner) { SDiskID did; TAOS_CHECK_GOTO(tfsAllocDisk(rtner->tsdb->pVnode->pTfs, expLevel, &did), &lino, _exit); - tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did); + (void)tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did); // data for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX && (fobj = fset->farr[ftype], 1); ++ftype) { @@ -316,7 +316,7 @@ static int32_t tsdbRetention(void *arg) { // begin task (void)taosThreadMutexLock(&pTsdb->mutex); - tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset); + (void)tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset); if (fset && (code = tsdbTFileSetInitCopy(pTsdb, fset, &rtner.fset))) { (void)taosThreadMutexUnlock(&pTsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); @@ -337,7 +337,7 @@ static int32_t tsdbRetention(void *arg) { _exit: if (rtner.fset) { (void)taosThreadMutexLock(&pTsdb->mutex); - tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid); + (void)tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid); (void)taosThreadMutexUnlock(&pTsdb->mutex); } @@ -427,7 +427,7 @@ static int32_t tsdbCopyFileS3(SRTNer *rtner, const STFileObj *from, const STFile TdFilePtr fdFrom = NULL; // TdFilePtr fdTo = NULL; - tsdbTFileName(rtner->tsdb, to, fname); + (void)tsdbTFileName(rtner->tsdb, to, fname); fdFrom = taosOpenFile(from->fname, TD_FILE_READ); if (fdFrom == NULL) { @@ -442,7 +442,7 @@ _exit: tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - taosCloseFile(&fdFrom); + (void)taosCloseFile(&fdFrom); return code; } @@ -486,7 +486,7 @@ static int32_t tsdbMigrateDataFileLCS3(SRTNer *rtner, const STFileObj *fobj, int TAOS_CHECK_GOTO(TARRAY2_APPEND(&rtner->fopArr, op), &lino, _exit); char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(rtner->tsdb, &op.nf, fname); + (void)tsdbTFileName(rtner->tsdb, &op.nf, fname); char *object_name = taosDirEntryBaseName(fname); char object_name_prefix[TSDB_FILENAME_LEN]; int32_t node_id = vnodeNodeId(rtner->tsdb->pVnode); @@ -542,8 +542,8 @@ _exit: tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - taosCloseFile(&fdFrom); - taosCloseFile(&fdTo); + (void)taosCloseFile(&fdFrom); + (void)taosCloseFile(&fdTo); return code; } @@ -587,7 +587,7 @@ static int32_t tsdbMigrateDataFileS3(SRTNer *rtner, const STFileObj *fobj, int64 TAOS_CHECK_GOTO(TARRAY2_APPEND(&rtner->fopArr, op), &lino, _exit); char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(rtner->tsdb, &op.nf, fname); + (void)tsdbTFileName(rtner->tsdb, &op.nf, fname); char *object_name = taosDirEntryBaseName(fname); char object_name_prefix[TSDB_FILENAME_LEN]; int32_t node_id = vnodeNodeId(rtner->tsdb->pVnode); @@ -640,8 +640,8 @@ _exit: tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - taosCloseFile(&fdFrom); - taosCloseFile(&fdTo); + (void)taosCloseFile(&fdFrom); + (void)taosCloseFile(&fdTo); return code; } @@ -673,7 +673,7 @@ static int32_t tsdbDoS3Migrate(SRTNer *rtner) { if (/*lcn < 1 && */ taosCheckExistFile(fobj->fname)) { int32_t mtime = 0; int64_t size = 0; - taosStatFile(fobj->fname, &size, &mtime, NULL); + (void)taosStatFile(fobj->fname, &size, &mtime, NULL); if (size > chunksize && mtime < rtner->now - tsS3UploadDelaySec) { if (pCfg->s3Compact && lcn < 0) { extern int32_t tsdbAsyncCompact(STsdb * tsdb, const STimeWindow *tw, bool sync); @@ -695,12 +695,12 @@ static int32_t tsdbDoS3Migrate(SRTNer *rtner) { TAOS_CHECK_GOTO(TSDB_CODE_INVALID_PARA, &lino, _exit); } char fname1[TSDB_FILENAME_LEN]; - tsdbTFileLastChunkName(rtner->tsdb, fobj->f, fname1); + (void)tsdbTFileLastChunkName(rtner->tsdb, fobj->f, fname1); if (taosCheckExistFile(fname1)) { int32_t mtime = 0; int64_t size = 0; - taosStatFile(fname1, &size, &mtime, NULL); + (void)taosStatFile(fname1, &size, &mtime, NULL); if (size > chunksize && mtime < rtner->now - tsS3UploadDelaySec) { TAOS_CHECK_GOTO(tsdbMigrateDataFileLCS3(rtner, fobj, size, chunksize), &lino, _exit); } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c index c9e02c5130..decf276bc6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c @@ -196,7 +196,7 @@ int32_t tsdbFSetPartListToRangeDiff(STsdbFSetPartList* pList, TFileSetRangeArray _err: if (pDiff) { - tsdbTFileSetRangeArrayDestroy(&pDiff); + (void)tsdbTFileSetRangeArrayDestroy(&pDiff); } return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 3edff5ebcb..2b63d5b6e6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -59,7 +59,7 @@ struct STsdbSnapReader { static int32_t tsdbSnapReadFileSetCloseReader(STsdbSnapReader* reader) { TARRAY2_CLEAR(reader->sttReaderArr, tsdbSttFileReaderClose); - tsdbDataFileReaderClose(&reader->dataReader); + TAOS_UNUSED(tsdbDataFileReaderClose(&reader->dataReader)); return 0; } @@ -107,7 +107,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) { TSDB_CHECK_CODE(code, lino, _exit); if ((code = TARRAY2_APPEND(reader->sttReaderArr, sttReader))) { - tsdbSttFileReaderClose(&sttReader); + TAOS_UNUSED(tsdbSttFileReaderClose(&sttReader)); TSDB_CHECK_CODE(code, lino, _exit); } } @@ -115,7 +115,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) { _exit: if (code) { - tsdbSnapReadFileSetCloseReader(reader); + TAOS_UNUSED(tsdbSnapReadFileSetCloseReader(reader)); TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino); } return code; @@ -199,8 +199,8 @@ _exit: } static int32_t tsdbSnapReadFileSetCloseIter(STsdbSnapReader* reader) { - tsdbIterMergerClose(&reader->dataIterMerger); - tsdbIterMergerClose(&reader->tombIterMerger); + TAOS_UNUSED(tsdbIterMergerClose(&reader->dataIterMerger)); + TAOS_UNUSED(tsdbIterMergerClose(&reader->tombIterMerger)); TARRAY2_CLEAR(reader->dataIterArr, tsdbIterClose); TARRAY2_CLEAR(reader->tombIterArr, tsdbIterClose); return 0; @@ -232,8 +232,8 @@ _exit: } static int32_t tsdbSnapReadRangeEnd(STsdbSnapReader* reader) { - tsdbSnapReadFileSetCloseIter(reader); - tsdbSnapReadFileSetCloseReader(reader); + TAOS_UNUSED(tsdbSnapReadFileSetCloseIter(reader)); + TAOS_UNUSED(tsdbSnapReadFileSetCloseReader(reader)); reader->ctx->fsr = NULL; return 0; } @@ -384,7 +384,7 @@ static int32_t tsdbSnapReadTombData(STsdbSnapReader* reader, uint8_t** data) { int32_t lino = 0; SMetaInfo info; - tTombBlockClear(reader->tombBlock); + TAOS_UNUSED(tTombBlockClear(reader->tombBlock)); TABLEID tbid[1] = {0}; for (STombRecord* record; (record = tsdbIterMergerGetTombRecord(reader->tombIterMerger)) != NULL;) { @@ -441,7 +441,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s, sver:%" PRId64 " ever:%" PRId64 " type:%d", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code), sver, ever, type); - tsdbTFileSetRangeArrayDestroy(&reader[0]->fsrArr); + TAOS_UNUSED(tsdbTFileSetRangeArrayDestroy(&reader[0]->fsrArr)); taosMemoryFree(reader[0]); reader[0] = NULL; } else { @@ -460,21 +460,21 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** reader) { STsdb* tsdb = reader[0]->tsdb; - tTombBlockDestroy(reader[0]->tombBlock); + TAOS_UNUSED(tTombBlockDestroy(reader[0]->tombBlock)); tBlockDataDestroy(reader[0]->blockData); - tsdbIterMergerClose(&reader[0]->dataIterMerger); - tsdbIterMergerClose(&reader[0]->tombIterMerger); + TAOS_UNUSED(tsdbIterMergerClose(&reader[0]->dataIterMerger)); + TAOS_UNUSED(tsdbIterMergerClose(&reader[0]->tombIterMerger)); TARRAY2_DESTROY(reader[0]->dataIterArr, tsdbIterClose); TARRAY2_DESTROY(reader[0]->tombIterArr, tsdbIterClose); TARRAY2_DESTROY(reader[0]->sttReaderArr, tsdbSttFileReaderClose); - tsdbDataFileReaderClose(&reader[0]->dataReader); + TAOS_UNUSED(tsdbDataFileReaderClose(&reader[0]->dataReader)); - tsdbFSDestroyRefRangedSnapshot(&reader[0]->fsrArr); + TAOS_UNUSED(tsdbFSDestroyRefRangedSnapshot(&reader[0]->fsrArr)); tDestroyTSchema(reader[0]->skmTb->pTSchema); for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->buffers); ++i) { - tBufferDestroy(reader[0]->buffers + i); + TAOS_UNUSED(tBufferDestroy(reader[0]->buffers + i)); } taosMemoryFree(reader[0]); @@ -706,7 +706,7 @@ _exit: static int32_t tsdbSnapWriteFileSetCloseReader(STsdbSnapWriter* writer) { TARRAY2_CLEAR(writer->ctx->sttReaderArr, tsdbSttFileReaderClose); - tsdbDataFileReaderClose(&writer->ctx->dataReader); + TAOS_UNUSED(tsdbDataFileReaderClose(&writer->ctx->dataReader)); return 0; } @@ -782,8 +782,8 @@ _exit: } static int32_t tsdbSnapWriteFileSetCloseIter(STsdbSnapWriter* writer) { - tsdbIterMergerClose(&writer->ctx->dataIterMerger); - tsdbIterMergerClose(&writer->ctx->tombIterMerger); + TAOS_UNUSED(tsdbIterMergerClose(&writer->ctx->dataIterMerger)); + TAOS_UNUSED(tsdbIterMergerClose(&writer->ctx->tombIterMerger)); TARRAY2_CLEAR(writer->ctx->dataIterArr, tsdbIterClose); TARRAY2_CLEAR(writer->ctx->tombIterArr, tsdbIterClose); return 0; @@ -838,7 +838,7 @@ static int32_t tsdbSnapWriteFileSetBegin(STsdbSnapWriter* writer, int32_t fid) { code = TSDB_CODE_NO_AVAIL_DISK; TSDB_CHECK_CODE(code, lino, _exit); } - tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); + TAOS_UNUSED(tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did)); writer->ctx->hasData = true; writer->ctx->hasTomb = true; @@ -993,7 +993,7 @@ static int32_t tsdbSnapWriteDecmprTombBlock(SSnapDataHdr* hdr, STombBlock* tombB int32_t code = 0; int32_t lino = 0; - tTombBlockClear(tombBlock); + TAOS_UNUSED(tTombBlockClear(tombBlock)); int64_t size = hdr->size; ASSERT(size % TOMB_RECORD_ELEM_NUM == 0); @@ -1140,15 +1140,15 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) { (void)taosThreadMutexUnlock(&writer[0]->tsdb->mutex); } - tsdbIterMergerClose(&writer[0]->ctx->tombIterMerger); - tsdbIterMergerClose(&writer[0]->ctx->dataIterMerger); + TAOS_UNUSED(tsdbIterMergerClose(&writer[0]->ctx->tombIterMerger)); + TAOS_UNUSED(tsdbIterMergerClose(&writer[0]->ctx->dataIterMerger)); TARRAY2_DESTROY(writer[0]->ctx->tombIterArr, tsdbIterClose); TARRAY2_DESTROY(writer[0]->ctx->dataIterArr, tsdbIterClose); TARRAY2_DESTROY(writer[0]->ctx->sttReaderArr, tsdbSttFileReaderClose); - tsdbDataFileReaderClose(&writer[0]->ctx->dataReader); + TAOS_UNUSED(tsdbDataFileReaderClose(&writer[0]->ctx->dataReader)); TARRAY2_DESTROY(writer[0]->fopArr, NULL); - tsdbFSDestroyCopyRangedSnapshot(&writer[0]->fsetArr); + TAOS_UNUSED(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 ac6507ac7f..5b69638b36 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c @@ -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); - tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); + (void)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); - tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); + (void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); taosMemoryFree(reader[0]); reader[0] = NULL; @@ -141,7 +141,7 @@ static int32_t tsdbSnapRAWReadFileSetOpenReader(STsdbSnapRAWReader* reader) { _exit: if (code) { - tsdbSnapRAWReadFileSetCloseReader(reader); + (void)tsdbSnapRAWReadFileSetCloseReader(reader); TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino); } return code; @@ -268,8 +268,8 @@ _exit: } static int32_t tsdbSnapRAWReadEnd(STsdbSnapRAWReader* reader) { - tsdbSnapRAWReadFileSetCloseIter(reader); - tsdbSnapRAWReadFileSetCloseReader(reader); + (void)tsdbSnapRAWReadFileSetCloseIter(reader); + (void)tsdbSnapRAWReadFileSetCloseReader(reader); reader->ctx->fset = NULL; return 0; } @@ -420,7 +420,7 @@ 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); - tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); + (void)tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); code = tsdbSnapRAWWriteFileSetOpenWriter(writer); TSDB_CHECK_CODE(code, lino, _exit); @@ -499,7 +499,7 @@ int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** writer, int8_t rollback) { } TARRAY2_DESTROY(writer[0]->fopArr, NULL); - tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr); + (void)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 d39adaac41..6e24311017 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -55,7 +55,7 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con TAOS_CHECK_GOTO(tsdbOpenFile(fname, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit); } else { char fname1[TSDB_FILENAME_LEN]; - tsdbTFileName(config->tsdb, config->file, fname1); + (void)tsdbTFileName(config->tsdb, config->file, fname1); TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit); } @@ -91,7 +91,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(config->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); - tsdbSttFileReaderClose(reader); + (void)tsdbSttFileReaderClose(reader); } return code; } @@ -507,7 +507,7 @@ static int32_t tsdbFileDoWriteSttBlockData(STsdbFD *fd, SBlockData *blockData, S if (sttBlk->maxVer < blockData->aVersion[iRow]) sttBlk->maxVer = blockData->aVersion[iRow]; } - tsdbWriterUpdVerRange(range, sttBlk->minVer, sttBlk->maxVer); + (void)tsdbWriterUpdVerRange(range, sttBlk->minVer, sttBlk->maxVer); TAOS_CHECK_RETURN(tBlockDataCompress(blockData, info, buffers, buffers + 4)); sttBlk->bInfo.offset = *fileSize; @@ -790,7 +790,7 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) { int32_t flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC; char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(writer->config->tsdb, writer->file, fname); + (void)tsdbTFileName(writer->config->tsdb, writer->file, fname); TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd, 0), &lino, _exit); uint8_t hdr[TSDB_FHDR_SIZE] = {0}; @@ -860,7 +860,7 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o .fid = writer->config->fid, .nf = writer->file[0], }; - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArray, op), &lino, _exit); @@ -874,7 +874,7 @@ _exit: static int32_t tsdbSttFWriterCloseAbort(SSttFileWriter *writer) { char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(writer->config->tsdb, writer->file, fname); + (void)tsdbTFileName(writer->config->tsdb, writer->file, fname); tsdbCloseFile(&writer->fd); (void)taosRemoveFile(fname); return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c index 6d2006eaa1..9336231420 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c +++ b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c @@ -79,7 +79,7 @@ static int32_t tsdbUpgradeHead(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader * // open fd char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(tsdb, &file, fname); + (void)tsdbTFileName(tsdb, &file, fname); TAOS_CHECK_GOTO(tsdbOpenFile(fname, tsdb, TD_FILE_READ | TD_FILE_WRITE, &ctx->fd, 0), &lino, _exit); @@ -321,7 +321,7 @@ static int32_t tsdbUpgradeStt(STsdb *tsdb, SDFileSet *pDFileSet, SDataFReader *r if (TARRAY2_SIZE(lvl->fobjArr) > 0) { TAOS_CHECK_GOTO(TARRAY2_APPEND(fset->lvlArr, lvl), &lino, _exit); } else { - tsdbSttLvlClear(&lvl); + (void)tsdbSttLvlClear(&lvl); } _exit: @@ -358,7 +358,7 @@ static int32_t tsdbUpgradeFileSet(STsdb *tsdb, SDFileSet *pDFileSet, TFileSetArr TAOS_CHECK_GOTO(tsdbUpgradeStt(tsdb, pDFileSet, reader, fset), &lino, _exit); } - tsdbDataFReaderClose(&reader); + (void)tsdbDataFReaderClose(&reader); TAOS_CHECK_GOTO(TARRAY2_APPEND(fileSetArray, fset), &lino, _exit); @@ -570,7 +570,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } - tsdbDelFReaderClose(&reader); + (void)tsdbDelFReaderClose(&reader); taosArrayDestroy(aDelIdx); return code; } @@ -612,7 +612,7 @@ static int32_t tsdbUpgradeFileSystem(STsdb *tsdb, int8_t rollback) { // save new file system char fname[TSDB_FILENAME_LEN]; - current_fname(tsdb, fname, TSDB_FCURRENT); + (void)current_fname(tsdb, fname, TSDB_FCURRENT); TAOS_CHECK_GOTO(save_fs(fileSetArray, fname), &lino, _exit); _exit: diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index a1ca8ccda2..667d7ffb7c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -107,7 +107,7 @@ _exit: void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *)) { ASSERT(idx >= 0 && idx < pMapData->nItem); - tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem); + (void)tGetItemFn(pMapData->pData + pMapData->aOffset[idx], pItem); } #ifdef BUILD_NO_CALL @@ -613,7 +613,7 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal * SValue value; if (pRow->type == TSDBROW_ROW_FMT) { - tRowGet(pRow->pTSRow, pTSchema, iCol, pColVal); + (void)tRowGet(pRow->pTSRow, pTSchema, iCol, pColVal); } else if (pRow->type == TSDBROW_COL_FMT) { if (iCol == 0) { *pColVal = diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 06786ecca6..2ddd3c9d3e 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -171,12 +171,12 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) { async->numTasks--; if (task->numWait == 0) { - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); } else if (task->numWait == 1) { - taosThreadCondSignal(&task->waitCond); + (void)taosThreadCondSignal(&task->waitCond); } else { - taosThreadCondBroadcast(&task->waitCond); + (void)taosThreadCondBroadcast(&task->waitCond); } return 0; } @@ -195,7 +195,7 @@ static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) { .arg = task->arg, })); } - vnodeAsyncTaskDone(async, task); + (void)vnodeAsyncTaskDone(async, task); } } } @@ -217,14 +217,14 @@ static void *vnodeAsyncLoop(void *arg) { // finish last running task if (worker->runningTask != NULL) { - vnodeAsyncTaskDone(async, worker->runningTask); + (void)vnodeAsyncTaskDone(async, worker->runningTask); worker->runningTask = NULL; } for (;;) { if (async->stop || worker->workerId >= async->numWorkers) { if (async->stop) { // cancel all tasks - vnodeAsyncCancelAllTasks(async, cancelArray); + (void)vnodeAsyncCancelAllTasks(async, cancelArray); } worker->state = EVA_WORKER_STATE_STOP; async->numLaunchWorkers--; @@ -259,7 +259,7 @@ static void *vnodeAsyncLoop(void *arg) { if (worker->runningTask == NULL) { worker->state = EVA_WORKER_STATE_IDLE; async->numIdleWorkers++; - taosThreadCondWait(&async->hasTask, &async->mutex); + (void)taosThreadCondWait(&async->hasTask, &async->mutex); async->numIdleWorkers--; worker->state = EVA_WORKER_STATE_ACTIVE; } else { @@ -271,7 +271,7 @@ static void *vnodeAsyncLoop(void *arg) { (void)taosThreadMutexUnlock(&async->mutex); // do run the task - worker->runningTask->execute(worker->runningTask->arg); + (void)worker->runningTask->execute(worker->runningTask->arg); } _exit: @@ -334,8 +334,8 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { strcpy((char *)((*async) + 1), label); (*async)->label = (const char *)((*async) + 1); - taosThreadMutexInit(&(*async)->mutex, NULL); - taosThreadCondInit(&(*async)->hasTask, NULL); + (void)taosThreadMutexInit(&(*async)->mutex, NULL); + (void)taosThreadCondInit(&(*async)->hasTask, NULL); (*async)->stop = false; // worker @@ -356,8 +356,8 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { (*async)->chList.next = &(*async)->chList; ret = vHashInit(&(*async)->channelTable, vnodeAsyncChannelHash, vnodeAsyncChannelCompare); if (ret != 0) { - taosThreadMutexDestroy(&(*async)->mutex); - taosThreadCondDestroy(&(*async)->hasTask); + (void)taosThreadMutexDestroy(&(*async)->mutex); + (void)taosThreadCondDestroy(&(*async)->hasTask); taosMemoryFree(*async); return ret; } @@ -371,9 +371,9 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { } ret = vHashInit(&(*async)->taskTable, vnodeAsyncTaskHash, vnodeAsyncTaskCompare); if (ret != 0) { - vHashDestroy(&(*async)->channelTable); - taosThreadMutexDestroy(&(*async)->mutex); - taosThreadCondDestroy(&(*async)->hasTask); + (void)vHashDestroy(&(*async)->channelTable); + (void)taosThreadMutexDestroy(&(*async)->mutex); + (void)taosThreadCondDestroy(&(*async)->hasTask); taosMemoryFree(*async); return ret; } @@ -389,7 +389,7 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) { // set stop and broadcast (void)taosThreadMutexLock(&(*async)->mutex); (*async)->stop = true; - taosThreadCondBroadcast(&(*async)->hasTask); + (void)taosThreadCondBroadcast(&(*async)->hasTask); (void)taosThreadMutexUnlock(&(*async)->mutex); // join all workers @@ -402,7 +402,7 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) { continue; } - taosThreadJoin((*async)->workers[i].thread, NULL); + (void)taosThreadJoin((*async)->workers[i].thread, NULL); ASSERT((*async)->workers[i].state == EVA_WORKER_STATE_STOP); (*async)->workers[i].state = EVA_WORKER_STATE_UINIT; } @@ -425,11 +425,11 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) { ASSERT((*async)->numChannels == 0); ASSERT((*async)->numTasks == 0); - taosThreadMutexDestroy(&(*async)->mutex); - taosThreadCondDestroy(&(*async)->hasTask); + (void)taosThreadMutexDestroy(&(*async)->mutex); + (void)taosThreadCondDestroy(&(*async)->hasTask); - vHashDestroy(&(*async)->channelTable); - vHashDestroy(&(*async)->taskTable); + (void)vHashDestroy(&(*async)->channelTable); + (void)vHashDestroy(&(*async)->taskTable); taosMemoryFree(*async); *async = NULL; @@ -442,11 +442,11 @@ static int32_t vnodeAsyncLaunchWorker(SVAsync *async) { if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) { continue; } else if (async->workers[i].state == EVA_WORKER_STATE_STOP) { - taosThreadJoin(async->workers[i].thread, NULL); + (void)taosThreadJoin(async->workers[i].thread, NULL); async->workers[i].state = EVA_WORKER_STATE_UINIT; } - taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]); + (void)taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]); async->workers[i].state = EVA_WORKER_STATE_ACTIVE; async->numLaunchWorkers++; break; @@ -461,20 +461,20 @@ int32_t vnodeAsyncOpen(int32_t numOfThreads) { // vnode-commit code = vnodeAsyncInit(&vnodeAsyncs[1], "vnode-commit"); TSDB_CHECK_CODE(code, lino, _exit); - vnodeAsyncSetWorkers(1, numOfThreads); + (void)vnodeAsyncSetWorkers(1, numOfThreads); // vnode-merge code = vnodeAsyncInit(&vnodeAsyncs[2], "vnode-merge"); TSDB_CHECK_CODE(code, lino, _exit); - vnodeAsyncSetWorkers(2, numOfThreads); + (void)vnodeAsyncSetWorkers(2, numOfThreads); _exit: return code; } int32_t vnodeAsyncClose() { - vnodeAsyncDestroy(&vnodeAsyncs[1]); - vnodeAsyncDestroy(&vnodeAsyncs[2]); + (void)vnodeAsyncDestroy(&vnodeAsyncs[1]); + (void)vnodeAsyncDestroy(&vnodeAsyncs[2]); return 0; } @@ -501,7 +501,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec task->arg = arg; task->state = EVA_TASK_STATE_WAITTING; task->numWait = 0; - taosThreadCondInit(&task->waitCond, NULL); + (void)taosThreadCondInit(&task->waitCond, NULL); // schedule task (void)taosThreadMutexLock(&async->mutex); @@ -512,10 +512,10 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec SVAChannel channel = { .channelId = channelID->id, }; - vHashGet(async->channelTable, &channel, (void **)&task->channel); + (void)vHashGet(async->channelTable, &channel, (void **)&task->channel); if (task->channel == NULL) { (void)taosThreadMutexUnlock(&async->mutex); - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); return TSDB_CODE_INVALID_PARA; } @@ -527,7 +527,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec int32_t ret = vHashPut(async->taskTable, task); if (ret != 0) { (void)taosThreadMutexUnlock(&async->mutex); - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); return ret; } @@ -548,9 +548,9 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec // signal worker or launch new worker if (async->numIdleWorkers > 0) { - taosThreadCondSignal(&(async->hasTask)); + (void)taosThreadCondSignal(&(async->hasTask)); } else if (async->numLaunchWorkers < async->numWorkers) { - vnodeAsyncLaunchWorker(async); + (void)vnodeAsyncLaunchWorker(async); } } else if (task->channel->scheduled->state == EVA_TASK_STATE_RUNNING || priority >= VATASK_PIORITY(task->channel->scheduled)) { @@ -603,14 +603,14 @@ int32_t vnodeAWait(SVATaskID *taskID) { (void)taosThreadMutexLock(&async->mutex); - vHashGet(async->taskTable, &task2, (void **)&task); + (void)vHashGet(async->taskTable, &task2, (void **)&task); if (task) { task->numWait++; - taosThreadCondWait(&task->waitCond, &async->mutex); + (void)taosThreadCondWait(&task->waitCond, &async->mutex); task->numWait--; if (task->numWait == 0) { - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); } } @@ -636,14 +636,14 @@ int32_t vnodeACancel(SVATaskID *taskID) { (void)taosThreadMutexLock(&async->mutex); - vHashGet(async->taskTable, &task2, (void **)&task); + (void)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; - vnodeAsyncTaskDone(async, task); + (void)vnodeAsyncTaskDone(async, task); } else { ret = TSDB_CODE_FAILED; } @@ -666,7 +666,7 @@ int32_t vnodeAsyncSetWorkers(int64_t asyncID, int32_t numWorkers) { (void)taosThreadMutexLock(&async->mutex); async->numWorkers = numWorkers; if (async->numIdleWorkers > 0) { - taosThreadCondBroadcast(&async->hasTask); + (void)taosThreadCondBroadcast(&async->hasTask); } (void)taosThreadMutexUnlock(&async->mutex); @@ -736,12 +736,12 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { (void)taosThreadMutexLock(&async->mutex); - vHashGet(async->channelTable, &channel2, (void **)&channel); + (void)vHashGet(async->channelTable, &channel2, (void **)&channel); if (channel) { // unregister channel channel->next->prev = channel->prev; channel->prev->next = channel->next; - vHashDrop(async->channelTable, channel); + (void)vHashDrop(async->channelTable, channel); async->numChannels--; // cancel all waiting tasks @@ -756,7 +756,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { .arg = task->arg, })); } - vnodeAsyncTaskDone(async, task); + (void)vnodeAsyncTaskDone(async, task); } } @@ -771,7 +771,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { .arg = channel->scheduled->arg, })); } - vnodeAsyncTaskDone(async, channel->scheduled); + (void)vnodeAsyncTaskDone(async, channel->scheduled); } taosMemoryFree(channel); } else { @@ -779,10 +779,10 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { // wait task SVATask *task = channel->scheduled; task->numWait++; - taosThreadCondWait(&task->waitCond, &async->mutex); + (void)taosThreadCondWait(&task->waitCond, &async->mutex); task->numWait--; if (task->numWait == 0) { - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); } diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c index f9f539b6d3..cbd6fbbe52 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c @@ -26,7 +26,7 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu memset(pPool, 0, sizeof(SVBufPool)); // query handle list - taosThreadMutexInit(&pPool->mutex, NULL); + (void)taosThreadMutexInit(&pPool->mutex, NULL); pPool->nQuery = 0; pPool->qList.pNext = &pPool->qList; pPool->qList.ppNext = &pPool->qList.pNext; @@ -61,10 +61,10 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu static int vnodeBufPoolDestroy(SVBufPool *pPool) { vnodeBufPoolReset(pPool); if (pPool->lock) { - taosThreadSpinDestroy(pPool->lock); + (void)taosThreadSpinDestroy(pPool->lock); taosMemoryFree((void *)pPool->lock); } - taosThreadMutexDestroy(&pPool->mutex); + (void)taosThreadMutexDestroy(&pPool->mutex); taosMemoryFree(pPool); return 0; } @@ -77,7 +77,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)); - vnodeCloseBufPool(pVnode); + (void)vnodeCloseBufPool(pVnode); return code; } @@ -93,7 +93,7 @@ int vnodeOpenBufPool(SVnode *pVnode) { int vnodeCloseBufPool(SVnode *pVnode) { for (int32_t i = 0; i < VNODE_BUFPOOL_SEGMENTS; i++) { if (pVnode->aBufPool[i]) { - vnodeBufPoolDestroy(pVnode->aBufPool[i]); + (void)vnodeBufPoolDestroy(pVnode->aBufPool[i]); pVnode->aBufPool[i] = NULL; } } @@ -141,7 +141,7 @@ void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) { pNode = taosMemoryMalloc(sizeof(*pNode) + size); if (pNode == NULL) { if (pPool->lock) { - taosThreadSpinUnlock(pPool->lock); + (void)taosThreadSpinUnlock(pPool->lock); } return NULL; } @@ -155,7 +155,7 @@ void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) { pPool->size = pPool->size + sizeof(*pNode) + size; } - if (pPool->lock) taosThreadSpinUnlock(pPool->lock); + if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock); return p; } @@ -174,7 +174,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) { // allocate a new node pNode = taosMemoryMalloc(sizeof(*pNode) + size); if (pNode == NULL) { - if (pPool->lock) taosThreadSpinUnlock(pPool->lock); + if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock); return NULL; } @@ -187,7 +187,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) { pPool->size = pPool->size + sizeof(*pNode) + size; } - if (pPool->lock) taosThreadSpinUnlock(pPool->lock); + if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock); return p; } @@ -223,7 +223,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); - vnodeBufPoolDestroy(pPool); + (void)vnodeBufPoolDestroy(pPool); pPool = pNewPool; pVnode->aBufPool[pPool->id] = pPool; } @@ -234,7 +234,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) { vnodeBufPoolReset(pPool); pPool->freeNext = pVnode->freeList; pVnode->freeList = pPool; - taosThreadCondSignal(&pVnode->poolNotEmpty); + (void)taosThreadCondSignal(&pVnode->poolNotEmpty); } void vnodeBufPoolUnRef(SVBufPool *pPool, bool proactive) { diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 12e4fe7753..e2db87173d 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -127,7 +127,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (pNodeRetentions == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - tjsonAddItemToObject(pJson, "retentions", pNodeRetentions); + TAOS_CHECK_RETURN(tjsonAddItemToObject(pJson, "retentions", pNodeRetentions)); for (int32_t i = 0; i < nRetention; ++i) { SJson *pNodeRetention = tjsonCreateObject(); const SRetention *pRetention = pCfg->tsdbCfg.retentions + i; @@ -353,7 +353,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (info == NULL) return -1; tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code); if (code) return code; - tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); + (void)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 db6b29d427..88b13310d8 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -91,7 +91,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) { struct timeval tv; struct timespec ts; - taosGetTimeOfDay(&tv); + (void)taosGetTimeOfDay(&tv); ts.tv_nsec = tv.tv_usec * 1000 + WAIT_TIME_MILI_SEC * 1000000; if (ts.tv_nsec > 999999999l) { ts.tv_sec = tv.tv_sec + 1; @@ -199,7 +199,7 @@ _exit: vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d selfIndex:%d changeVersion:%d", pInfo->config.vgId, fname, pInfo->config.syncCfg.replicaNum, pInfo->config.syncCfg.myIndex, pInfo->config.syncCfg.changeVersion); } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); taosMemoryFree(data); return code; } @@ -259,7 +259,7 @@ _exit: vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code)); } taosMemoryFree(pData); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return code; } @@ -270,7 +270,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { int64_t lastCommitted = pInfo->info.state.committed; // wait last commit task - vnodeAWait(&pVnode->commitTask); + (void)vnodeAWait(&pVnode->commitTask); code = syncNodeGetConfig(pVnode->sync, &pVnode->config.syncCfg); TSDB_CHECK_CODE(code, lino, _exit); @@ -285,13 +285,13 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { pInfo->txn = metaGetTxn(pVnode->pMeta); // save info - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); vDebug("vgId:%d, save config while prepare commit", TD_VID(pVnode)); code = vnodeSaveInfo(dir, &pInfo->info); TSDB_CHECK_CODE(code, lino, _exit); - tsdbPreCommit(pVnode->pTsdb); + (void)tsdbPreCommit(pVnode->pTsdb); code = metaPrepareAsyncCommit(pVnode->pMeta); TSDB_CHECK_CODE(code, lino, _exit); @@ -395,8 +395,8 @@ _exit: } int vnodeSyncCommit(SVnode *pVnode) { - vnodeAsyncCommit(pVnode); - vnodeAWait(&pVnode->commitTask); + (void)vnodeAsyncCommit(pVnode); + (void)vnodeAWait(&pVnode->commitTask); return 0; } @@ -416,9 +416,9 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { return -1; } - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); - syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed); + (void)syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed); code = tsdbCommitBegin(pVnode->pTsdb, pInfo); TSDB_CHECK_CODE(code, lino, _exit); @@ -455,7 +455,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { return -1; } - syncEndSnapshot(pVnode->sync); + (void)syncEndSnapshot(pVnode->sync); _exit: if (code) { @@ -470,7 +470,7 @@ bool vnodeShouldRollback(SVnode *pVnode) { char tFName[TSDB_FILENAME_LEN] = {0}; int32_t offset = 0; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); offset = strlen(tFName); snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP); @@ -481,7 +481,7 @@ void vnodeRollback(SVnode *pVnode) { char tFName[TSDB_FILENAME_LEN] = {0}; int32_t offset = 0; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); offset = strlen(tFName); snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP); diff --git a/source/dnode/vnode/src/vnd/vnodeHash.c b/source/dnode/vnode/src/vnd/vnodeHash.c index 093b5056ed..00fc2dfc00 100644 --- a/source/dnode/vnode/src/vnd/vnodeHash.c +++ b/source/dnode/vnode/src/vnd/vnodeHash.c @@ -98,7 +98,7 @@ int32_t vHashPut(SVHashTable* ht, void* obj) { } if (ht->numEntries >= ht->numBuckets) { - vHashRehash(ht, ht->numBuckets * 2); + (void)vHashRehash(ht, ht->numBuckets * 2); bucketIndex = ht->hash(obj) % ht->numBuckets; } @@ -144,7 +144,7 @@ int32_t vHashDrop(SVHashTable* ht, const void* obj) { taosMemoryFree(tmp); ht->numEntries--; if (ht->numBuckets > VNODE_HASH_DEFAULT_NUM_BUCKETS && ht->numEntries < ht->numBuckets / 4) { - vHashRehash(ht, ht->numBuckets / 2); + (void)vHashRehash(ht, ht->numBuckets / 2); } return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeModule.c b/source/dnode/vnode/src/vnd/vnodeModule.c index 228cc9e0b2..8b7de7058c 100644 --- a/source/dnode/vnode/src/vnd/vnodeModule.c +++ b/source/dnode/vnode/src/vnd/vnodeModule.c @@ -31,7 +31,7 @@ int vnodeInit(int nthreads) { void vnodeCleanup() { if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return; - vnodeAsyncClose(); + (void)vnodeAsyncClose(); walCleanUp(); smaCleanUp(); } diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index fb835fd0c2..8a2b10d2ef 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -53,7 +53,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs vError("vgId:%d, failed to prepare vnode dir since %s, path: %s", pCfg->vgId, strerror(errno), path); return TAOS_SYSTEM_ERROR(errno); } - vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); if (pCfg) { info.config = *pCfg; @@ -88,7 +88,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t char dir[TSDB_FILENAME_LEN] = {0}; int32_t ret = 0; - vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); ret = vnodeLoadInfo(dir, &info); if (ret < 0) { @@ -221,7 +221,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod char dir[TSDB_FILENAME_LEN] = {0}; int32_t ret = 0; - vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); ret = vnodeLoadInfo(dir, &info); if (ret < 0) { @@ -283,7 +283,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s char dir[TSDB_FILENAME_LEN] = {0}; int32_t code = 0; - vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); if (vnodeLoadInfo(dir, &info) == 0) { if (info.config.vgId != dstVgId) { vError("vgId:%d, unexpected vnode config.vgId:%d", dstVgId, info.config.vgId); @@ -292,7 +292,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s return dstVgId; } - vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); if (vnodeLoadInfo(dir, &info) < 0) { vError("vgId:%d, failed to read vnode config from %s since %s", srcVgId, srcPath, tstrerror(terrno)); return -1; @@ -317,7 +317,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId) { vInfo("path:%s is removed while destroy vnode", path); - tfsRmdir(pTfs, path); + (void)tfsRmdir(pTfs, path); // int32_t nlevel = tfsGetLevel(pTfs); if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) { @@ -351,7 +351,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC vError("failed to open vnode from %s since %s. diskPrimary:%d", path, terrstr(), diskPrimary); return NULL; } - vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); info.config = vnodeCfgDefault; @@ -401,12 +401,12 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC pVnode->pTfs = pTfs; pVnode->diskPrimary = diskPrimary; pVnode->msgCb = msgCb; - taosThreadMutexInit(&pVnode->lock, NULL); + (void)taosThreadMutexInit(&pVnode->lock, NULL); pVnode->blocked = false; - tsem_init(&pVnode->syncSem, 0, 0); - taosThreadMutexInit(&pVnode->mutex, NULL); - taosThreadCondInit(&pVnode->poolNotEmpty, NULL); + (void)tsem_init(&pVnode->syncSem, 0, 0); + (void)taosThreadMutexInit(&pVnode->mutex, NULL); + (void)taosThreadCondInit(&pVnode->poolNotEmpty, NULL); if (vnodeAChannelInit(1, &pVnode->commitChannel) != 0) { vError("vgId:%d, failed to init commit channel", TD_VID(pVnode)); @@ -439,7 +439,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC // open wal sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR); - taosRealPath(tdir, NULL, sizeof(tdir)); + (void)taosRealPath(tdir, NULL, sizeof(tdir)); pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg)); if (pVnode->pWal == NULL) { @@ -449,7 +449,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC // open tq sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR); - taosRealPath(tdir, NULL, sizeof(tdir)); + (void)taosRealPath(tdir, NULL, sizeof(tdir)); // open query if (vnodeQueryOpen(pVnode)) { @@ -502,7 +502,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", label_count, sample_labels); vInfo("vgId:%d, new metric:%p", TD_VID(pVnode), counter); if (taos_collector_registry_register_metric(counter) == 1) { - taos_counter_destroy(counter); + (void)taos_counter_destroy(counter); counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT); vInfo("vgId:%d, get metric from registry:%p", TD_VID(pVnode), counter); } @@ -516,10 +516,10 @@ _err: if (pVnode->pQuery) vnodeQueryClose(pVnode); if (pVnode->pTq) tqClose(pVnode->pTq); if (pVnode->pWal) walClose(pVnode->pWal); - if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); - if (pVnode->pSma) smaClose(pVnode->pSma); - if (pVnode->pMeta) metaClose(&pVnode->pMeta); - if (pVnode->freeList) vnodeCloseBufPool(pVnode); + 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); taosMemoryFree(pVnode); return NULL; @@ -534,22 +534,22 @@ void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); } void vnodeClose(SVnode *pVnode) { if (pVnode) { - vnodeAWait(&pVnode->commitTask); - vnodeAChannelDestroy(&pVnode->commitChannel, true); + (void)vnodeAWait(&pVnode->commitTask); + (void)vnodeAChannelDestroy(&pVnode->commitChannel, true); vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); tqClose(pVnode->pTq); walClose(pVnode->pWal); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); - smaClose(pVnode->pSma); + (void)smaClose(pVnode->pSma); if (pVnode->pMeta) metaClose(&pVnode->pMeta); - vnodeCloseBufPool(pVnode); + (void)vnodeCloseBufPool(pVnode); // destroy handle - tsem_destroy(&pVnode->syncSem); - taosThreadCondDestroy(&pVnode->poolNotEmpty); - taosThreadMutexDestroy(&pVnode->mutex); - taosThreadMutexDestroy(&pVnode->lock); + (void)tsem_destroy(&pVnode->syncSem); + (void)taosThreadCondDestroy(&pVnode->poolNotEmpty); + (void)taosThreadMutexDestroy(&pVnode->mutex); + (void)taosThreadMutexDestroy(&pVnode->lock); taosMemoryFree(pVnode); } } diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index f30b2f2ada..92e2ffeb7f 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -209,7 +209,7 @@ static void vnodeSnapReaderDestroyTsdbRanges(SVSnapReader *pReader) { for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) { TFileSetRangeArray **ppRanges = vnodeSnapReaderGetTsdbRanges(pReader, tsdbTyps[j]); if (ppRanges == NULL) continue; - tsdbTFileSetRangeArrayDestroy(ppRanges); + (void)tsdbTFileSetRangeArrayDestroy(ppRanges); } } @@ -218,15 +218,15 @@ void vnodeSnapReaderClose(SVSnapReader *pReader) { vnodeSnapReaderDestroyTsdbRanges(pReader); if (pReader->pRsmaReader) { - rsmaSnapReaderClose(&pReader->pRsmaReader); + (void)rsmaSnapReaderClose(&pReader->pRsmaReader); } if (pReader->pTsdbReader) { - tsdbSnapReaderClose(&pReader->pTsdbReader); + (void)tsdbSnapReaderClose(&pReader->pTsdbReader); } if (pReader->pTsdbRAWReader) { - tsdbSnapRAWReaderClose(&pReader->pTsdbRAWReader); + (void)tsdbSnapRAWReaderClose(&pReader->pTsdbRAWReader); } if (pReader->pMetaReader) { @@ -260,7 +260,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) char fName[TSDB_FILENAME_LEN]; int32_t offset = 0; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN); offset = strlen(fName); snprintf(fName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME); @@ -272,13 +272,13 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) int64_t size; if (taosFStatFile(pFile, &size, NULL) < 0) { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit); } *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1); if (*ppData == NULL) { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); } ((SSnapDataHdr *)(*ppData))->type = SNAP_DATA_CFG; @@ -287,11 +287,11 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) { taosMemoryFree(*ppData); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit); } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); pReader->cfgDone = 1; goto _exit; @@ -590,15 +590,15 @@ extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb); extern int32_t tsdbEnableBgTask(STsdb *pTsdb); static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) { - tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); - vnodeSyncCommit(pVnode); - vnodeAChannelDestroy(&pVnode->commitChannel, true); + (void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); + (void)vnodeSyncCommit(pVnode); + (void)vnodeAChannelDestroy(&pVnode->commitChannel, true); return 0; } static int32_t vnodeEnableBgTask(SVnode *pVnode) { - tsdbEnableBgTask(pVnode->pTsdb); - vnodeAChannelInit(1, &pVnode->commitChannel); + (void)tsdbEnableBgTask(pVnode->pTsdb); + (void)vnodeAChannelInit(1, &pVnode->commitChannel); return 0; } @@ -610,7 +610,7 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, SSnapshotParam *pParam, SVSnapWriter int64_t ever = pParam->end; // cancel and disable all bg task - vnodeCancelAndDisableAllBgTask(pVnode); + (void)vnodeCancelAndDisableAllBgTask(pVnode); // alloc pWriter = (SVSnapWriter *)taosMemoryCalloc(1, sizeof(*pWriter)); @@ -646,7 +646,7 @@ static void vnodeSnapWriterDestroyTsdbRanges(SVSnapWriter *pWriter) { for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) { TFileSetRangeArray **ppRanges = vnodeSnapWriterGetTsdbRanges(pWriter, tsdbTyps[j]); if (ppRanges == NULL) continue; - tsdbTFileSetRangeArrayDestroy(ppRanges); + (void)tsdbTFileSetRangeArrayDestroy(ppRanges); } } @@ -658,15 +658,15 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * // prepare if (pWriter->pTsdbSnapWriter) { - tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter); + (void)tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter); } if (pWriter->pTsdbSnapRAWWriter) { - tsdbSnapRAWWriterPrepareClose(pWriter->pTsdbSnapRAWWriter); + (void)tsdbSnapRAWWriterPrepareClose(pWriter->pTsdbSnapRAWWriter); } if (pWriter->pRsmaSnapWriter) { - rsmaSnapWriterPrepareClose(pWriter->pRsmaSnapWriter); + (void)rsmaSnapWriterPrepareClose(pWriter->pRsmaSnapWriter); } // commit json @@ -681,7 +681,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * .applyTerm = pWriter->info.state.commitTerm}; pVnode->statis = pWriter->info.statis; char dir[TSDB_FILENAME_LEN] = {0}; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); code = vnodeCommitInfo(dir); if (code) goto _exit; @@ -740,7 +740,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * if (code) goto _exit; } - vnodeBegin(pVnode); + (void)vnodeBegin(pVnode); _exit: if (code) { @@ -749,7 +749,7 @@ _exit: vInfo("vgId:%d, vnode snapshot writer closed, rollback:%d", TD_VID(pVnode), rollback); taosMemoryFree(pWriter); } - vnodeEnableBgTask(pVnode); + (void)vnodeEnableBgTask(pVnode); return code; } @@ -768,7 +768,7 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_ // modify info as needed char dir[TSDB_FILENAME_LEN] = {0}; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); SVnodeStats vndStats = pWriter->info.config.vndStats; pWriter->info.config = pVnode->config; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 1b656442a5..feaad0f46d 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -207,7 +207,7 @@ static int32_t vnodePreProcessDropTtlMsg(SVnode *pVnode, SRpcMsg *pMsg) { TSDB_CHECK_CODE(code, lino, _exit); } - tSerializeSVDropTtlTableReq((char *)pContNew + sizeof(SMsgHead), reqLenNew, &ttlReq); + (void)tSerializeSVDropTtlTableReq((char *)pContNew + sizeof(SMsgHead), reqLenNew, &ttlReq); pContNew->contLen = htonl(reqLenNew); pContNew->vgId = pContOld->vgId; @@ -422,7 +422,7 @@ static int32_t vnodePreProcessDeleteMsg(SVnode *pVnode, SRpcMsg *pMsg) { ((SMsgHead *)pCont)->vgId = TD_VID(pVnode); tEncoderInit(pCoder, pCont + sizeof(SMsgHead), size); - tEncodeDeleteRes(pCoder, &res); + (void)tEncodeDeleteRes(pCoder, &res); tEncoderClear(pCoder); rpcFreeCont(pMsg->pCont); @@ -632,7 +632,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg } break; case TDMT_STREAM_CONSEN_CHKPT: { if (pVnode->restored) { - tqProcessTaskConsenChkptIdReq(pVnode->pTq, pMsg); + (void)tqProcessTaskConsenChkptIdReq(pVnode->pTq, pMsg); } } break; case TDMT_STREAM_TASK_PAUSE: { @@ -649,7 +649,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg } break; case TDMT_VND_STREAM_TASK_RESET: { if (pVnode->restored && vnodeIsLeader(pVnode)) { - tqProcessTaskResetReq(pVnode->pTq, pMsg); + (void)tqProcessTaskResetReq(pVnode->pTq, pMsg); } } break; case TDMT_VND_ALTER_CONFIRM: @@ -699,7 +699,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg vTrace("vgId:%d, process %s request, code:0x%x index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), pRsp->code, ver); - walApplyVer(pVnode->pWal, ver); + (void)walApplyVer(pVnode->pWal, ver); code = tqPushMsg(pVnode->pTq, pMsg->msgType); if (code) { @@ -871,7 +871,7 @@ int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) } void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { - tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); + (void)tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); } void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) { @@ -942,7 +942,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t ver, void *pReq, int ret = 0; if (ttlReq.nUids > 0) { metaDropTables(pVnode->pMeta, ttlReq.pTbUids); - tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false); + (void)tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false); } end: @@ -1142,7 +1142,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, } } else { cRsp.code = TSDB_CODE_SUCCESS; - tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); + (void)tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); if (taosArrayPush(tbUids, &pCreateReq->uid) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; rcode = -1; @@ -1159,11 +1159,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, } vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids)); - tqUpdateTbUidList(pVnode->pTq, tbUids, true); + (void)tqUpdateTbUidList(pVnode->pTq, tbUids, true); if (tdUpdateTbUidList(pVnode->pSma, pStore, true) < 0) { goto _exit; } - tdUidStoreFree(pStore); + (void)tdUidStoreFree(pStore); // prepare rsp int32_t ret = 0; @@ -1175,13 +1175,13 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, goto _exit; } tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); - tEncodeSVCreateTbBatchRsp(&encoder, &rsp); + (void)tEncodeSVCreateTbBatchRsp(&encoder, &rsp); if (tsEnableAudit && tsEnableAuditCreateTable) { int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; SName name = {0}; - tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); + (void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); SStringBuilder sb = {0}; for (int32_t i = 0; i < tbNames->size; i++) { @@ -1329,7 +1329,7 @@ _exit: tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); - tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp); + (void)tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp); tEncoderClear(&ec); if (vMetaRsp.pSchemas) { taosMemoryFree(vMetaRsp.pSchemas); @@ -1384,7 +1384,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in } } else { dropTbRsp.code = TSDB_CODE_SUCCESS; - if (tbUid > 0) tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid); + if (tbUid > 0) (void)tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid); } if (taosArrayPush(rsp.pArray, &dropTbRsp) == NULL) { @@ -1404,14 +1404,14 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in } } - tqUpdateTbUidList(pVnode->pTq, tbUids, false); - tdUpdateTbUidList(pVnode->pSma, pStore, false); + (void)tqUpdateTbUidList(pVnode->pTq, tbUids, false); + (void)tdUpdateTbUidList(pVnode->pSma, pStore, false); if (tsEnableAuditCreateTable) { int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; SName name = {0}; - tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); + (void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); SStringBuilder sb = {0}; for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { @@ -1435,12 +1435,12 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in _exit: taosArrayDestroy(tbUids); - tdUidStoreFree(pStore); + (void)tdUidStoreFree(pStore); tDecoderClear(&decoder); tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); - tEncodeSVDropTbBatchRsp(&encoder, &rsp); + (void)tEncodeSVDropTbBatchRsp(&encoder, &rsp); tEncoderClear(&encoder); taosArrayDestroy(rsp.pArray); taosArrayDestroy(tbNames); @@ -1876,7 +1876,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in if (taosArrayGetSize(newTbUids) > 0) { vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode), (int32_t)taosArrayGetSize(newTbUids)); - tqUpdateTbUidList(pVnode->pTq, newTbUids, true); + (void)tqUpdateTbUidList(pVnode->pTq, newTbUids, true); } _exit: @@ -1885,13 +1885,13 @@ _exit: tEncodeSize(tEncodeSSubmitRsp2, pSubmitRsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); - tEncodeSSubmitRsp2(&ec, pSubmitRsp); + (void)tEncodeSSubmitRsp2(&ec, pSubmitRsp); tEncoderClear(&ec); // update statistics - atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows); - atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows); - atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1); + (void)atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows); + (void)atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows); + (void)atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1); if (tsEnableMonitor && pSubmitRsp->affectedRows > 0 && strlen(pOriginalMsg->info.conn.user) > 0) { const char *sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS, @@ -1901,11 +1901,11 @@ _exit: pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Success"}; - taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels); + (void)taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels); } if (code == 0) { - atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1); + (void)atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1); code = tdProcessRSmaSubmit(pVnode->pSma, ver, pSubmitReq, pReq, len); } /* @@ -2125,10 +2125,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 { - vnodeAWait(&pVnode->commitTask); - tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); + (void)vnodeAWait(&pVnode->commitTask); + (void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); pVnode->config.sttTrigger = req.sttTrigger; - tsdbEnableBgTask(pVnode->pTsdb); + (void)tsdbEnableBgTask(pVnode->pTsdb); } } @@ -2144,11 +2144,11 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe } if (walChanged) { - walAlter(pVnode->pWal, &pVnode->config.walCfg); + (void)walAlter(pVnode->pWal, &pVnode->config.walCfg); } if (tsdbChanged) { - tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg); + (void)tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg); } return 0; @@ -2158,7 +2158,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t ver, void *pRe SBatchDeleteReq deleteReq; SDecoder decoder; tDecoderInit(&decoder, pReq, len); - tDecodeSBatchDeleteReq(&decoder, &deleteReq); + (void)tDecodeSBatchDeleteReq(&decoder, &deleteReq); SMetaReader mr = {0}; metaReaderDoInit(&mr, pVnode->pMeta, META_READER_NOLOCK); @@ -2220,7 +2220,8 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in } tDecoderInit(pCoder, pReq, len); - tDecodeDeleteRes(pCoder, pRes); + code = tDecodeDeleteRes(pCoder, pRes); + if (code) goto _err; if (pRes->affectedRows > 0) { for (int32_t iUid = 0; iUid < taosArrayGetSize(pRes->uidList); iUid++) { @@ -2243,7 +2244,8 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in pRsp->pCont = rpcMallocCont(pRsp->contLen); SEncoder ec = {0}; tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); - tEncodeSVDeleteRsp(&ec, &rsp); + code = tEncodeSVDeleteRsp(&ec, &rsp); + if (code) goto _err; tEncoderClear(&ec); return code; @@ -2325,7 +2327,7 @@ static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t ver, void *pR } static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) { - syncCheckMember(pVnode->sync); + (void)syncCheckMember(pVnode->sync); pRsp->msgType = TDMT_SYNC_CONFIG_CHANGE_RSP; pRsp->code = TSDB_CODE_SUCCESS; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index b7683a8698..d9630b56fd 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -28,7 +28,7 @@ static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { const STraceId *trace = &pMsg->info.traceId; vGTrace("vgId:%d, msg:%p wait block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq); - tsem_wait(&pVnode->syncSem); + (void)tsem_wait(&pVnode->syncSem); } static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { @@ -41,7 +41,7 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { pVnode->blocked = false; pVnode->blockSec = 0; pVnode->blockSeq = 0; - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } (void)taosThreadMutexUnlock(&pVnode->lock); } @@ -69,7 +69,7 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) { if (rsp.pCont == NULL) { pMsg->code = TSDB_CODE_OUT_OF_MEMORY; } else { - tSerializeSEpSet(rsp.pCont, contLen, &newEpSet); + (void)tSerializeSEpSet(rsp.pCont, contLen, &newEpSet); rsp.contLen = contLen; } @@ -161,7 +161,7 @@ void vnodeProposeCommitOnNeed(SVnode *pVnode, bool atExit) { rpcFreeCont(rpcMsg.pCont); rpcMsg.pCont = NULL; } else { - tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg); + (void)tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -556,7 +556,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) } while (true); ASSERT(commitIdx == vnodeSyncAppliedIndex(pFsm)); - walApplyVer(pVnode->pWal, commitIdx); + (void)walApplyVer(pVnode->pWal, commitIdx); pVnode->restored = true; SStreamMeta *pMeta = pVnode->pTq->pStreamMeta; @@ -583,7 +583,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) streamMetaWUnLock(pMeta); tqInfo("vgId:%d stream task already loaded, start them", vgId); - streamTaskSchedTask(&pVnode->msgCb, TD_VID(pVnode), 0, 0, STREAM_EXEC_T_START_ALL_TASKS); + (void)streamTaskSchedTask(&pVnode->msgCb, TD_VID(pVnode), 0, 0, STREAM_EXEC_T_START_ALL_TASKS); return; } } @@ -602,13 +602,13 @@ static void vnodeBecomeFollower(const SSyncFSM *pFsm) { if (pVnode->blocked) { pVnode->blocked = false; vDebug("vgId:%d, become follower and post block", pVnode->config.vgId); - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } (void)taosThreadMutexUnlock(&pVnode->lock); if (pVnode->pTq) { tqUpdateNodeStage(pVnode->pTq, false); - tqStopStreamTasksAsync(pVnode->pTq); + (void)tqStopStreamTasksAsync(pVnode->pTq); } } @@ -620,7 +620,7 @@ static void vnodeBecomeLearner(const SSyncFSM *pFsm) { if (pVnode->blocked) { pVnode->blocked = false; vDebug("vgId:%d, become learner and post block", pVnode->config.vgId); - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } (void)taosThreadMutexUnlock(&pVnode->lock); } @@ -743,14 +743,14 @@ int32_t vnodeSyncStart(SVnode *pVnode) { void vnodeSyncPreClose(SVnode *pVnode) { vInfo("vgId:%d, sync pre close", pVnode->config.vgId); - syncLeaderTransfer(pVnode->sync); + (void)syncLeaderTransfer(pVnode->sync); syncPreStop(pVnode->sync); (void)taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { vInfo("vgId:%d, post block after close sync", pVnode->config.vgId); pVnode->blocked = false; - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } (void)taosThreadMutexUnlock(&pVnode->lock); } @@ -785,7 +785,7 @@ void vnodeSyncCheckTimeout(SVnode *pVnode) { pVnode->blocked = false; pVnode->blockSec = 0; pVnode->blockSeq = 0; - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } } (void)taosThreadMutexUnlock(&pVnode->lock); diff --git a/source/libs/audit/src/auditMain.c b/source/libs/audit/src/auditMain.c index 7a8de49abe..cdc4a964c7 100644 --- a/source/libs/audit/src/auditMain.c +++ b/source/libs/audit/src/auditMain.c @@ -45,11 +45,11 @@ static FORCE_INLINE void auditDeleteRecord(SAuditRecord * record) { void auditCleanup() { tsLogFp = NULL; - taosThreadMutexLock(&tsAudit.lock); + (void)taosThreadMutexLock(&tsAudit.lock); taosArrayDestroyP(tsAudit.records, (FDelete)auditDeleteRecord); - taosThreadMutexUnlock(&tsAudit.lock); + (void)taosThreadMutexUnlock(&tsAudit.lock); tsAudit.records = NULL; - taosThreadMutexDestroy(&tsAudit.lock); + (void)taosThreadMutexDestroy(&tsAudit.lock); } extern void auditRecordImp(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2, diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index 652bea3137..7e0710b05a 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -1034,7 +1034,7 @@ int32_t doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, S int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo, TSKEY* primaryKeys, int32_t prevPosition, int32_t order); -void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status); +int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status); bool getIgoreNullRes(SExprSupp* pExprSup); bool checkNullRow(SExprSupp* pExprSup, SSDataBlock* pSrcBlock, int32_t index, bool ignoreNull); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index b25f2732fc..9d6885510b 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -2300,21 +2300,29 @@ int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t } STableKeyInfo keyInfo = {.uid = uid, .groupId = gid}; - void* tmp = taosArrayPush(pTableList->pTableList, &keyInfo); + void* p = taosHashGet(pTableList->map, &uid, sizeof(uid)); + if (p != NULL) { + qInfo("table:%" PRId64 " already in tableIdList, ignore it", uid); + goto _end; + } + + void* tmp = taosArrayPush(pTableList->pTableList, &keyInfo); QUERY_CHECK_NULL(tmp, code, lino, _end, terrno); int32_t slot = (int32_t)taosArrayGetSize(pTableList->pTableList) - 1; code = taosHashPut(pTableList->map, &uid, sizeof(uid), &slot, sizeof(slot)); - if (code == TSDB_CODE_DUP_KEY) { - code = TSDB_CODE_SUCCESS; + if (code != TSDB_CODE_SUCCESS) { + ASSERT(code != TSDB_CODE_DUP_KEY); // we have checked the existence of uid in hash map above + taosArrayPopTailBatch(pTableList->pTableList, 1); // let's pop the last element in the array list } - QUERY_CHECK_CODE(code, lino, _end); _end: if (code != TSDB_CODE_SUCCESS) { qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } else { + qDebug("uid:%" PRIu64 ", groupId:%" PRIu64 " added into table list, slot:%d, total:%d", uid, gid, slot, slot + 1); } - qDebug("uid:%" PRIu64 ", groupId:%" PRIu64 " added into table list, slot:%d, total:%d", uid, gid, slot, slot + 1); + return code; } diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index dc910888ad..75c335a6a8 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -295,7 +295,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3 return NULL; } - createRawScanOperatorInfo(pReaderHandle, pTaskInfo, &pTaskInfo->pRoot); + code = createRawScanOperatorInfo(pReaderHandle, pTaskInfo, &pTaskInfo->pRoot); if (NULL == pTaskInfo->pRoot || code != 0) { taosMemoryFree(pTaskInfo); return NULL; @@ -1158,9 +1158,15 @@ SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) { return &pTaskInfo->streamInfo.btMetaRsp; } -void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { +int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset); + return 0; + /*if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + pTaskInfo->code = code; + T_LONG_JMP(pTaskInfo->env, code); + }*/ } int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) { @@ -1231,7 +1237,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT } if (subType == TOPIC_SUB_TYPE__COLUMN) { - extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id, &pOperator); + code = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id, &pOperator); if (pOperator == NULL || code != 0) { return code; } @@ -1431,8 +1437,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT } end: - tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset); - + (void) tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset); return 0; } diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index d56b288129..bceefd2c0d 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -75,7 +75,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { static int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); static int32_t initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); -static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); +static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol); @@ -193,7 +193,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; int32_t code = tSimpleHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, - sizeof(SResultRowPosition)); + sizeof(SResultRowPosition)); if (code != TSDB_CODE_SUCCESS) { qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); T_LONG_JMP(pTaskInfo->env, code); @@ -522,7 +522,7 @@ int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t n if (!pResInfo->initialized) { if (pCtx[i].functionId != -1) { int32_t code = pCtx[i].fpSet.init(&pCtx[i], pResInfo); - if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)){ + if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)) { pResInfo->initialized = false; return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } @@ -567,7 +567,8 @@ int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* p code = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status); QUERY_CHECK_CODE(code, lino, _err); - extractQualifiedTupleByFilterResult(pBlock, p, status); + code = extractQualifiedTupleByFilterResult(pBlock, p, status); + QUERY_CHECK_CODE(code, lino, _err); if (pColMatchInfo != NULL) { size_t size = taosArrayGetSize(pColMatchInfo->pList); @@ -591,18 +592,20 @@ _err: return code; } -void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) { +int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) { + int32_t code = TSDB_CODE_SUCCESS; int8_t* pIndicator = (int8_t*)p->pData; if (status == FILTER_RESULT_ALL_QUALIFIED) { // here nothing needs to be done } else if (status == FILTER_RESULT_NONE_QUALIFIED) { - trimDataBlock(pBlock, pBlock->info.rows, NULL); + code = trimDataBlock(pBlock, pBlock->info.rows, NULL); pBlock->info.rows = 0; } else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) { - trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator); + code = trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator); } else { qError("unknown filter result type: %d", status); } + return code; } void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) { @@ -639,7 +642,7 @@ void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultR pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset); if (pCtx[j].fpSet.finalize) { if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 || - strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) { + strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) { // for groupkey along with functions that output multiple lines(e.g. Histogram) // need to match groupkey result for each output row of that function. if (pCtx[j].resultInfo->numOfRes != 0) { @@ -678,7 +681,7 @@ _end: // todo refactor. SResultRow has direct pointer in miainfo void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup, - SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { + SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId); if (page == NULL) { qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); @@ -694,7 +697,7 @@ void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPositi doUpdateNumOfRows(pCtx, pRow, pSup->numOfExprs, rowEntryOffset); if (pRow->numOfRows == 0) { releaseBufPage(pBuf, page); - return ; + return; } int32_t size = pBlock->info.capacity; diff --git a/source/libs/executor/src/mergejoinoperator.c b/source/libs/executor/src/mergejoinoperator.c index 542f161a80..2c485cdd1b 100644 --- a/source/libs/executor/src/mergejoinoperator.c +++ b/source/libs/executor/src/mergejoinoperator.c @@ -308,12 +308,9 @@ int32_t mJoinFilterAndMarkHashRows(SSDataBlock* pBlock, SFilterInfo* pFilterInfo } } - extractQualifiedTupleByFilterResult(pBlock, p, status); - - code = TSDB_CODE_SUCCESS; + code = extractQualifiedTupleByFilterResult(pBlock, p, status); _err: - colDataDestroy(p); taosMemoryFree(p); @@ -375,12 +372,9 @@ int32_t mJoinFilterAndMarkRows(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SM } } - extractQualifiedTupleByFilterResult(pBlock, p, status); - - code = TSDB_CODE_SUCCESS; + code = extractQualifiedTupleByFilterResult(pBlock, p, status); _return: - colDataDestroy(p); taosMemoryFree(p); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 9f4f8bf60b..a7ddd8f97a 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1311,7 +1311,8 @@ static void destroyTableScanOperatorInfo(void* param) { } int32_t createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, + SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); int32_t code = TSDB_CODE_SUCCESS; @@ -1404,7 +1405,7 @@ _error: int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); - int32_t code = 0; + int32_t code = 0; STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -1422,7 +1423,7 @@ int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskIn *pOptrInfo = pOperator; return code; - _end: +_end: if (pInfo != NULL) { taosMemoryFree(pInfo); } @@ -2425,10 +2426,14 @@ _end: return code; } -static void doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeWindow* pWindow, const char* id) { +static int32_t doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeWindow* pWindow, const char* id) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; + bool* p = NULL; if (pWindow->skey != INT64_MIN || pWindow->ekey != INT64_MAX) { - bool* p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool)); - bool hasUnqualified = false; + p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool)); + QUERY_CHECK_NULL(p, code, lino, _end, terrno); + bool hasUnqualified = false; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, tsIndex); @@ -2457,19 +2462,28 @@ static void doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeW } if (hasUnqualified) { - trimDataBlock(pBlock, pBlock->info.rows, p); + code = trimDataBlock(pBlock, pBlock->info.rows, p); + QUERY_CHECK_CODE(code, lino, _end); } - - taosMemoryFree(p); } + +_end: + taosMemoryFree(p); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } -static void doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offset) { +static int32_t doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offset) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; if (pBlock->info.window.skey != offset->ts || offset->primaryKey.type == 0) { - return; + return code; } bool* p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool)); - bool hasUnqualified = false; + QUERY_CHECK_NULL(p, code, lino, _end, terrno); + bool hasUnqualified = false; SColumnInfoData* pColTs = taosArrayGet(pBlock->pDataBlock, 0); SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1); @@ -2497,16 +2511,26 @@ static void doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offse } if (hasUnqualified) { - trimDataBlock(pBlock, pBlock->info.rows, p); + code = trimDataBlock(pBlock, pBlock->info.rows, p); + QUERY_CHECK_CODE(code, lino, _end); } +_end: taosMemoryFree(p); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } // re-build the delete block, ONLY according to the split timestamp -static void rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, const char* id) { +static int32_t rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, const char* id) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; int32_t numOfRows = pBlock->info.rows; bool* p = taosMemoryCalloc(numOfRows, sizeof(bool)); + QUERY_CHECK_NULL(p, code, lino, _end, terrno); + bool hasUnqualified = false; int64_t skey = pWindow->skey; int64_t ekey = pWindow->ekey; @@ -2543,14 +2567,20 @@ static void rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, co } if (hasUnqualified) { - trimDataBlock(pBlock, pBlock->info.rows, p); + code = trimDataBlock(pBlock, pBlock->info.rows, p); qDebug("%s re-build delete datablock, start key revised to:%" PRId64 ", rows:%" PRId64, id, skey, pBlock->info.rows); + QUERY_CHECK_CODE(code, lino, _end); } else { qDebug("%s not update the delete block", id); } +_end: taosMemoryFree(p); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } static int32_t colIdComparFn(const void* param1, const void* param2) { @@ -2669,7 +2699,8 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock } // filter the block extracted from WAL files, according to the time window apply additional time window filter - doBlockDataWindowFilter(pInfo->pRes, pInfo->primaryTsIndex, pTimeWindow, id); + code = doBlockDataWindowFilter(pInfo->pRes, pInfo->primaryTsIndex, pTimeWindow, id); + QUERY_CHECK_CODE(code, lino, _end); pInfo->pRes->info.dataLoad = 1; code = blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); @@ -2688,14 +2719,19 @@ _end: return code; } -static void processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffsetVal* offset) { - SValue val = {0}; +static int32_t processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffsetVal* offset) { + int32_t code = TSDB_CODE_SUCCESS; + SValue val = {0}; if (hasPrimaryKey) { - doBlockDataPrimaryKeyFilter(pBlock, offset); + code = doBlockDataPrimaryKeyFilter(pBlock, offset); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + return code; + } SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1); if (pBlock->info.rows < 1) { - return; + return code; } void* tmp = colDataGetData(pColPk, pBlock->info.rows - 1); val.type = pColPk->info.type; @@ -2708,6 +2744,7 @@ static void processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffset } } tqOffsetResetToData(offset, pBlock->info.id.uid, pBlock->info.window.ekey, val); + return code; } static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { @@ -2723,7 +2760,7 @@ static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { if (isTaskKilled(pTaskInfo)) { (*ppRes) = NULL; - return code; + return pTaskInfo->code; } if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) { @@ -2732,9 +2769,9 @@ static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { if (pResult && pResult->info.rows > 0) { bool hasPrimaryKey = pAPI->tqReaderFn.tqGetTablePrimaryKey(pInfo->tqReader); - processPrimaryKey(pResult, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); - qDebug("tmqsnap doQueueScan get data uid:%" PRId64 "", pResult->info.id.uid); - if (pResult->info.rows > 0) { + code = processPrimaryKey(pResult, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); + qDebug("tmqsnap doQueueScan get data utid:%" PRId64 "", pResult->info.id.uid); + if (pResult->info.rows > 0 || code != TSDB_CODE_SUCCESS) { (*ppRes) = pResult; return code; } @@ -3168,7 +3205,8 @@ FETCH_NEXT_BLOCK: code = setBlockGroupIdByUid(pInfo, pDelBlock); QUERY_CHECK_CODE(code, lino, _end); - rebuildDeleteBlockData(pDelBlock, &pStreamInfo->fillHistoryWindow, id); + code = rebuildDeleteBlockData(pDelBlock, &pStreamInfo->fillHistoryWindow, id); + QUERY_CHECK_CODE(code, lino, _end); printSpecDataBlock(pDelBlock, getStreamOpName(pOperator->operatorType), "delete recv filtered", GET_TASKID(pTaskInfo)); if (pDelBlock->info.rows == 0) { @@ -3491,7 +3529,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { if (pBlock && pBlock->info.rows > 0) { bool hasPrimaryKey = pAPI->snapshotFn.taosXGetTablePrimaryKey(pInfo->sContext); - processPrimaryKey(pBlock, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); + code = processPrimaryKey(pBlock, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.id.uid); (*ppRes) = pBlock; return code; @@ -3505,7 +3543,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { tDeleteSchemaWrapper(mtInfo.schema); goto _end; } - STqOffsetVal offset = {0}; + STqOffsetVal offset = {0}; if (mtInfo.uid == 0 || pInfo->sContext->withMeta == ONLY_META) { // read snapshot done, change to get data from wal qDebug("tmqsnap read snapshot done, change to get data from wal"); tqOffsetResetToLog(&offset, pInfo->sContext->snapVersion + 1); @@ -3976,7 +4014,7 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* QUERY_CHECK_CODE(code, lino, _error); pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX}; - createSpecialDataBlock(STREAM_CLEAR, &pInfo->pUpdateDataRes); + code = createSpecialDataBlock(STREAM_CLEAR, &pInfo->pUpdateDataRes); QUERY_CHECK_CODE(code, lino, _error); if (hasPrimaryKeyCol(pInfo)) { @@ -4135,7 +4173,7 @@ static EDealRes tagScanRewriteTagColumn(SNode** pNode, void* pContext) { int32_t code = TSDB_CODE_SUCCESS; int32_t lino = 0; STagScanFilterContext* pCtx = (STagScanFilterContext*)pContext; - SColumnNode* pSColumnNode = NULL; + SColumnNode* pSColumnNode = NULL; if (QUERY_NODE_COLUMN == nodeType((*pNode))) { pSColumnNode = *(SColumnNode**)pNode; } else if (QUERY_NODE_FUNCTION == nodeType((*pNode))) { @@ -4496,8 +4534,8 @@ static void destroyTagScanOperatorInfo(void* param) { } int32_t createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pTagScanNode, - STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, - SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, + SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); int32_t code = TSDB_CODE_SUCCESS; @@ -5095,7 +5133,7 @@ _end: static SSDataBlock* doTableMergeScanParaSubTables(SOperatorInfo* pOperator) { SSDataBlock* pRes = NULL; - int32_t code = doTableMergeScanParaSubTablesNext(pOperator, &pRes); + int32_t code = doTableMergeScanParaSubTablesNext(pOperator, &pRes); return pRes; } @@ -5329,7 +5367,7 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { pInfo->pSortHandle = NULL; code = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage, - pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0, &pInfo->pSortHandle); + pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0, &pInfo->pSortHandle); if (code) { return code; } @@ -5581,7 +5619,7 @@ _end: static SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { SSDataBlock* pRes = NULL; - int32_t code = doTableMergeScanNext(pOperator, &pRes); + int32_t code = doTableMergeScanNext(pOperator, &pRes); return pRes; } @@ -5638,10 +5676,11 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla } int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, + SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); - int32_t code = 0; + int32_t code = 0; STableMergeScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableMergeScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -5653,7 +5692,7 @@ int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SR int32_t numOfCols = 0; code = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, - &pInfo->base.matchInfo); + &pInfo->base.matchInfo); int32_t lino = 0; if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -5879,7 +5918,7 @@ int32_t getTableCountScanSupp(SNodeList* groupTags, SName* tableName, SNodeList* } int32_t createTableCountScanOperatorInfo(SReadHandle* readHandle, STableCountScanPhysiNode* pTblCountScanNode, - SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); int32_t code = TSDB_CODE_SUCCESS; @@ -6052,7 +6091,7 @@ _end: } static int32_t doTableCountScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STableCountScanOperatorInfo* pInfo = pOperator->info; STableCountScanSupp* pSupp = &pInfo->supp; @@ -6074,7 +6113,7 @@ static int32_t doTableCountScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRe static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) { SSDataBlock* pRes = NULL; - int32_t code = doTableCountScanNext(pOperator, &pRes); + int32_t code = doTableCountScanNext(pOperator, &pRes); return pRes; } diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index c1d647d0bc..86fc323991 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -510,18 +510,16 @@ int32_t doStreamEventDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpera int32_t mapSize = 0; buf = taosDecodeFixedI32(buf, &mapSize); for (int32_t i = 0; i < mapSize; i++) { - SSessionKey key = {0}; SResultWindowInfo winfo = {0}; - buf = decodeSSessionKey(buf, &key); + buf = decodeSSessionKey(buf, &winfo.sessionWin); int32_t winCode = TSDB_CODE_SUCCESS; code = pAggSup->stateStore.streamStateSessionAddIfNotExist( pAggSup->pState, &winfo.sessionWin, pAggSup->gap, (void**)&winfo.pStatePos, &pAggSup->resultRowSize, &winCode); QUERY_CHECK_CODE(code, lino, _end); - ASSERT(winCode == TSDB_CODE_SUCCESS); buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize); code = - tSimpleHashPut(pInfo->streamAggSup.pResultRows, &key, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo)); + tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo)); QUERY_CHECK_CODE(code, lino, _end); } diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 42d6e50e2a..af2b45bf13 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -5195,7 +5195,7 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); pInfo->delIndex = 0; - createSpecialDataBlock(STREAM_DELETE_RESULT, &pInfo->pDelRes); + code = createSpecialDataBlock(STREAM_DELETE_RESULT, &pInfo->pDelRes); QUERY_CHECK_CODE(code, lino, _error); initResultRowInfo(&pInfo->binfo.resultRowInfo); diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 7c0ddb6175..66e503fd89 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -896,14 +896,14 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo } int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) { - int32_t code = 0, lino = 0; - SUdfColumnMeta* meta = &udfCol->colMeta; + int32_t code = 0, lino = 0; + SUdfColumnMeta *meta = &udfCol->colMeta; SColumnInfoData colInfoData = createColumnInfoData(meta->type, meta->bytes, 1); code = blockDataAppendColInfo(block, &colInfoData); TAOS_CHECK_GOTO(code, &lino, _exit); - code = blockDataEnsureCapacity(block, udfCol->colData.numOfRows); + code = blockDataEnsureCapacity(block, udfCol->colData.numOfRows); TAOS_CHECK_GOTO(code, &lino, _exit); SColumnInfoData *col = NULL; diff --git a/source/libs/index/inc/indexUtil.h b/source/libs/index/inc/indexUtil.h index 308e213ac9..6b016900c2 100644 --- a/source/libs/index/inc/indexUtil.h +++ b/source/libs/index/inc/indexUtil.h @@ -55,7 +55,7 @@ extern "C" { } \ } \ if (f == false) { \ - taosArrayPush(dst, &tgt); \ + (void)taosArrayPush(dst, &tgt); \ } \ } diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index fad04798a8..986693ab00 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -74,7 +74,7 @@ void indexCleanup() { // refacto later taosCleanUpScheduler(indexQhandle); taosMemoryFreeClear(indexQhandle); - taosCloseRef(indexRefMgt); + (void)taosCloseRef(indexRefMgt); } typedef struct SIdxColInfo { @@ -99,15 +99,15 @@ static void idxMergeCacheAndTFile(SArray* result, IterateValue* icache, IterateV static void idxPost(void* idx) { SIndex* pIdx = idx; - tsem_post(&pIdx->sem); + (void)tsem_post(&pIdx->sem); } static void indexWait(void* idx) { SIndex* pIdx = idx; - tsem_wait(&pIdx->sem); + (void)tsem_wait(&pIdx->sem); } int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { - taosThreadOnce(&isInit, indexEnvInit); + (void)taosThreadOnce(&isInit, indexEnvInit); int code = TSDB_CODE_SUCCESS; SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex)); @@ -137,8 +137,8 @@ int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, END); } - taosThreadMutexInit(&idx->mtx, NULL); - tsem_init(&idx->sem, 0, 0); + (void)taosThreadMutexInit(&idx->mtx, NULL); + (void)tsem_init(&idx->sem, 0, 0); idx->refId = idxAddRef(idx); idx->opts = *opts; @@ -158,8 +158,8 @@ END: void indexDestroy(void* handle) { if (handle == NULL) return; SIndex* idx = handle; - taosThreadMutexDestroy(&idx->mtx); - tsem_destroy(&idx->sem); + (void)taosThreadMutexDestroy(&idx->mtx); + (void)tsem_destroy(&idx->sem); idxTFileDestroy(idx->tindex); taosMemoryFree(idx->path); @@ -190,7 +190,7 @@ void indexClose(SIndex* sIdx) { } idxReleaseRef(sIdx->refId); - idxRemoveRef(sIdx->refId); + (void)idxRemoveRef(sIdx->refId); } int64_t idxAddRef(void* p) { // impl @@ -203,16 +203,16 @@ int32_t idxRemoveRef(int64_t ref) { void idxAcquireRef(int64_t ref) { // impl - taosAcquireRef(indexRefMgt, ref); + (void)taosAcquireRef(indexRefMgt, ref); } void idxReleaseRef(int64_t ref) { // impl - taosReleaseRef(indexRefMgt, ref); + (void)taosReleaseRef(indexRefMgt, ref); } int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { // TODO(yihao): reduce the lock range - taosThreadMutexLock(&index->mtx); + (void)taosThreadMutexLock(&index->mtx); for (int i = 0; i < taosArrayGetSize(fVals); i++) { SIndexTerm* p = taosArrayGetP(fVals, i); @@ -223,10 +223,10 @@ int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { IndexCache** cache = taosHashGet(index->colObj, buf, sz); if (cache == NULL) { IndexCache* pCache = idxCacheCreate(index, p->suid, p->colName, p->colType); - taosHashPut(index->colObj, buf, sz, &pCache, sizeof(void*)); + (void)taosHashPut(index->colObj, buf, sz, &pCache, sizeof(void*)); } } - taosThreadMutexUnlock(&index->mtx); + (void)taosThreadMutexUnlock(&index->mtx); for (int i = 0; i < taosArrayGetSize(fVals); i++) { SIndexTerm* p = taosArrayGetP(fVals, i); @@ -255,10 +255,10 @@ int32_t indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* re for (size_t i = 0; i < nQuery; i++) { SIndexTermQuery* qterm = taosArrayGet(multiQuerys->query, i); SArray* trslt = NULL; - idxTermSearch(index, qterm, &trslt); - taosArrayPush(iRslts, (void*)&trslt); + (void)idxTermSearch(index, qterm, &trslt); + (void)taosArrayPush(iRslts, (void*)&trslt); } - idxMergeFinalResults(iRslts, opera, result); + (void)idxMergeFinalResults(iRslts, opera, result); idxInterRsltDestroy(iRslts); return 0; } @@ -295,7 +295,7 @@ void indexMultiTermQueryDestroy(SIndexMultiTermQuery* pQuery) { }; int32_t indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EIndexQueryType qType) { SIndexTermQuery q = {.qType = qType, .term = term}; - taosArrayPush(pQuery->query, &q); + (void)taosArrayPush(pQuery->query, &q); return 0; } @@ -341,7 +341,7 @@ void indexTermDestroy(SIndexTerm* p) { SIndexMultiTerm* indexMultiTermCreate() { return taosArrayInit(4, sizeof(SIndexTerm*)); } int32_t indexMultiTermAdd(SIndexMultiTerm* terms, SIndexTerm* term) { - taosArrayPush(terms, &term); + (void)taosArrayPush(terms, &term); return 0; } void indexMultiTermDestroy(SIndexMultiTerm* terms) { @@ -374,7 +374,7 @@ void indexRebuild(SIndexJson* idx, void* iter) { schedMsg.fp = idxSchedRebuildIdx; schedMsg.ahandle = idx; idxAcquireRef(idx->refId); - taosScheduleTask(indexQhandle, &schedMsg); + (void)taosScheduleTask(indexQhandle, &schedMsg); } /* @@ -415,10 +415,10 @@ static int32_t idxTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** resu int32_t sz = idxSerialCacheKey(&key, buf); - taosThreadMutexLock(&sIdx->mtx); + (void)taosThreadMutexLock(&sIdx->mtx); IndexCache** pCache = taosHashGet(sIdx->colObj, buf, sz); cache = (pCache == NULL) ? NULL : *pCache; - taosThreadMutexUnlock(&sIdx->mtx); + (void)taosThreadMutexUnlock(&sIdx->mtx); *result = taosArrayInit(4, sizeof(uint64_t)); if (*result == NULL) { @@ -501,7 +501,7 @@ static void idxMayMergeTempToFinalRslt(SArray* result, TFileValue* tfv, SIdxTRsl idxTRsltMergeTo(tr, lv->tableId); idxTRsltClear(tr); - taosArrayPush(result, &tfv); + (void)taosArrayPush(result, &tfv); } else if (tfv == NULL) { // handle last iterator idxTRsltMergeTo(tr, lv->tableId); @@ -509,7 +509,7 @@ static void idxMayMergeTempToFinalRslt(SArray* result, TFileValue* tfv, SIdxTRsl tfileValueDestroy(tfv); } } else { - taosArrayPush(result, &tfv); + (void)taosArrayPush(result, &tfv); } } static void idxMergeCacheAndTFile(SArray* result, IterateValue* cv, IterateValue* tv, SIdxTRslt* tr) { @@ -528,7 +528,7 @@ static void idxMergeCacheAndTFile(SArray* result, IterateValue* cv, IterateValue } } if (tv != NULL) { - taosArrayAddAll(tr->total, tv->val); + (void)taosArrayAddAll(tr->total, tv->val); } } static void idxDestroyFinalRslt(SArray* result) { @@ -655,9 +655,9 @@ static int64_t idxGetAvailableVer(SIndex* sIdx, IndexCache* cache) { IndexTFile* tf = (IndexTFile*)(sIdx->tindex); - taosThreadMutexLock(&tf->mtx); + (void)taosThreadMutexLock(&tf->mtx); TFileReader* rd = tfileCacheGet(tf->cache, &key); - taosThreadMutexUnlock(&tf->mtx); + (void)taosThreadMutexUnlock(&tf->mtx); if (rd != NULL) { ver = (ver > rd->header.version ? ver : rd->header.version) + 1; @@ -698,9 +698,9 @@ static int32_t idxGenTFile(SIndex* sIdx, IndexCache* cache, SArray* batch) { TFileHeader* header = &reader->header; ICacheKey key = {.suid = cache->suid, .colName = header->colName, .nColName = strlen(header->colName)}; - taosThreadMutexLock(&tf->mtx); + (void)taosThreadMutexLock(&tf->mtx); code = tfileCachePut(tf->cache, &key, reader); - taosThreadMutexUnlock(&tf->mtx); + (void)taosThreadMutexUnlock(&tf->mtx); return code; @@ -717,7 +717,7 @@ int32_t idxSerialCacheKey(ICacheKey* key, char* buf) { char* p = buf; char tbuf[65] = {0}; - idxInt2str((int64_t)key->suid, tbuf, 0); + (void)idxInt2str((int64_t)key->suid, tbuf, 0); SERIALIZE_STR_VAR_TO_BUF(buf, tbuf, strlen(tbuf)); SERIALIZE_VAR_TO_BUF(buf, '_', char); diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index f2aefcfc41..adf555edd2 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -104,7 +104,7 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe } taosMemoryFree(pCt); - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); return 0; } static int32_t cacheSearchPrefix(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) { @@ -162,7 +162,7 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt* } } taosMemoryFree(pCt); - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); return TSDB_CODE_SUCCESS; } static int32_t cacheSearchLessThan(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) { @@ -222,7 +222,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr taosMemoryFree(pCt); taosMemoryFree(exBuf); - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); return 0; return TSDB_CODE_SUCCESS; @@ -329,7 +329,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR taosMemoryFree(pCt); taosMemoryFree(exBuf); - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); return TSDB_CODE_SUCCESS; } @@ -356,8 +356,8 @@ IndexCache* idxCacheCreate(SIndex* idx, uint64_t suid, const char* colName, int8 cache->suid = suid; cache->occupiedMem = 0; - taosThreadMutexInit(&cache->mtx, NULL); - taosThreadCondInit(&cache->finished, NULL); + (void)taosThreadMutexInit(&cache->mtx, NULL); + (void)taosThreadCondInit(&cache->finished, NULL); idxCacheRef(cache); if (idx != NULL) { @@ -368,10 +368,10 @@ IndexCache* idxCacheCreate(SIndex* idx, uint64_t suid, const char* colName, int8 void idxCacheDebug(IndexCache* cache) { MemTable* tbl = NULL; - taosThreadMutexLock(&cache->mtx); + (void)taosThreadMutexLock(&cache->mtx); tbl = cache->mem; idxMemRef(tbl); - taosThreadMutexUnlock(&cache->mtx); + (void)taosThreadMutexUnlock(&cache->mtx); { SSkipList* slt = tbl->mem; @@ -384,16 +384,16 @@ void idxCacheDebug(IndexCache* cache) { indexInfo("{colVal: %s, version: %" PRId64 "} \t", ct->colVal, ct->version); } } - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); idxMemUnRef(tbl); } { - taosThreadMutexLock(&cache->mtx); + (void)taosThreadMutexLock(&cache->mtx); tbl = cache->imm; idxMemRef(tbl); - taosThreadMutexUnlock(&cache->mtx); + (void)taosThreadMutexUnlock(&cache->mtx); if (tbl != NULL) { SSkipList* slt = tbl->mem; SSkipListIterator* iter = tSkipListCreateIter(slt); @@ -405,7 +405,7 @@ void idxCacheDebug(IndexCache* cache) { indexInfo("{colVal: %s, version: %" PRId64 "} \t", ct->colVal, ct->version); } } - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); } idxMemUnRef(tbl); @@ -422,29 +422,29 @@ void idxCacheDestroySkiplist(SSkipList* slt) { taosMemoryFree(ct); } } - tSkipListDestroyIter(iter); + (void)tSkipListDestroyIter(iter); tSkipListDestroy(slt); } void idxCacheBroadcast(void* cache) { IndexCache* pCache = cache; - taosThreadCondBroadcast(&pCache->finished); + (void)taosThreadCondBroadcast(&pCache->finished); } void idxCacheWait(void* cache) { IndexCache* pCache = cache; - taosThreadCondWait(&pCache->finished, &pCache->mtx); + (void)taosThreadCondWait(&pCache->finished, &pCache->mtx); } void idxCacheDestroyImm(IndexCache* cache) { if (cache == NULL) { return; } MemTable* tbl = NULL; - taosThreadMutexLock(&cache->mtx); + (void)taosThreadMutexLock(&cache->mtx); tbl = cache->imm; cache->imm = NULL; // or throw int bg thread idxCacheBroadcast(cache); - taosThreadMutexUnlock(&cache->mtx); + (void)taosThreadMutexUnlock(&cache->mtx); idxMemUnRef(tbl); idxMemUnRef(tbl); @@ -459,8 +459,8 @@ void idxCacheDestroy(void* cache) { idxMemUnRef(pCache->imm); taosMemoryFree(pCache->colName); - taosThreadMutexDestroy(&pCache->mtx); - taosThreadCondDestroy(&pCache->finished); + (void)taosThreadMutexDestroy(&pCache->mtx); + (void)taosThreadCondDestroy(&pCache->finished); if (pCache->index != NULL) { idxReleaseRef(((SIndex*)pCache->index)->refId); } @@ -475,7 +475,7 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) { if (iter == NULL) { return NULL; } - taosThreadMutexLock(&cache->mtx); + (void)taosThreadMutexLock(&cache->mtx); idxMemRef(cache->imm); @@ -486,7 +486,7 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) { iter->next = idxCacheIteratorNext; iter->getValue = idxCacheIteratorGetValue; - taosThreadMutexUnlock(&cache->mtx); + (void)taosThreadMutexUnlock(&cache->mtx); return iter; } @@ -494,7 +494,7 @@ void idxCacheIteratorDestroy(Iterate* iter) { if (iter == NULL) { return; } - tSkipListDestroyIter(iter->iter); + (void)tSkipListDestroyIter(iter->iter); iterateValueDestroy(&iter->val, true); taosMemoryFree(iter); } @@ -508,7 +508,7 @@ int idxCacheSchedToMerge(IndexCache* pCache, bool notify) { } schedMsg.msg = NULL; idxAcquireRef(pCache->index->refId); - taosScheduleTask(indexQhandle, &schedMsg); + (void)taosScheduleTask(indexQhandle, &schedMsg); return 0; } @@ -533,7 +533,7 @@ static void idxCacheMakeRoomForWrite(IndexCache* cache) { } // 1. sched to merge // 2. unref cache in bgwork - idxCacheSchedToMerge(cache, quit); + (void)idxCacheSchedToMerge(cache, quit); } } } @@ -548,7 +548,7 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // encode data CacheTerm* ct = taosMemoryCalloc(1, sizeof(CacheTerm)); if (ct == NULL) { - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } // set up key ct->colType = term->colType; @@ -556,6 +556,10 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { ct->colVal = idxPackJsonData(term); } else { ct->colVal = (char*)taosMemoryCalloc(1, sizeof(char) * (term->nColVal + 1)); + if (ct->colVal == NULL) { + taosMemoryFree(ct); + return TSDB_CODE_OUT_OF_MEMORY; + } memcpy(ct->colVal, term->colVal, term->nColVal); } ct->version = atomic_add_fetch_64(&pCache->version, 1); @@ -565,15 +569,15 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // ugly code, refactor later int64_t estimate = sizeof(ct) + strlen(ct->colVal); - taosThreadMutexLock(&pCache->mtx); + (void)taosThreadMutexLock(&pCache->mtx); pCache->occupiedMem += estimate; idxCacheMakeRoomForWrite(pCache); MemTable* tbl = pCache->mem; idxMemRef(tbl); - tSkipListPut(tbl->mem, (char*)ct); + (void)tSkipListPut(tbl->mem, (char*)ct); idxMemUnRef(tbl); - taosThreadMutexUnlock(&pCache->mtx); + (void)taosThreadMutexUnlock(&pCache->mtx); idxCacheUnRef(pCache); return 0; } @@ -581,13 +585,13 @@ void idxCacheForceToMerge(void* cache) { IndexCache* pCache = cache; idxCacheRef(pCache); - taosThreadMutexLock(&pCache->mtx); + (void)taosThreadMutexLock(&pCache->mtx); indexInfo("%p is forced to merge into tfile", pCache); pCache->occupiedMem += MEM_SIGNAL_QUIT; idxCacheMakeRoomForWrite(pCache); - taosThreadMutexUnlock(&pCache->mtx); + (void)taosThreadMutexUnlock(&pCache->mtx); idxCacheUnRef(pCache); return; } @@ -618,12 +622,12 @@ int idxCacheSearch(void* cache, SIndexTermQuery* query, SIdxTRslt* result, STerm IndexCache* pCache = cache; MemTable *mem = NULL, *imm = NULL; - taosThreadMutexLock(&pCache->mtx); + (void)taosThreadMutexLock(&pCache->mtx); mem = pCache->mem; imm = pCache->imm; idxMemRef(mem); idxMemRef(imm); - taosThreadMutexUnlock(&pCache->mtx); + (void)taosThreadMutexUnlock(&pCache->mtx); int64_t st = taosGetTimestampUs(); @@ -759,7 +763,7 @@ static void idxDoMergeWork(SSchedMsg* msg) { int quit = msg->thandle ? true : false; taosMemoryFree(msg->thandle); - idxFlushCacheToTFile(sidx, pCache, quit); + (void)idxFlushCacheToTFile(sidx, pCache, quit); } static bool idxCacheIteratorNext(Iterate* itera) { SSkipListIterator* iter = itera->iter; @@ -777,7 +781,7 @@ static bool idxCacheIteratorNext(Iterate* itera) { iv->type = ct->operaType; iv->ver = ct->version; iv->colVal = taosStrdup(ct->colVal); - taosArrayPush(iv->val, &ct->uid); + (void)taosArrayPush(iv->val, &ct->uid); } return next; } diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index b7b9f1cc9f..6337b2c556 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -378,6 +378,9 @@ int32_t idxConvertData(void* src, int8_t type, void** dst) { int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (src == NULL) { *dst = strndup(INDEX_DATA_NULL_STR, (int)strlen(INDEX_DATA_NULL_STR)); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } return (int32_t)strlen(INDEX_DATA_NULL_STR); } int tlen = tDataTypes[type].bytes; @@ -385,63 +388,96 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { switch (type) { case TSDB_DATA_TYPE_TIMESTAMP: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(int64_t*)src, *dst, -1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(int64_t*)src, *dst, -1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_UTINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(uint8_t*)src, *dst, 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(uint8_t*)src, *dst, 1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_TINYINT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(int8_t*)src, *dst, 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(int8_t*)src, *dst, 1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_SMALLINT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(int16_t*)src, *dst, -1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(int16_t*)src, *dst, -1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_USMALLINT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(uint16_t*)src, *dst, -1); + (void)idxInt2str(*(uint16_t*)src, *dst, -1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_INT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(int32_t*)src, *dst, -1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(int32_t*)src, *dst, -1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_UINT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(uint32_t*)src, *dst, 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(uint32_t*)src, *dst, 1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_BIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } sprintf(*dst, "%" PRIu64, *(uint64_t*)src); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_UBIGINT: *dst = taosMemoryCalloc(1, bufSize + 1); - idxInt2str(*(uint64_t*)src, *dst, 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + (void)idxInt2str(*(uint64_t*)src, *dst, 1); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_FLOAT: *dst = taosMemoryCalloc(1, bufSize + 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } sprintf(*dst, "%.9lf", *(float*)src); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_DOUBLE: *dst = taosMemoryCalloc(1, bufSize + 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } sprintf(*dst, "%.9lf", *(double*)src); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_NCHAR: { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; break; @@ -451,6 +487,9 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { case TSDB_DATA_TYPE_GEOMETRY: { tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src)); *dst = taosMemoryCalloc(1, tlen + 1); + if (*dst == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src)); *dst = (char*)*dst - tlen; break; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index a7e539efc6..9563b91593 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -646,7 +646,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP } SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST); - indexMultiTermQueryAdd(mtm, tm, qtype); + (void)indexMultiTermQueryAdd(mtm, tm, qtype); ret = indexJsonSearch(arg->ivtIdx, mtm, output->result); indexMultiTermQueryDestroy(mtm); } else { @@ -882,9 +882,9 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou if (ctx->noExec == false) { for (int32_t m = 0; m < node->pParameterList->length; m++) { if (node->condType == LOGIC_COND_TYPE_AND) { - taosArrayAddAll(output->result, params[m].result); + (void)taosArrayAddAll(output->result, params[m].result); } else if (node->condType == LOGIC_COND_TYPE_OR) { - taosArrayAddAll(output->result, params[m].result); + (void)taosArrayAddAll(output->result, params[m].result); } else if (node->condType == LOGIC_COND_TYPE_NOT) { // taosArrayAddAll(output->result, params[m].result); } @@ -1018,12 +1018,12 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { SIF_ERR_RET(TSDB_CODE_APP_ERROR); } if (res->result != NULL) { - taosArrayAddAll(pDst->result, res->result); + (void)taosArrayAddAll(pDst->result, res->result); } pDst->status = res->status; sifFreeParam(res); - taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); + (void)taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); } sifFreeRes(ctx.pRes); return code; @@ -1055,7 +1055,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status, SMetaDataFilte } *status = res->status; sifFreeParam(res); - taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); + (void)taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); void *iter = taosHashIterate(ctx.pRes, NULL); while (iter != NULL) { @@ -1090,7 +1090,7 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, *status = st; } - taosArrayAddAll(result, param.result); + (void)taosArrayAddAll(result, param.result); sifFreeParam(¶m); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/index/src/indexFst.c b/source/libs/index/src/indexFst.c index f3b7b2fbae..54d28f4784 100644 --- a/source/libs/index/src/indexFst.c +++ b/source/libs/index/src/indexFst.c @@ -62,7 +62,7 @@ void fstUnFinishedNodesPushEmpty(FstUnFinishedNodes* nodes, bool isFinal) { node->trans = taosArrayInit(16, sizeof(FstTransition)); FstBuilderNodeUnfinished un = {.node = node, .last = NULL}; - taosArrayPush(nodes->stack, &un); + (void)taosArrayPush(nodes->stack, &un); } FstBuilderNode* fstUnFinishedNodesPopRoot(FstUnFinishedNodes* nodes) { FstBuilderNodeUnfinished* un = taosArrayPop(nodes->stack); @@ -120,7 +120,7 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes* nodes, FstSlice bs, Output FstLastTransition* trn = fstLastTransitionCreate(data[i], 0); FstBuilderNodeUnfinished un = {.node = n, .last = trn}; - taosArrayPush(nodes->stack, &un); + (void)taosArrayPush(nodes->stack, &un); } fstUnFinishedNodesPushEmpty(nodes, true); } @@ -214,9 +214,9 @@ void fstStateCompileForOneTransNext(IdxFstFile* w, CompiledAddr addr, uint8_t in uint8_t v = fstStateCommInput(&s, &null); if (null) { // w->write_all(&[inp]) - idxFileWrite(w, &inp, 1); + (void)idxFileWrite(w, &inp, 1); } - idxFileWrite(w, &(s.val), 1); + (void)idxFileWrite(w, &(s.val), 1); // w->write_all(&[s.val]) return; } @@ -228,7 +228,7 @@ void fstStateCompileForOneTrans(IdxFstFile* w, CompiledAddr addr, FstTransition* FST_SET_OUTPUT_PACK_SIZE(packSizes, outPackSize); FST_SET_TRANSITION_PACK_SIZE(packSizes, transPackSize); - idxFileWrite(w, (char*)&packSizes, sizeof(packSizes)); + (void)idxFileWrite(w, (char*)&packSizes, sizeof(packSizes)); FstState st = fstStateCreate(OneTrans); @@ -237,9 +237,9 @@ void fstStateCompileForOneTrans(IdxFstFile* w, CompiledAddr addr, FstTransition* bool null = false; uint8_t inp = fstStateCommInput(&st, &null); if (null == true) { - idxFileWrite(w, (char*)&trn->inp, sizeof(trn->inp)); + (void)idxFileWrite(w, (char*)&trn->inp, sizeof(trn->inp)); } - idxFileWrite(w, (char*)(&(st.val)), sizeof(st.val)); + (void)idxFileWrite(w, (char*)(&(st.val)), sizeof(st.val)); return; } void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode* node) { @@ -285,7 +285,7 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode } for (int32_t i = sz - 1; i >= 0; i--) { FstTransition* t = taosArrayGet(node->trans, i); - idxFileWrite(w, (char*)&t->inp, 1); + (void)idxFileWrite(w, (char*)&t->inp, 1); } if (sz > TRANS_INDEX_THRESHOLD) { // A value of 255 indicates that no transition exists for the byte at that idx @@ -295,24 +295,24 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode FstTransition* t = taosArrayGet(node->trans, i); index[t->inp] = i; } - idxFileWrite(w, (char*)index, 256); + (void)idxFileWrite(w, (char*)index, 256); taosMemoryFree(index); } - idxFileWrite(w, (char*)&packSizes, 1); + (void)idxFileWrite(w, (char*)&packSizes, 1); bool null = false; - fstStateStateNtrans(&st, &null); + (void)fstStateStateNtrans(&st, &null); if (null == true) { // 256 can't be represented in a u8, so we abuse the fact that // the # of transitions can never be 1 here, since 1 is always // encoded in the state byte. uint8_t v = 1; if (sz == 256) { - idxFileWrite(w, (char*)&v, 1); + (void)idxFileWrite(w, (char*)&v, 1); } else { - idxFileWrite(w, (char*)&sz, 1); + (void)idxFileWrite(w, (char*)&sz, 1); } } - idxFileWrite(w, (char*)(&(st.val)), 1); + (void)idxFileWrite(w, (char*)(&(st.val)), 1); return; } @@ -342,7 +342,7 @@ uint8_t fstStateCommInput(FstState* s, bool* null) { uint64_t fstStateInputLen(FstState* s) { ASSERT(s->state == OneTransNext || s->state == OneTrans); bool null = false; - fstStateCommInput(s, &null); + (void)fstStateCommInput(s, &null); return null ? 1 : 0; } @@ -499,7 +499,7 @@ uint64_t fstStateTransIndexSize(FstState* s, uint64_t version, uint64_t nTrans) uint64_t fstStateNtransLen(FstState* s) { ASSERT(s->state == AnyTrans); bool null = false; - fstStateStateNtrans(s, &null); + (void)fstStateStateNtrans(s, &null); return null == true ? 1 : 0; } uint64_t fstStateNtrans(FstState* s, FstSlice* slice) { @@ -673,12 +673,12 @@ bool fstNodeGetTransitionAddrAt(FstNode* node, uint64_t i, CompiledAddr* res) { FstState* st = &node->state; if (st->state == OneTransNext) { ASSERT(i == 0); - fstStateTransAddr(st, node); + (void)fstStateTransAddr(st, node); } else if (st->state == OneTrans) { ASSERT(i == 0); - fstStateTransAddr(st, node); + (void)fstStateTransAddr(st, node); } else if (st->state == AnyTrans) { - fstStateTransAddrForAnyTrans(st, node, i); + (void)fstStateTransAddrForAnyTrans(st, node, i); } else if (FST_STATE_EMPTY_FINAL(node)) { s = false; } else { @@ -755,13 +755,13 @@ FstBuilder* fstBuilderCreate(void* w, FstType ty) { char buf64[8] = {0}; void* pBuf64 = buf64; - taosEncodeFixedU64(&pBuf64, VERSION); - idxFileWrite(b->wrt, buf64, sizeof(buf64)); + (void)taosEncodeFixedU64(&pBuf64, VERSION); + (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); pBuf64 = buf64; memset(buf64, 0, sizeof(buf64)); - taosEncodeFixedU64(&pBuf64, ty); - idxFileWrite(b->wrt, buf64, sizeof(buf64)); + (void)taosEncodeFixedU64(&pBuf64, ty); + (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); return b; } @@ -862,7 +862,7 @@ CompiledAddr fstBuilderCompile(FstBuilder* b, FstBuilderNode* bn) { } CompiledAddr startAddr = (CompiledAddr)(FST_WRITER_COUNT(b->wrt)); - fstBuilderNodeCompileTo(bn, b->wrt, b->lastAddr, startAddr); + (void)fstBuilderNodeCompileTo(bn, b->wrt, b->lastAddr, startAddr); b->lastAddr = (CompiledAddr)(FST_WRITER_COUNT(b->wrt) - 1); if (entry->state == NOTFOUND) { FST_REGISTRY_CELL_INSERT(entry->cell, b->lastAddr); @@ -881,23 +881,23 @@ void* fstBuilderInsertInner(FstBuilder* b) { char buf64[8] = {0}; void* pBuf64 = buf64; - taosEncodeFixedU64(&pBuf64, b->len); - idxFileWrite(b->wrt, buf64, sizeof(buf64)); + (void)taosEncodeFixedU64(&pBuf64, b->len); + (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); pBuf64 = buf64; - taosEncodeFixedU64(&pBuf64, rootAddr); - idxFileWrite(b->wrt, buf64, sizeof(buf64)); + (void)taosEncodeFixedU64(&pBuf64, rootAddr); + (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); char buf32[4] = {0}; void* pBuf32 = buf32; uint32_t sum = idxFileMaskedCheckSum(b->wrt); - taosEncodeFixedU32(&pBuf32, sum); - idxFileWrite(b->wrt, buf32, sizeof(buf32)); + (void)taosEncodeFixedU32(&pBuf32, sum); + (void)idxFileWrite(b->wrt, buf32, sizeof(buf32)); - idxFileFlush(b->wrt); + (void)idxFileFlush(b->wrt); return b->wrt; } -void fstBuilderFinish(FstBuilder* b) { fstBuilderInsertInner(b); } +void fstBuilderFinish(FstBuilder* b) { (void)fstBuilderInsertInner(b); } FstSlice fstNodeAsSlice(FstNode* node) { FstSlice* slice = &node->data; @@ -924,7 +924,7 @@ void fstBuilderNodeUnfinishedLastCompiled(FstBuilderNodeUnfinished* unNode, Comp return; } FstTransition t = {.inp = trn->inp, .out = trn->out, .addr = addr}; - taosArrayPush(unNode->node->trans, &t); + (void)taosArrayPush(unNode->node->trans, &t); fstLastTransitionDestroy(trn); unNode->last = NULL; return; @@ -955,19 +955,19 @@ Fst* fstCreate(FstSlice* slice) { uint64_t skip = 0; uint64_t version; - taosDecodeFixedU64(buf, &version); + (void)taosDecodeFixedU64(buf, &version); skip += sizeof(version); if (version == 0 || version > VERSION) { return NULL; } uint64_t type; - taosDecodeFixedU64(buf + skip, &type); + (void)taosDecodeFixedU64(buf + skip, &type); skip += sizeof(type); uint32_t checkSum = 0; len -= sizeof(checkSum); - taosDecodeFixedU32(buf + len, &checkSum); + (void)taosDecodeFixedU32(buf + len, &checkSum); if (taosCheckChecksum(buf, len, checkSum)) { indexError("index file is corrupted"); // verify fst @@ -975,11 +975,11 @@ Fst* fstCreate(FstSlice* slice) { } CompiledAddr rootAddr; len -= sizeof(rootAddr); - taosDecodeFixedU64(buf + len, &rootAddr); + (void)taosDecodeFixedU64(buf + len, &rootAddr); uint64_t fstLen; len -= sizeof(fstLen); - taosDecodeFixedU64(buf + len, &fstLen); + (void)taosDecodeFixedU64(buf + len, &fstLen); // TODO(validate root addr) Fst* fst = (Fst*)taosMemoryCalloc(1, sizeof(Fst)); if (fst == NULL) { @@ -1001,7 +1001,7 @@ Fst* fstCreate(FstSlice* slice) { *s = fstSliceCopy(slice, 0, FST_SLICE_LEN(slice) - 1); fst->data = s; - taosThreadMutexInit(&fst->mtx, NULL); + (void)taosThreadMutexInit(&fst->mtx, NULL); return fst; FST_CREAT_FAILED: @@ -1015,7 +1015,7 @@ void fstDestroy(Fst* fst) { taosMemoryFree(fst->meta); fstSliceDestroy(fst->data); taosMemoryFree(fst->data); - taosThreadMutexDestroy(&fst->mtx); + (void)taosThreadMutexDestroy(&fst->mtx); } taosMemoryFree(fst); } @@ -1029,7 +1029,7 @@ bool fstGet(Fst* fst, FstSlice* b, Output* out) { uint8_t* data = fstSliceData(b, &len); SArray* nodes = (SArray*)taosArrayInit(len, sizeof(FstNode*)); - taosArrayPush(nodes, &root); + (void)taosArrayPush(nodes, &root); for (uint32_t i = 0; i < len; i++) { uint8_t inp = data[i]; Output res = 0; @@ -1038,10 +1038,10 @@ bool fstGet(Fst* fst, FstSlice* b, Output* out) { } FstTransition trn; - fstNodeGetTransitionAt(root, res, &trn); + (void)fstNodeGetTransitionAt(root, res, &trn); tOut += trn.out; root = fstGetNode(fst, trn.addr); - taosArrayPush(nodes, &root); + (void)taosArrayPush(nodes, &root); } if (!FST_NODE_IS_FINAL(root)) { goto _return; @@ -1163,7 +1163,7 @@ FStmSt* stmStCreate(Fst* fst, FAutoCtx* automation, FstBoundWithData* min, FstBo sws->stack = (SArray*)taosArrayInit(256, sizeof(FstStreamState)); sws->endAt = max; - stmStSeekMin(sws, min); + (void)stmStSeekMin(sws, min); return sws; } @@ -1188,7 +1188,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { .trans = 0, .out = {.null = false, .out = 0}, .autState = automFuncs[aut->type].start(aut)}; // auto.start callback - taosArrayPush(sws->stack, &s); + (void)taosArrayPush(sws->stack, &s); return true; } FstSlice* key = NULL; @@ -1214,15 +1214,15 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { uint64_t res = 0; if (fstNodeFindInput(node, b, &res)) { FstTransition trn; - fstNodeGetTransitionAt(node, res, &trn); + (void)fstNodeGetTransitionAt(node, res, &trn); void* preState = autState; autState = automFuncs[aut->type].accept(aut, preState, b); - taosArrayPush(sws->inp, &b); + (void)taosArrayPush(sws->inp, &b); FstStreamState s = {.node = node, .trans = res + 1, .out = {.null = false, .out = out}, .autState = preState}; node = NULL; - taosArrayPush(sws->stack, &s); + (void)taosArrayPush(sws->stack, &s); out += trn.out; node = fstGetNode(sws->fst, trn.addr); } else { @@ -1241,7 +1241,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { } FstStreamState s = {.node = node, .trans = i, .out = {.null = false, .out = out}, .autState = autState}; - taosArrayPush(sws->stack, &s); + (void)taosArrayPush(sws->stack, &s); taosMemoryFree(trans); return true; } @@ -1254,15 +1254,15 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { FstStreamState* s = taosArrayGet(sws->stack, sz - 1); if (inclusize) { s->trans -= 1; - taosArrayPop(sws->inp); + (void)taosArrayPop(sws->inp); } else { FstNode* n = s->node; uint64_t trans = s->trans; FstTransition trn; - fstNodeGetTransitionAt(n, trans - 1, &trn); + (void)fstNodeGetTransitionAt(n, trans - 1, &trn); FstStreamState s = { .node = fstGetNode(sws->fst, trn.addr), .trans = 0, .out = {.null = false, .out = out}, .autState = autState}; - taosArrayPush(sws->stack, &s); + (void)taosArrayPush(sws->stack, &s); return true; } return false; @@ -1291,13 +1291,13 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) { FstStreamState* p = (FstStreamState*)taosArrayPop(sws->stack); if (p->trans >= FST_NODE_LEN(p->node) || !automFuncs[aut->type].canMatch(aut, p->autState)) { if (FST_NODE_ADDR(p->node) != fstGetRootAddr(sws->fst)) { - taosArrayPop(sws->inp); + (void)taosArrayPop(sws->inp); } fstStreamStateDestroy(p); continue; } FstTransition trn; - fstNodeGetTransitionAt(p->node, p->trans, &trn); + (void)fstNodeGetTransitionAt(p->node, p->trans, &trn); Output out = p->out.out + trn.out; void* nextState = automFuncs[aut->type].accept(aut, p->autState, trn.inp); @@ -1305,8 +1305,8 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) { bool isMatch = automFuncs[aut->type].isMatch(aut, nextState); FstNode* nextNode = fstGetNode(sws->fst, trn.addr); - taosArrayPush(nodes, &nextNode); - taosArrayPush(sws->inp, &(trn.inp)); + (void)taosArrayPush(nodes, &nextNode); + (void)taosArrayPush(sws->inp, &(trn.inp)); if (FST_NODE_IS_FINAL(nextNode)) { void* eofState = automFuncs[aut->type].acceptEof(aut, nextState); @@ -1315,10 +1315,10 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) { } } FstStreamState s1 = {.node = p->node, .trans = p->trans + 1, .out = p->out, .autState = p->autState}; - taosArrayPush(sws->stack, &s1); + (void)taosArrayPush(sws->stack, &s1); FstStreamState s2 = {.node = nextNode, .trans = 0, .out = {.null = false, .out = out}, .autState = nextState}; - taosArrayPush(sws->stack, &s2); + (void)taosArrayPush(sws->stack, &s2); int32_t isz = taosArrayGetSize(sws->inp); uint8_t* buf = (uint8_t*)taosMemoryMalloc(isz * sizeof(uint8_t)); diff --git a/source/libs/index/src/indexFstDfa.c b/source/libs/index/src/indexFstDfa.c index a3e26d8518..f552d5feba 100644 --- a/source/libs/index/src/indexFstDfa.c +++ b/source/libs/index/src/indexFstDfa.c @@ -74,7 +74,7 @@ FstDfa *dfaBuilderBuild(FstDfaBuilder *builder) { uint32_t result; SArray *states = taosArrayInit(0, sizeof(uint32_t)); if (dfaBuilderCacheState(builder, cur, &result)) { - taosArrayPush(states, &result); + (void)taosArrayPush(states, &result); } SHashObj *seen = taosHashInit(12, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); while (taosArrayGetSize(states) != 0) { @@ -83,8 +83,8 @@ FstDfa *dfaBuilderBuild(FstDfaBuilder *builder) { uint32_t ns, dummpy = 0; if (dfaBuilderRunState(builder, cur, nxt, result, i, &ns)) { if (taosHashGet(seen, &ns, sizeof(ns)) == NULL) { - taosHashPut(seen, &ns, sizeof(ns), &dummpy, sizeof(dummpy)); - taosArrayPush(states, &ns); + (void)taosHashPut(seen, &ns, sizeof(ns), &dummpy, sizeof(dummpy)); + (void)taosArrayPush(states, &ns); } } if (taosArrayGetSize(builder->dfa->states) > STATE_LIMIT) { @@ -108,7 +108,7 @@ bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet bool succ = sparSetAdd(cur, ip, NULL); if (succ == false) return false; } - dfaRun(builder->dfa, cur, next, byte); + (void)dfaRun(builder->dfa, cur, next, byte); t = taosArrayGet(builder->dfa->states, state); @@ -133,10 +133,10 @@ bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *r if (inst->ty == JUMP || inst->ty == SPLIT) { continue; } else if (inst->ty == RANGE) { - taosArrayPush(tinsts, &ip); + (void)taosArrayPush(tinsts, &ip); } else if (inst->ty == MATCH) { isMatch = true; - taosArrayPush(tinsts, &ip); + (void)taosArrayPush(tinsts, &ip); } } if (taosArrayGetSize(tinsts) == 0) { @@ -149,10 +149,10 @@ bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *r taosArrayDestroy(tinsts); } else { DfaState st = {.insts = tinsts, .isMatch = isMatch}; - taosArrayPush(builder->dfa->states, &st); + (void)taosArrayPush(builder->dfa->states, &st); int32_t sz = taosArrayGetSize(builder->dfa->states) - 1; - taosHashPut(builder->cache, &tinsts, sizeof(POINTER_BYTES), &sz, sizeof(sz)); + (void)taosHashPut(builder->cache, &tinsts, sizeof(POINTER_BYTES), &sz, sizeof(sz)); *result = sz; } return true; @@ -187,7 +187,7 @@ void dfaAdd(FstDfa *dfa, FstSparseSet *set, uint32_t ip) { if (sparSetContains(set, ip)) { return; } - bool succ = sparSetAdd(set, ip, NULL); + bool succ = sparSetAdd(set, ip, NULL); Inst *inst = taosArrayGet(dfa->insts, ip); if (inst->ty == MATCH || inst->ty == RANGE) { // do nothing diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index d86b3d476f..69fee8d29d 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -38,7 +38,7 @@ static FORCE_INLINE void idxGenLRUKey(char* buf, const char* path, int32_t block char* p = buf; SERIALIZE_STR_VAR_TO_BUF(p, path, strlen(path)); SERIALIZE_VAR_TO_BUF(p, '_', char); - idxInt2str(blockId, p, 0); + (void)idxInt2str(blockId, p, 0); return; } static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) { @@ -48,7 +48,7 @@ static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) if (len + ctx->file.wBufOffset >= cap) { int32_t nw = cap - ctx->file.wBufOffset; memcpy(ctx->file.wBuf + ctx->file.wBufOffset, buf, nw); - taosWriteFile(ctx->file.pFile, ctx->file.wBuf, cap); + (void)taosWriteFile(ctx->file.pFile, ctx->file.wBuf, cap); memset(ctx->file.wBuf, 0, cap); ctx->file.wBufOffset = 0; @@ -58,7 +58,7 @@ static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) nw = (len / cap) * cap; if (nw != 0) { - taosWriteFile(ctx->file.pFile, buf, nw); + (void)taosWriteFile(ctx->file.pFile, buf, nw); } len -= nw; @@ -112,7 +112,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of SDataBlock* blk = taosLRUCacheValue(ctx->lru, h); nread = TMIN(blkLeft, len); memcpy(buf + total, blk->buf + blkOffset, nread); - taosLRUCacheRelease(ctx->lru, h, false); + (void)taosLRUCacheRelease(ctx->lru, h, false); } else { int32_t left = ctx->file.size - offset; if (left < kBlockSize) { @@ -162,7 +162,7 @@ static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) { return ctx->offset; } else { int64_t file_size = 0; - taosStatFile(ctx->file.buf, &file_size, NULL, NULL); + (void)taosStatFile(ctx->file.buf, &file_size, NULL, NULL); return (int)file_size; } } @@ -250,16 +250,16 @@ void idxFileCtxDestroy(IFileCtx* ctx, bool remove) { int32_t nw = taosWriteFile(ctx->file.pFile, ctx->file.wBuf, ctx->file.wBufOffset); ctx->file.wBufOffset = 0; } - ctx->flush(ctx); + (void)(ctx->flush(ctx)); taosMemoryFreeClear(ctx->file.wBuf); - taosCloseFile(&ctx->file.pFile); + (void)taosCloseFile(&ctx->file.pFile); if (ctx->file.readOnly) { #ifdef USE_MMAP munmap(ctx->file.ptr, ctx->file.size); #endif } if (remove) { - unlink(ctx->file.buf); + (void)unlink(ctx->file.buf); } } taosMemoryFree(ctx); @@ -275,7 +275,7 @@ IdxFstFile* idxFileCreate(void* wrt) { return cw; } void idxFileDestroy(IdxFstFile* cw) { - idxFileFlush(cw); + (void)idxFileFlush(cw); taosMemoryFree(cw); } @@ -314,7 +314,7 @@ uint32_t idxFileMaskedCheckSum(IdxFstFile* write) { int idxFileFlush(IdxFstFile* write) { IFileCtx* ctx = write->wrt; - ctx->flush(ctx); + (void)(ctx->flush(ctx)); return 1; } @@ -324,7 +324,7 @@ void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) { buf[i] = (uint8_t)n; n = n >> 8; } - idxFileWrite(writer, buf, nBytes); + (void)idxFileWrite(writer, buf, nBytes); taosMemoryFree(buf); return; } diff --git a/source/libs/index/src/indexFstNode.c b/source/libs/index/src/indexFstNode.c index 7185e44f46..b934cb0536 100644 --- a/source/libs/index/src/indexFstNode.c +++ b/source/libs/index/src/indexFstNode.c @@ -68,7 +68,7 @@ FstBuilderNode* fstBuilderNodeClone(FstBuilderNode* src) { for (size_t i = 0; i < sz; i++) { FstTransition* tran = taosArrayGet(src->trans, i); - taosArrayPush(trans, tran); + (void)taosArrayPush(trans, tran); } node->trans = trans; @@ -91,7 +91,7 @@ void fstBuilderNodeCloneFrom(FstBuilderNode* dst, FstBuilderNode* src) { dst->trans = taosArrayInit(sz, sizeof(FstTransition)); for (size_t i = 0; i < sz; i++) { FstTransition* trn = taosArrayGet(src->trans, i); - taosArrayPush(dst->trans, trn); + (void)taosArrayPush(dst->trans, trn); } } diff --git a/source/libs/index/src/indexFstRegex.c b/source/libs/index/src/indexFstRegex.c index 7af4b17e79..c6ceb1d965 100644 --- a/source/libs/index/src/indexFstRegex.c +++ b/source/libs/index/src/indexFstRegex.c @@ -24,12 +24,22 @@ FstRegex *regexCreate(const char *str) { } regex->orig = taosStrdup(str); + if (regex->orig == NULL) { + taosMemoryFree(regex); + return NULL; + } // construct insts based on str SArray *insts = taosArrayInit(256, sizeof(uint8_t)); + if (insts == NULL) { + taosMemoryFree(regex->orig); + taosMemoryFree(regex); + return NULL; + } + for (int i = 0; i < strlen(str); i++) { uint8_t v = str[i]; - taosArrayPush(insts, &v); + (void)taosArrayPush(insts, &v); } FstDfaBuilder *builder = dfaBuilderCreate(insts); regex->dfa = dfaBuilderBuild(builder); diff --git a/source/libs/index/src/indexFstRegister.c b/source/libs/index/src/indexFstRegister.c index adafecccb1..e27ab939b3 100644 --- a/source/libs/index/src/indexFstRegister.c +++ b/source/libs/index/src/indexFstRegister.c @@ -83,7 +83,7 @@ FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize) { for (uint64_t i = 0; i < nCells; i++) { FstRegistryCell cell = {.addr = NONE_ADDRESS, .node = fstBuilderNodeDefault()}; - taosArrayPush(tb, &cell); + (void)taosArrayPush(tb, &cell); } registry->table = tb; diff --git a/source/libs/index/src/indexFstUtil.c b/source/libs/index/src/indexFstUtil.c index f1e8808cf5..92cece3890 100644 --- a/source/libs/index/src/indexFstUtil.c +++ b/source/libs/index/src/indexFstUtil.c @@ -81,7 +81,7 @@ FstSlice fstSliceCreate(uint8_t* data, uint64_t len) { str->len = len; str->data = taosMemoryMalloc(len * sizeof(uint8_t)); - if (data != NULL) { + if (data != NULL && str->data != NULL) { memcpy(str->data, data, len); } @@ -91,7 +91,7 @@ FstSlice fstSliceCreate(uint8_t* data, uint64_t len) { // just shallow copy FstSlice fstSliceCopy(FstSlice* s, int32_t start, int32_t end) { FstString* str = s->str; - atomic_add_fetch_32(&str->ref, 1); + (void)atomic_add_fetch_32(&str->ref, 1); FstSlice t = {.str = str, .start = start + s->start, .end = end + s->start}; return t; diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index d0166ae2e5..99c7b6bc76 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -125,7 +125,7 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) { char buf[128] = {0}; int32_t sz = idxSerialCacheKey(&key, buf); - taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); + (void)taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); tfileReaderRef(reader); } taosArrayDestroyEx(files, tfileDestroyFileName); @@ -172,7 +172,7 @@ int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) { TFileReader** p = taosHashGet(tcache->tableCache, buf, sz); if (p != NULL && *p != NULL) { TFileReader* oldRdr = *p; - taosHashRemove(tcache->tableCache, buf, sz); + (void)taosHashRemove(tcache->tableCache, buf, sz); indexInfo("found %s, should remove file %s", buf, oldRdr->ctx->file.buf); oldRdr->remove = true; tfileReaderUnRef(oldRdr); @@ -265,7 +265,7 @@ static int32_t tfSearchPrefix(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { FStmSt* st = stmBuilderIntoStm(sb); FStmStRslt* rt = NULL; while ((rt = stmStNextWith(st, NULL)) != NULL) { - taosArrayPush(offsets, &(rt->out.out)); + (void)taosArrayPush(offsets, &(rt->out.out)); swsResultDestroy(rt); } stmStDestroy(st); @@ -337,7 +337,7 @@ static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTRslt* tr, TExeCond cond = cmpFn(ch, p, tem->colType); if (MATCH == cond) { - tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total); + (void)tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total); } else if (CONTINUE == cond) { } else if (BREAK == cond) { swsResultDestroy(rt); @@ -474,7 +474,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt taosMemoryFree(tBuf); } if (MATCH == cond) { - tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total); + (void)tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total); } else if (CONTINUE == cond) { } else if (BREAK == cond) { swsResultDestroy(rt); @@ -552,7 +552,7 @@ int32_t tfileWriterCreate(IFileCtx* ctx, TFileHeader* header, TFileWriter** pWri } tw->ctx = ctx; tw->header = *header; - tfileWriteHeader(tw); + (void)tfileWriteHeader(tw); *pWriter = tw; return code; @@ -571,7 +571,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { } else { fn = getComparFunc(colType, 0); } - taosArraySortPWithExt((SArray*)(data), tfileValueCompare, &fn); + (void)taosArraySortPWithExt((SArray*)(data), tfileValueCompare, &fn); } int32_t sz = taosArrayGetSize((SArray*)data); @@ -586,7 +586,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { if (tbsz == 0) continue; fstOffset += TF_TABLE_TATOAL_SIZE(tbsz); } - tfileWriteFstOffset(tw, fstOffset); + (void)tfileWriteFstOffset(tw, fstOffset); int32_t cap = 4 * 1024; char* buf = taosMemoryCalloc(1, cap); @@ -614,7 +614,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { char* p = buf; tfileSerialTableIdsToBuf(p, v->tableId); - tw->ctx->write(tw->ctx, buf, ttsz); + (void)(tw->ctx->write(tw->ctx, buf, ttsz)); v->offset = tw->offset; tw->offset += ttsz; memset(buf, 0, cap); @@ -642,7 +642,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) { } } fstBuilderDestroy(tw->fb); - tfileWriteFooter(tw); + (void)tfileWriteFooter(tw); return 0; } void tfileWriterClose(TFileWriter* tw) { @@ -671,7 +671,7 @@ IndexTFile* idxTFileCreate(SIndex* idx, const char* path) { tfileCacheDestroy(cache); return NULL; } - taosThreadMutexInit(&tfile->mtx, NULL); + (void)taosThreadMutexInit(&tfile->mtx, NULL); tfile->cache = cache; return tfile; } @@ -679,7 +679,7 @@ void idxTFileDestroy(IndexTFile* tfile) { if (tfile == NULL) { return; } - taosThreadMutexDestroy(&tfile->mtx); + (void)taosThreadMutexDestroy(&tfile->mtx); tfileCacheDestroy(tfile->cache); taosMemoryFree(tfile); } @@ -696,9 +696,9 @@ int idxTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTRslt* result) { SIndexTerm* term = query->term; ICacheKey key = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName = term->nColName}; - taosThreadMutexLock(&pTfile->mtx); + (void)taosThreadMutexLock(&pTfile->mtx); TFileReader* reader = tfileCacheGet(pTfile->cache, &key); - taosThreadMutexUnlock(&pTfile->mtx); + (void)taosThreadMutexUnlock(&pTfile->mtx); if (reader == NULL) { return 0; } @@ -802,9 +802,9 @@ TFileReader* tfileGetReaderByCol(IndexTFile* tf, uint64_t suid, char* colName) { TFileReader* rd = NULL; ICacheKey key = {.suid = suid, .colType = TSDB_DATA_TYPE_BINARY, .colName = colName, .nColName = strlen(colName)}; - taosThreadMutexLock(&tf->mtx); + (void)taosThreadMutexLock(&tf->mtx); rd = tfileCacheGet(tf->cache, &key); - taosThreadMutexUnlock(&tf->mtx); + (void)taosThreadMutexUnlock(&tf->mtx); return rd; } @@ -838,7 +838,7 @@ int tfileValuePush(TFileValue* tf, uint64_t val) { if (tf == NULL) { return -1; } - taosArrayPush(tf->tableId, &val); + (void)taosArrayPush(tf->tableId, &val); return 0; } void tfileValueDestroy(TFileValue* tf) { @@ -897,7 +897,7 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval) { static int tfileWriteFooter(TFileWriter* write) { char buf[sizeof(FILE_MAGIC_NUMBER) + 1] = {0}; void* pBuf = (void*)buf; - taosEncodeFixedU64((void**)(void*)&pBuf, FILE_MAGIC_NUMBER); + (void)taosEncodeFixedU64((void**)(void*)&pBuf, FILE_MAGIC_NUMBER); int nwrite = write->ctx->write(write->ctx, buf, (int32_t)strlen(buf)); indexInfo("tfile write footer size: %d", write->ctx->size(write->ctx)); @@ -964,7 +964,7 @@ static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* while (nid > 0) { int32_t left = block + sizeof(block) - p; if (left >= sizeof(uint64_t)) { - taosArrayPush(result, (uint64_t*)p); + (void)taosArrayPush(result, (uint64_t*)p); p += sizeof(uint64_t); } else { char buf[sizeof(uint64_t)] = {0}; @@ -975,7 +975,7 @@ static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* nread = ctx->readFrom(ctx, block, sizeof(block), offset); memcpy(buf + left, block, sizeof(uint64_t) - left); - taosArrayPush(result, (uint64_t*)buf); + (void)taosArrayPush(result, (uint64_t*)buf); p = block + sizeof(uint64_t) - left; } nid -= 1; @@ -996,7 +996,7 @@ static int tfileReaderVerify(TFileReader* reader) { return -1; } - taosDecodeFixedU64(buf, &tMagicNumber); + (void)taosDecodeFixedU64(buf, &tMagicNumber); return tMagicNumber == FILE_MAGIC_NUMBER ? 0 : -1; } @@ -1040,12 +1040,12 @@ static SArray* tfileGetFileList(const char* path) { size_t len = strlen(path) + 1 + strlen(file) + 1; char* buf = taosMemoryCalloc(1, len); sprintf(buf, "%s/%s", path, file); - taosArrayPush(files, &buf); + (void)taosArrayPush(files, &buf); } - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); taosArraySort(files, tfileCompare); - tfileRmExpireFile(files); + (void)tfileRmExpireFile(files); return files; } diff --git a/source/libs/index/src/indexUtil.c b/source/libs/index/src/indexUtil.c index f89944204d..0776e71180 100644 --- a/source/libs/index/src/indexUtil.c +++ b/source/libs/index/src/indexUtil.c @@ -64,7 +64,7 @@ void iIntersection(SArray *in, SArray *out) { } } if (has == true) { - taosArrayPush(out, &tgt); + (void)taosArrayPush(out, &tgt); } } taosMemoryFreeClear(mi); @@ -75,7 +75,7 @@ void iUnion(SArray *in, SArray *out) { return; } if (sz == 1) { - taosArrayAddAll(out, taosArrayGetP(in, 0)); + (void)taosArrayAddAll(out, taosArrayGetP(in, 0)); return; } @@ -108,7 +108,7 @@ void iUnion(SArray *in, SArray *out) { continue; } } - taosArrayPush(out, &mVal); + (void)taosArrayPush(out, &mVal); } else { break; } @@ -198,11 +198,11 @@ void idxTRsltMergeTo(SIdxTRslt *tr, SArray *result) { if (taosArrayGetSize(tr->total) == 0 || taosArrayGetSize(tr->add) == 0) { SArray *t = taosArrayGetSize(tr->total) == 0 ? tr->add : tr->total; - taosArrayAddAll(result, t); + (void)taosArrayAddAll(result, t); } else { SArray *arrs = taosArrayInit(2, sizeof(void *)); - taosArrayPush(arrs, &tr->total); - taosArrayPush(arrs, &tr->add); + (void)taosArrayPush(arrs, &tr->total); + (void)taosArrayPush(arrs, &tr->add); iUnion(arrs, result); taosArrayDestroy(arrs); } diff --git a/source/libs/monitor/src/monFramework.c b/source/libs/monitor/src/monFramework.c index 488b4d1d58..d5fc1b4c65 100644 --- a/source/libs/monitor/src/monFramework.c +++ b/source/libs/monitor/src/monFramework.c @@ -100,7 +100,7 @@ extern char* tsMonFwUri; #define VNODE_ROLE "taosd_vnodes_info:role" void monInitMonitorFW(){ - taos_collector_registry_default_init(); + (void)taos_collector_registry_default_init(); tsMonitor.metrics = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); taos_gauge_t *gauge = NULL; @@ -115,9 +115,9 @@ void monInitMonitorFW(){ for(int32_t i = 0; i < 25; i++){ gauge= taos_gauge_new(dnodes_gauges[i], "", dnodes_label_count, dnodes_sample_labels); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } - taosHashPut(tsMonitor.metrics, dnodes_gauges[i], strlen(dnodes_gauges[i]), &gauge, sizeof(taos_gauge_t *)); + (void)taosHashPut(tsMonitor.metrics, dnodes_gauges[i], strlen(dnodes_gauges[i]), &gauge, sizeof(taos_gauge_t *)); } int32_t dnodes_data_label_count = 5; @@ -126,9 +126,10 @@ void monInitMonitorFW(){ for(int32_t i = 0; i < 3; i++){ gauge= taos_gauge_new(dnodes_data_gauges[i], "", dnodes_data_label_count, dnodes_data_sample_labels); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } - taosHashPut(tsMonitor.metrics, dnodes_data_gauges[i], strlen(dnodes_data_gauges[i]), &gauge, sizeof(taos_gauge_t *)); + (void)taosHashPut(tsMonitor.metrics, dnodes_data_gauges[i], strlen(dnodes_data_gauges[i]), &gauge, + sizeof(taos_gauge_t *)); } int32_t dnodes_log_label_count = 4; @@ -137,15 +138,16 @@ void monInitMonitorFW(){ for(int32_t i = 0; i < 3; i++){ gauge= taos_gauge_new(dnodes_log_gauges[i], "", dnodes_log_label_count, dnodes_log_sample_labels); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } - taosHashPut(tsMonitor.metrics, dnodes_log_gauges[i], strlen(dnodes_log_gauges[i]), &gauge, sizeof(taos_gauge_t *)); + (void)taosHashPut(tsMonitor.metrics, dnodes_log_gauges[i], strlen(dnodes_log_gauges[i]), &gauge, + sizeof(taos_gauge_t *)); } } void monCleanupMonitorFW(){ taosHashCleanup(tsMonitor.metrics); - taos_collector_registry_destroy(TAOS_COLLECTOR_REGISTRY_DEFAULT); + (void)taos_collector_registry_destroy(TAOS_COLLECTOR_REGISTRY_DEFAULT); TAOS_COLLECTOR_REGISTRY_DEFAULT = NULL; } @@ -165,7 +167,7 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){ uError("failed to delete metric %s", metric_names[i]); } - taosHashRemove(tsMonitor.metrics, metric_names[i], strlen(metric_names[i])); + (void)taosHashRemove(tsMonitor.metrics, metric_names[i], strlen(metric_names[i])); } if(pBasicInfo->cluster_id == 0) { @@ -182,9 +184,9 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){ for(int32_t i = 0; i < 18; i++){ gauge= taos_gauge_new(metric_names[i], "", label_count, sample_labels1); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } - taosHashPut(tsMonitor.metrics, metric_names[i], strlen(metric_names[i]), &gauge, sizeof(taos_gauge_t *)); + (void)taosHashPut(tsMonitor.metrics, metric_names[i], strlen(metric_names[i]), &gauge, sizeof(taos_gauge_t *)); } char buf[TSDB_CLUSTER_ID_LEN] = {0}; @@ -194,37 +196,37 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){ taos_gauge_t **metric = NULL; metric = taosHashGet(tsMonitor.metrics, MASTER_UPTIME, strlen(MASTER_UPTIME)); - taos_gauge_set(*metric, pInfo->master_uptime, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->master_uptime, sample_label_values); metric = taosHashGet(tsMonitor.metrics, DBS_TOTAL, strlen(DBS_TOTAL)); - taos_gauge_set(*metric, pInfo->dbs_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->dbs_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, TBS_TOTAL, strlen(TBS_TOTAL)); - taos_gauge_set(*metric, pInfo->tbs_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->tbs_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, STBS_TOTAL, strlen(STBS_TOTAL)); - taos_gauge_set(*metric, pInfo->stbs_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->stbs_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, VGROUPS_TOTAL, strlen(VGROUPS_TOTAL)); - taos_gauge_set(*metric, pInfo->vgroups_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vgroups_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, VGROUPS_ALIVE, strlen(VGROUPS_ALIVE)); - taos_gauge_set(*metric, pInfo->vgroups_alive, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vgroups_alive, sample_label_values); metric = taosHashGet(tsMonitor.metrics, VNODES_TOTAL, strlen(VNODES_TOTAL)); - taos_gauge_set(*metric, pInfo->vnodes_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vnodes_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, VNODES_ALIVE, strlen(VNODES_ALIVE)); - taos_gauge_set(*metric, pInfo->vnodes_alive, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->vnodes_alive, sample_label_values); metric = taosHashGet(tsMonitor.metrics, CONNECTIONS_TOTAL, strlen(CONNECTIONS_TOTAL)); - taos_gauge_set(*metric, pInfo->connections_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->connections_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, TOPICS_TOTAL, strlen(TOPICS_TOTAL)); - taos_gauge_set(*metric, pInfo->topics_toal, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->topics_toal, sample_label_values); metric = taosHashGet(tsMonitor.metrics, STREAMS_TOTAL, strlen(STREAMS_TOTAL)); - taos_gauge_set(*metric, pInfo->streams_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->streams_total, sample_label_values); //dnodes number int32_t dnode_total = taosArrayGetSize(pInfo->dnodes); @@ -239,10 +241,10 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){ } metric = taosHashGet(tsMonitor.metrics, DNODES_TOTAL, strlen(DNODES_TOTAL)); - taos_gauge_set(*metric, dnode_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, dnode_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, DNODES_ALIVE, strlen(DNODES_ALIVE)); - taos_gauge_set(*metric, dnode_alive, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, dnode_alive, sample_label_values); //mnodes number int32_t mnode_total = taosArrayGetSize(pInfo->mnodes); @@ -271,20 +273,20 @@ void monGenClusterInfoTable(SMonInfo *pMonitor){ } metric = taosHashGet(tsMonitor.metrics, MNODES_TOTAL, strlen(MNODES_TOTAL)); - taos_gauge_set(*metric, mnode_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, mnode_total, sample_label_values); metric = taosHashGet(tsMonitor.metrics, MNODES_ALIVE, strlen(MNODES_ALIVE)); - taos_gauge_set(*metric, mnode_alive, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, mnode_alive, sample_label_values); //grant info metric = taosHashGet(tsMonitor.metrics, EXPIRE_TIME, strlen(EXPIRE_TIME)); - taos_gauge_set(*metric, pGrantInfo->expire_time, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pGrantInfo->expire_time, sample_label_values); metric = taosHashGet(tsMonitor.metrics, TIMESERIES_USED, strlen(TIMESERIES_USED)); - taos_gauge_set(*metric, pGrantInfo->timeseries_used, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pGrantInfo->timeseries_used, sample_label_values); metric = taosHashGet(tsMonitor.metrics, TIMESERIES_TOTAL, strlen(TIMESERIES_TOTAL)); - taos_gauge_set(*metric, pGrantInfo->timeseries_total, sample_label_values); + if (metric != NULL) (void)taos_gauge_set(*metric, pGrantInfo->timeseries_total, sample_label_values); } void monGenVgroupInfoTable(SMonInfo *pMonitor){ @@ -306,11 +308,11 @@ void monGenVgroupInfoTable(SMonInfo *pMonitor){ const char *vgroup_sample_labels[] = {"cluster_id", "vgroup_id", "database_name"}; taos_gauge_t *tableNumGauge = taos_gauge_new(TABLES_NUM, "", vgroup_label_count, vgroup_sample_labels); if(taos_collector_registry_register_metric(tableNumGauge) == 1){ - taos_counter_destroy(tableNumGauge); + (void)taos_counter_destroy(tableNumGauge); } taos_gauge_t *statusGauge = taos_gauge_new(STATUS, "", vgroup_label_count, vgroup_sample_labels); if(taos_collector_registry_register_metric(statusGauge) == 1){ - taos_counter_destroy(statusGauge); + (void)taos_counter_destroy(statusGauge); } char cluster_id[TSDB_CLUSTER_ID_LEN] = {0}; @@ -325,14 +327,14 @@ void monGenVgroupInfoTable(SMonInfo *pMonitor){ const char *sample_labels[] = {cluster_id, vgroup_id, pVgroupDesc->database_name}; taos_gauge_t **metric = NULL; - - taos_gauge_set(tableNumGauge, pVgroupDesc->tables_num, sample_labels); + + if (tableNumGauge != NULL) (void)taos_gauge_set(tableNumGauge, pVgroupDesc->tables_num, sample_labels); int32_t status = 0; if(strcmp(pVgroupDesc->status, "ready") == 0){ status = 1; } - taos_gauge_set(statusGauge, status, sample_labels); + if (statusGauge != NULL) (void)taos_gauge_set(statusGauge, status, sample_labels); } } @@ -401,70 +403,70 @@ void monGenDnodeInfoTable(SMonInfo *pMonitor) { double io_write_disk_rate = io_write_disk / interval; metric = taosHashGet(tsMonitor.metrics, UPTIME, strlen(UPTIME)); - taos_gauge_set(*metric, pInfo->uptime, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->uptime, sample_labels); metric = taosHashGet(tsMonitor.metrics, CPU_ENGINE, strlen(CPU_ENGINE)); - taos_gauge_set(*metric, cpu_engine, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, cpu_engine, sample_labels); metric = taosHashGet(tsMonitor.metrics, CPU_SYSTEM, strlen(CPU_SYSTEM)); - taos_gauge_set(*metric, pSys->cpu_system, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->cpu_system, sample_labels); metric = taosHashGet(tsMonitor.metrics, CPU_CORE, strlen(CPU_CORE)); - taos_gauge_set(*metric, pSys->cpu_cores, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->cpu_cores, sample_labels); metric = taosHashGet(tsMonitor.metrics, MEM_ENGINE, strlen(MEM_ENGINE)); - taos_gauge_set(*metric, mem_engine, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, mem_engine, sample_labels); metric = taosHashGet(tsMonitor.metrics, MEM_SYSTEM, strlen(MEM_SYSTEM)); - taos_gauge_set(*metric, pSys->mem_system, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->mem_system, sample_labels); metric = taosHashGet(tsMonitor.metrics, MEM_TOTAL, strlen(MEM_TOTAL)); - taos_gauge_set(*metric, pSys->mem_total, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->mem_total, sample_labels); metric = taosHashGet(tsMonitor.metrics, DISK_ENGINE, strlen(DISK_ENGINE)); - taos_gauge_set(*metric, pSys->disk_engine, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->disk_engine, sample_labels); metric = taosHashGet(tsMonitor.metrics, DISK_USED, strlen(DISK_USED)); - taos_gauge_set(*metric, pSys->disk_used, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->disk_used, sample_labels); metric = taosHashGet(tsMonitor.metrics, DISK_TOTAL, strlen(DISK_TOTAL)); - taos_gauge_set(*metric, pSys->disk_total, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pSys->disk_total, sample_labels); metric = taosHashGet(tsMonitor.metrics, NET_IN, strlen(NET_IN)); - taos_gauge_set(*metric, net_in_rate, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, net_in_rate, sample_labels); metric = taosHashGet(tsMonitor.metrics, NET_OUT, strlen(NET_OUT)); - taos_gauge_set(*metric, net_out_rate, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, net_out_rate, sample_labels); metric = taosHashGet(tsMonitor.metrics, IO_READ, strlen(IO_READ)); - taos_gauge_set(*metric, io_read_rate, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, io_read_rate, sample_labels); metric = taosHashGet(tsMonitor.metrics, IO_WRITE, strlen(IO_WRITE)); - taos_gauge_set(*metric, io_write_rate, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, io_write_rate, sample_labels); metric = taosHashGet(tsMonitor.metrics, IO_READ_DISK, strlen(IO_READ_DISK)); - taos_gauge_set(*metric, io_read_disk_rate, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, io_read_disk_rate, sample_labels); metric = taosHashGet(tsMonitor.metrics, IO_WRITE_DISK, strlen(IO_WRITE_DISK)); - taos_gauge_set(*metric, io_write_disk_rate, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, io_write_disk_rate, sample_labels); - //metric = taosHashGet(tsMonitor.metrics, ERRORS, strlen(ERRORS)); - //taos_gauge_set(*metric, pStat->errors, sample_labels); + // metric = taosHashGet(tsMonitor.metrics, ERRORS, strlen(ERRORS)); + // if(metric != NULL) (void)taos_gauge_set(*metric, pStat->errors, sample_labels); metric = taosHashGet(tsMonitor.metrics, VNODES_NUM, strlen(VNODES_NUM)); - taos_gauge_set(*metric, pStat->totalVnodes, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pStat->totalVnodes, sample_labels); metric = taosHashGet(tsMonitor.metrics, MASTERS, strlen(MASTERS)); - taos_gauge_set(*metric, pStat->masterNum, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pStat->masterNum, sample_labels); metric = taosHashGet(tsMonitor.metrics, HAS_MNODE, strlen(HAS_MNODE)); - taos_gauge_set(*metric, pInfo->has_mnode, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->has_mnode, sample_labels); metric = taosHashGet(tsMonitor.metrics, HAS_QNODE, strlen(HAS_QNODE)); - taos_gauge_set(*metric, pInfo->has_qnode, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->has_qnode, sample_labels); metric = taosHashGet(tsMonitor.metrics, HAS_SNODE, strlen(HAS_SNODE)); - taos_gauge_set(*metric, pInfo->has_snode, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pInfo->has_snode, sample_labels); //log number SMonLogs *logs[6]; @@ -489,16 +491,16 @@ void monGenDnodeInfoTable(SMonInfo *pMonitor) { } metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_ERROR, strlen(DNODE_LOG_ERROR)); - taos_gauge_set(*metric, numOfErrorLogs, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, numOfErrorLogs, sample_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_INFO, strlen(DNODE_LOG_INFO)); - taos_gauge_set(*metric, numOfInfoLogs, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, numOfInfoLogs, sample_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_DEBUG, strlen(DNODE_LOG_DEBUG)); - taos_gauge_set(*metric, numOfDebugLogs, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, numOfDebugLogs, sample_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TRACE, strlen(DNODE_LOG_TRACE)); - taos_gauge_set(*metric, numOfTraceLogs, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, numOfTraceLogs, sample_labels); } void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){ @@ -519,7 +521,7 @@ void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){ gauge= taos_gauge_new(DNODE_STATUS, "", dnodes_label_count, dnodes_sample_labels); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } char cluster_id[TSDB_CLUSTER_ID_LEN]; @@ -541,7 +543,7 @@ void monGenDnodeStatusInfoTable(SMonInfo *pMonitor){ if(strcmp(pDnodeDesc->status, "ready") == 0){ status = 1; } - taos_gauge_set(gauge, status, sample_labels); + if (gauge != NULL) (void)taos_gauge_set(gauge, status, sample_labels); } } @@ -567,13 +569,13 @@ void monGenDataDiskTable(SMonInfo *pMonitor){ const char *sample_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pDatadirDesc->name, level}; metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_AVAIL, strlen(DNODE_DATA_AVAIL)); - taos_gauge_set(*metric, pDatadirDesc->size.avail, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pDatadirDesc->size.avail, sample_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_USED, strlen(DNODE_DATA_USED)); - taos_gauge_set(*metric, pDatadirDesc->size.used, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pDatadirDesc->size.used, sample_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_DATA_TOTAL, strlen(DNODE_DATA_TOTAL)); - taos_gauge_set(*metric, pDatadirDesc->size.total, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pDatadirDesc->size.total, sample_labels); } } @@ -594,24 +596,24 @@ void monGenLogDiskTable(SMonInfo *pMonitor){ const char *sample_log_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pLogDesc->name}; metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_AVAIL, strlen(DNODE_LOG_AVAIL)); - taos_gauge_set(*metric, pLogDesc->size.avail, sample_log_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pLogDesc->size.avail, sample_log_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_USED, strlen(DNODE_LOG_USED)); - taos_gauge_set(*metric, pLogDesc->size.used, sample_log_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pLogDesc->size.used, sample_log_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TOTAL, strlen(DNODE_LOG_TOTAL)); - taos_gauge_set(*metric, pLogDesc->size.total, sample_log_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pLogDesc->size.total, sample_log_labels); const char *sample_temp_labels[] = {cluster_id, dnode_id, pMonitor->dmInfo.basic.dnode_ep, pTempDesc->name}; metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_AVAIL, strlen(DNODE_LOG_AVAIL)); - taos_gauge_set(*metric, pTempDesc->size.avail, sample_temp_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pTempDesc->size.avail, sample_temp_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_USED, strlen(DNODE_LOG_USED)); - taos_gauge_set(*metric, pTempDesc->size.used, sample_temp_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pTempDesc->size.used, sample_temp_labels); metric = taosHashGet(tsMonitor.metrics, DNODE_LOG_TOTAL, strlen(DNODE_LOG_TOTAL)); - taos_gauge_set(*metric, pTempDesc->size.total, sample_temp_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pTempDesc->size.total, sample_temp_labels); } void monGenMnodeRoleTable(SMonInfo *pMonitor){ @@ -622,7 +624,7 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){ uError("failed to delete metric %s", mnodes_role_gauges[i]); } - taosHashRemove(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i])); + (void)taosHashRemove(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i])); } SMonClusterInfo *pInfo = &pMonitor->mmInfo.cluster; @@ -636,9 +638,10 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){ for(int32_t i = 0; i < 1; i++){ gauge= taos_gauge_new(mnodes_role_gauges[i], "", mnodes_role_label_count, mnodes_role_sample_labels); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } - taosHashPut(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i]), &gauge, sizeof(taos_gauge_t *)); + (void)taosHashPut(tsMonitor.metrics, mnodes_role_gauges[i], strlen(mnodes_role_gauges[i]), &gauge, + sizeof(taos_gauge_t *)); } char buf[TSDB_CLUSTER_ID_LEN] = {0}; @@ -669,13 +672,13 @@ void monGenMnodeRoleTable(SMonInfo *pMonitor){ metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE)); if(dnodeIsOnline){ - taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels); } else{ - taos_gauge_set(*metric, 0, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, 0, sample_labels); } - //metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE)); - //taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels); + // metric = taosHashGet(tsMonitor.metrics, MNODE_ROLE, strlen(MNODE_ROLE)); + // if(metric != NULL) (void)taos_gauge_set(*metric, pMnodeDesc->syncState, sample_labels); } } @@ -688,7 +691,7 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){ uError("failed to delete metric %s", vnodes_role_gauges[i]); } - taosHashRemove(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i])); + (void)taosHashRemove(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i])); } SMonVgroupInfo *pInfo = &pMonitor->mmInfo.vgroup; @@ -702,9 +705,10 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){ for(int32_t i = 0; i < 1; i++){ gauge= taos_gauge_new(vnodes_role_gauges[i], "", vnodes_role_label_count, vnodes_role_sample_labels); if(taos_collector_registry_register_metric(gauge) == 1){ - taos_counter_destroy(gauge); + (void)taos_counter_destroy(gauge); } - taosHashPut(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i]), &gauge, sizeof(taos_gauge_t *)); + (void)taosHashPut(tsMonitor.metrics, vnodes_role_gauges[i], strlen(vnodes_role_gauges[i]), &gauge, + sizeof(taos_gauge_t *)); } char buf[TSDB_CLUSTER_ID_LEN] = {0}; @@ -728,7 +732,7 @@ void monGenVnodeRoleTable(SMonInfo *pMonitor){ const char *sample_labels[] = {buf, vgroup_id, pVgroupDesc->database_name, dnode_id}; metric = taosHashGet(tsMonitor.metrics, VNODE_ROLE, strlen(VNODE_ROLE)); - taos_gauge_set(*metric, pVnodeDesc->syncState, sample_labels); + if (metric != NULL) (void)taos_gauge_set(*metric, pVnodeDesc->syncState, sample_labels); } } } @@ -753,7 +757,7 @@ void monSendPromReport() { if (taosSendHttpReport(tsMonitor.cfg.server, tsMonFwUri, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) { uError("failed to send monitor msg"); }else{ - taos_collector_registry_clear_batch(TAOS_COLLECTOR_REGISTRY_DEFAULT); + (void)taos_collector_registry_clear_batch(TAOS_COLLECTOR_REGISTRY_DEFAULT); } taosMemoryFreeClear(pCont); } diff --git a/source/libs/monitor/src/monMain.c b/source/libs/monitor/src/monMain.c index 6bc3c43d0f..9669eac508 100644 --- a/source/libs/monitor/src/monMain.c +++ b/source/libs/monitor/src/monMain.c @@ -110,7 +110,7 @@ int32_t monInit(const SMonCfg *pCfg) { tsMonitor.cfg = *pCfg; tsLogFp = monRecordLog; tsMonitor.lastTime = taosGetTimestampMs(); - taosThreadMutexInit(&tsMonitor.lock, NULL); + (void)taosThreadMutexInit(&tsMonitor.lock, NULL); monInitMonitorFW(); @@ -126,7 +126,7 @@ void monCleanup() { tFreeSMonSmInfo(&tsMonitor.smInfo); tFreeSMonQmInfo(&tsMonitor.qmInfo); tFreeSMonBmInfo(&tsMonitor.bmInfo); - taosThreadMutexDestroy(&tsMonitor.lock); + (void)taosThreadMutexDestroy(&tsMonitor.lock); monCleanupMonitorFW(); } @@ -151,7 +151,9 @@ static SMonInfo *monCreateMonitorInfo() { return NULL; } - monGetLogs(&pMonitor->log); + if ((terrno = monGetLogs(&pMonitor->log)) != 0) { + return NULL; + } (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&pMonitor->dmInfo, &tsMonitor.dmInfo, sizeof(SMonDmInfo)); @@ -185,14 +187,14 @@ static void monGenBasicJson(SMonInfo *pMonitor) { SJson *pJson = pMonitor->pJson; char buf[40] = {0}; - taosFormatUtcTime(buf, sizeof(buf), pMonitor->curTime, TSDB_TIME_PRECISION_MILLI); + (void)taosFormatUtcTime(buf, sizeof(buf), pMonitor->curTime, TSDB_TIME_PRECISION_MILLI); - tjsonAddStringToObject(pJson, "ts", buf); - tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id); - tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep); + (void)tjsonAddStringToObject(pJson, "ts", buf); + (void)tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id); + (void)tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep); snprintf(buf, sizeof(buf), "%" PRId64, pInfo->cluster_id); - tjsonAddStringToObject(pJson, "cluster_id", buf); - tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol); + (void)tjsonAddStringToObject(pJson, "cluster_id", buf); + (void)tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol); } static void monGenBasicJsonBasic(SMonInfo *pMonitor) { @@ -203,12 +205,12 @@ static void monGenBasicJsonBasic(SMonInfo *pMonitor) { char buf[40] = {0}; sprintf(buf, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI)); - tjsonAddStringToObject(pJson, "ts", buf); - tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id); - tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep); + (void)tjsonAddStringToObject(pJson, "ts", buf); + (void)tjsonAddDoubleToObject(pJson, "dnode_id", pInfo->dnode_id); + (void)tjsonAddStringToObject(pJson, "dnode_ep", pInfo->dnode_ep); snprintf(buf, sizeof(buf), "%" PRId64, pInfo->cluster_id); - tjsonAddStringToObject(pJson, "cluster_id", buf); - tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol); + (void)tjsonAddStringToObject(pJson, "cluster_id", buf); + (void)tjsonAddDoubleToObject(pJson, "protocol", pInfo->protocol); } static void monGenClusterJson(SMonInfo *pMonitor) { @@ -222,21 +224,21 @@ static void monGenClusterJson(SMonInfo *pMonitor) { return; } - tjsonAddStringToObject(pJson, "first_ep", pInfo->first_ep); - tjsonAddDoubleToObject(pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id); - tjsonAddStringToObject(pJson, "version", pInfo->version); - tjsonAddDoubleToObject(pJson, "master_uptime", pInfo->master_uptime); - tjsonAddDoubleToObject(pJson, "monitor_interval", pInfo->monitor_interval); - tjsonAddDoubleToObject(pJson, "dbs_total", pInfo->dbs_total); - tjsonAddDoubleToObject(pJson, "tbs_total", pInfo->tbs_total); - tjsonAddDoubleToObject(pJson, "stbs_total", pInfo->stbs_total); - tjsonAddDoubleToObject(pJson, "vgroups_total", pInfo->vgroups_total); - tjsonAddDoubleToObject(pJson, "vgroups_alive", pInfo->vgroups_alive); - tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total); - tjsonAddDoubleToObject(pJson, "vnodes_alive", pInfo->vnodes_alive); - tjsonAddDoubleToObject(pJson, "connections_total", pInfo->connections_total); - tjsonAddDoubleToObject(pJson, "topics_total", pInfo->topics_toal); - tjsonAddDoubleToObject(pJson, "streams_total", pInfo->streams_total); + (void)tjsonAddStringToObject(pJson, "first_ep", pInfo->first_ep); + (void)tjsonAddDoubleToObject(pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id); + (void)tjsonAddStringToObject(pJson, "version", pInfo->version); + (void)tjsonAddDoubleToObject(pJson, "master_uptime", pInfo->master_uptime); + (void)tjsonAddDoubleToObject(pJson, "monitor_interval", pInfo->monitor_interval); + (void)tjsonAddDoubleToObject(pJson, "dbs_total", pInfo->dbs_total); + (void)tjsonAddDoubleToObject(pJson, "tbs_total", pInfo->tbs_total); + (void)tjsonAddDoubleToObject(pJson, "stbs_total", pInfo->stbs_total); + (void)tjsonAddDoubleToObject(pJson, "vgroups_total", pInfo->vgroups_total); + (void)tjsonAddDoubleToObject(pJson, "vgroups_alive", pInfo->vgroups_alive); + (void)tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total); + (void)tjsonAddDoubleToObject(pJson, "vnodes_alive", pInfo->vnodes_alive); + (void)tjsonAddDoubleToObject(pJson, "connections_total", pInfo->connections_total); + (void)tjsonAddDoubleToObject(pJson, "topics_total", pInfo->topics_toal); + (void)tjsonAddDoubleToObject(pJson, "streams_total", pInfo->streams_total); SJson *pDnodesJson = tjsonAddArrayToObject(pJson, "dnodes"); if (pDnodesJson == NULL) return; @@ -246,9 +248,9 @@ static void monGenClusterJson(SMonInfo *pMonitor) { if (pDnodeJson == NULL) continue; SMonDnodeDesc *pDnodeDesc = taosArrayGet(pInfo->dnodes, i); - tjsonAddDoubleToObject(pDnodeJson, "dnode_id", pDnodeDesc->dnode_id); - tjsonAddStringToObject(pDnodeJson, "dnode_ep", pDnodeDesc->dnode_ep); - tjsonAddStringToObject(pDnodeJson, "status", pDnodeDesc->status); + (void)tjsonAddDoubleToObject(pDnodeJson, "dnode_id", pDnodeDesc->dnode_id); + (void)tjsonAddStringToObject(pDnodeJson, "dnode_ep", pDnodeDesc->dnode_ep); + (void)tjsonAddStringToObject(pDnodeJson, "status", pDnodeDesc->status); if (tjsonAddItemToArray(pDnodesJson, pDnodeJson) != 0) tjsonDelete(pDnodeJson); } @@ -261,9 +263,9 @@ static void monGenClusterJson(SMonInfo *pMonitor) { if (pMnodeJson == NULL) continue; SMonMnodeDesc *pMnodeDesc = taosArrayGet(pInfo->mnodes, i); - tjsonAddDoubleToObject(pMnodeJson, "mnode_id", pMnodeDesc->mnode_id); - tjsonAddStringToObject(pMnodeJson, "mnode_ep", pMnodeDesc->mnode_ep); - tjsonAddStringToObject(pMnodeJson, "role", pMnodeDesc->role); + (void)tjsonAddDoubleToObject(pMnodeJson, "mnode_id", pMnodeDesc->mnode_id); + (void)tjsonAddStringToObject(pMnodeJson, "mnode_ep", pMnodeDesc->mnode_ep); + (void)tjsonAddStringToObject(pMnodeJson, "role", pMnodeDesc->role); if (tjsonAddItemToArray(pMnodesJson, pMnodeJson) != 0) tjsonDelete(pMnodeJson); } @@ -273,11 +275,11 @@ static void monGenClusterJsonBasic(SMonInfo *pMonitor) { SMonClusterInfo *pInfo = &pMonitor->mmInfo.cluster; if (pMonitor->mmInfo.cluster.first_ep_dnode_id == 0) return; - // tjsonAddStringToObject(pMonitor->pJson, "first_ep", pInfo->first_ep); - tjsonAddStringToObject(pMonitor->pJson, "first_ep", tsFirst); - tjsonAddDoubleToObject(pMonitor->pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id); - tjsonAddStringToObject(pMonitor->pJson, "cluster_version", pInfo->version); - // tjsonAddDoubleToObject(pMonitor->pJson, "monitor_interval", pInfo->monitor_interval); + // (void)tjsonAddStringToObject(pMonitor->pJson, "first_ep", pInfo->first_ep); + (void)tjsonAddStringToObject(pMonitor->pJson, "first_ep", tsFirst); + (void)tjsonAddDoubleToObject(pMonitor->pJson, "first_ep_dnode_id", pInfo->first_ep_dnode_id); + (void)tjsonAddStringToObject(pMonitor->pJson, "cluster_version", pInfo->version); + // (void)tjsonAddDoubleToObject(pMonitor->pJson, "monitor_interval", pInfo->monitor_interval); } static void monGenVgroupJson(SMonInfo *pMonitor) { @@ -296,10 +298,10 @@ static void monGenVgroupJson(SMonInfo *pMonitor) { } SMonVgroupDesc *pVgroupDesc = taosArrayGet(pInfo->vgroups, i); - tjsonAddDoubleToObject(pVgroupJson, "vgroup_id", pVgroupDesc->vgroup_id); - tjsonAddStringToObject(pVgroupJson, "database_name", pVgroupDesc->database_name); - tjsonAddDoubleToObject(pVgroupJson, "tables_num", pVgroupDesc->tables_num); - tjsonAddStringToObject(pVgroupJson, "status", pVgroupDesc->status); + (void)tjsonAddDoubleToObject(pVgroupJson, "vgroup_id", pVgroupDesc->vgroup_id); + (void)tjsonAddStringToObject(pVgroupJson, "database_name", pVgroupDesc->database_name); + (void)tjsonAddDoubleToObject(pVgroupJson, "tables_num", pVgroupDesc->tables_num); + (void)tjsonAddStringToObject(pVgroupJson, "status", pVgroupDesc->status); SJson *pVnodesJson = tjsonAddArrayToObject(pVgroupJson, "vnodes"); if (pVnodesJson == NULL) continue; @@ -311,8 +313,8 @@ static void monGenVgroupJson(SMonInfo *pMonitor) { SJson *pVnodeJson = tjsonCreateObject(); if (pVnodeJson == NULL) continue; - tjsonAddDoubleToObject(pVnodeJson, "dnode_id", pVnodeDesc->dnode_id); - tjsonAddStringToObject(pVnodeJson, "vnode_role", pVnodeDesc->vnode_role); + (void)tjsonAddDoubleToObject(pVnodeJson, "dnode_id", pVnodeDesc->dnode_id); + (void)tjsonAddStringToObject(pVnodeJson, "vnode_role", pVnodeDesc->vnode_role); if (tjsonAddItemToArray(pVnodesJson, pVnodeJson) != 0) tjsonDelete(pVnodeJson); } @@ -335,8 +337,8 @@ static void monGenStbJson(SMonInfo *pMonitor) { } SMonStbDesc *pStbDesc = taosArrayGet(pInfo->stbs, i); - tjsonAddStringToObject(pStbJson, "stb_name", pStbDesc->stb_name); - tjsonAddStringToObject(pStbJson, "database_name", pStbDesc->database_name); + (void)tjsonAddStringToObject(pStbJson, "stb_name", pStbDesc->stb_name); + (void)tjsonAddStringToObject(pStbJson, "database_name", pStbDesc->database_name); } } @@ -351,9 +353,9 @@ static void monGenGrantJson(SMonInfo *pMonitor) { return; } - tjsonAddDoubleToObject(pJson, "expire_time", pInfo->expire_time); - tjsonAddDoubleToObject(pJson, "timeseries_used", pInfo->timeseries_used); - tjsonAddDoubleToObject(pJson, "timeseries_total", pInfo->timeseries_total); + (void)tjsonAddDoubleToObject(pJson, "expire_time", pInfo->expire_time); + (void)tjsonAddDoubleToObject(pJson, "timeseries_used", pInfo->timeseries_used); + (void)tjsonAddDoubleToObject(pJson, "timeseries_total", pInfo->timeseries_total); } static void monGenDnodeJson(SMonInfo *pMonitor) { @@ -410,36 +412,36 @@ static void monGenDnodeJson(SMonInfo *pMonitor) { double io_read_disk_rate = io_read_disk / interval; double io_write_disk_rate = io_write_disk / interval; - tjsonAddDoubleToObject(pJson, "uptime", pInfo->uptime); - tjsonAddDoubleToObject(pJson, "cpu_engine", cpu_engine); - tjsonAddDoubleToObject(pJson, "cpu_system", pSys->cpu_system); - tjsonAddDoubleToObject(pJson, "cpu_cores", pSys->cpu_cores); - tjsonAddDoubleToObject(pJson, "mem_engine", mem_engine); - tjsonAddDoubleToObject(pJson, "mem_system", pSys->mem_system); - tjsonAddDoubleToObject(pJson, "mem_total", pSys->mem_total); - tjsonAddDoubleToObject(pJson, "disk_engine", pSys->disk_engine); - tjsonAddDoubleToObject(pJson, "disk_used", pSys->disk_used); - tjsonAddDoubleToObject(pJson, "disk_total", pSys->disk_total); - tjsonAddDoubleToObject(pJson, "net_in", net_in_rate); - tjsonAddDoubleToObject(pJson, "net_out", net_out_rate); - tjsonAddDoubleToObject(pJson, "io_read", io_read_rate); - tjsonAddDoubleToObject(pJson, "io_write", io_write_rate); - tjsonAddDoubleToObject(pJson, "io_read_disk", io_read_disk_rate); - tjsonAddDoubleToObject(pJson, "io_write_disk", io_write_disk_rate); - tjsonAddDoubleToObject(pJson, "req_select", pStat->numOfSelectReqs); - tjsonAddDoubleToObject(pJson, "req_select_rate", req_select_rate); - tjsonAddDoubleToObject(pJson, "req_insert", pStat->numOfInsertReqs); - tjsonAddDoubleToObject(pJson, "req_insert_success", pStat->numOfInsertSuccessReqs); - tjsonAddDoubleToObject(pJson, "req_insert_rate", req_insert_rate); - tjsonAddDoubleToObject(pJson, "req_insert_batch", pStat->numOfBatchInsertReqs); - tjsonAddDoubleToObject(pJson, "req_insert_batch_success", pStat->numOfBatchInsertSuccessReqs); - tjsonAddDoubleToObject(pJson, "req_insert_batch_rate", req_insert_batch_rate); - tjsonAddDoubleToObject(pJson, "errors", pStat->errors); - tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes); - tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum); - tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode); - tjsonAddDoubleToObject(pJson, "has_qnode", pInfo->has_qnode); - tjsonAddDoubleToObject(pJson, "has_snode", pInfo->has_snode); + (void)tjsonAddDoubleToObject(pJson, "uptime", pInfo->uptime); + (void)tjsonAddDoubleToObject(pJson, "cpu_engine", cpu_engine); + (void)tjsonAddDoubleToObject(pJson, "cpu_system", pSys->cpu_system); + (void)tjsonAddDoubleToObject(pJson, "cpu_cores", pSys->cpu_cores); + (void)tjsonAddDoubleToObject(pJson, "mem_engine", mem_engine); + (void)tjsonAddDoubleToObject(pJson, "mem_system", pSys->mem_system); + (void)tjsonAddDoubleToObject(pJson, "mem_total", pSys->mem_total); + (void)tjsonAddDoubleToObject(pJson, "disk_engine", pSys->disk_engine); + (void)tjsonAddDoubleToObject(pJson, "disk_used", pSys->disk_used); + (void)tjsonAddDoubleToObject(pJson, "disk_total", pSys->disk_total); + (void)tjsonAddDoubleToObject(pJson, "net_in", net_in_rate); + (void)tjsonAddDoubleToObject(pJson, "net_out", net_out_rate); + (void)tjsonAddDoubleToObject(pJson, "io_read", io_read_rate); + (void)tjsonAddDoubleToObject(pJson, "io_write", io_write_rate); + (void)tjsonAddDoubleToObject(pJson, "io_read_disk", io_read_disk_rate); + (void)tjsonAddDoubleToObject(pJson, "io_write_disk", io_write_disk_rate); + (void)tjsonAddDoubleToObject(pJson, "req_select", pStat->numOfSelectReqs); + (void)tjsonAddDoubleToObject(pJson, "req_select_rate", req_select_rate); + (void)tjsonAddDoubleToObject(pJson, "req_insert", pStat->numOfInsertReqs); + (void)tjsonAddDoubleToObject(pJson, "req_insert_success", pStat->numOfInsertSuccessReqs); + (void)tjsonAddDoubleToObject(pJson, "req_insert_rate", req_insert_rate); + (void)tjsonAddDoubleToObject(pJson, "req_insert_batch", pStat->numOfBatchInsertReqs); + (void)tjsonAddDoubleToObject(pJson, "req_insert_batch_success", pStat->numOfBatchInsertSuccessReqs); + (void)tjsonAddDoubleToObject(pJson, "req_insert_batch_rate", req_insert_batch_rate); + (void)tjsonAddDoubleToObject(pJson, "errors", pStat->errors); + (void)tjsonAddDoubleToObject(pJson, "vnodes_num", pStat->totalVnodes); + (void)tjsonAddDoubleToObject(pJson, "masters", pStat->masterNum); + (void)tjsonAddDoubleToObject(pJson, "has_mnode", pInfo->has_mnode); + (void)tjsonAddDoubleToObject(pJson, "has_qnode", pInfo->has_qnode); + (void)tjsonAddDoubleToObject(pJson, "has_snode", pInfo->has_snode); } static void monGenDiskJson(SMonInfo *pMonitor) { @@ -474,18 +476,18 @@ static void monGenDiskJson(SMonInfo *pMonitor) { SJson *pLogdirJson = tjsonCreateObject(); if (pLogdirJson == NULL) return; if (tjsonAddItemToObject(pJson, "logdir", pLogdirJson) != 0) return; - tjsonAddStringToObject(pLogdirJson, "name", pLogDesc->name); - tjsonAddDoubleToObject(pLogdirJson, "avail", pLogDesc->size.avail); - tjsonAddDoubleToObject(pLogdirJson, "used", pLogDesc->size.used); - tjsonAddDoubleToObject(pLogdirJson, "total", pLogDesc->size.total); + (void)tjsonAddStringToObject(pLogdirJson, "name", pLogDesc->name); + (void)tjsonAddDoubleToObject(pLogdirJson, "avail", pLogDesc->size.avail); + (void)tjsonAddDoubleToObject(pLogdirJson, "used", pLogDesc->size.used); + (void)tjsonAddDoubleToObject(pLogdirJson, "total", pLogDesc->size.total); SJson *pTempdirJson = tjsonCreateObject(); if (pTempdirJson == NULL) return; if (tjsonAddItemToObject(pJson, "tempdir", pTempdirJson) != 0) return; - tjsonAddStringToObject(pTempdirJson, "name", pTempDesc->name); - tjsonAddDoubleToObject(pTempdirJson, "avail", pTempDesc->size.avail); - tjsonAddDoubleToObject(pTempdirJson, "used", pTempDesc->size.used); - tjsonAddDoubleToObject(pTempdirJson, "total", pTempDesc->size.total); + (void)tjsonAddStringToObject(pTempdirJson, "name", pTempDesc->name); + (void)tjsonAddDoubleToObject(pTempdirJson, "avail", pTempDesc->size.avail); + (void)tjsonAddDoubleToObject(pTempdirJson, "used", pTempDesc->size.used); + (void)tjsonAddDoubleToObject(pTempdirJson, "total", pTempDesc->size.total); } static const char *monLogLevelStr(ELogLevel level) { @@ -530,26 +532,26 @@ static void monGenLogJson(SMonInfo *pMonitor) { SJson *pLogError = tjsonCreateObject(); if (pLogError == NULL) return; - tjsonAddStringToObject(pLogError, "level", "error"); - tjsonAddDoubleToObject(pLogError, "total", numOfErrorLogs); + (void)tjsonAddStringToObject(pLogError, "level", "error"); + (void)tjsonAddDoubleToObject(pLogError, "total", numOfErrorLogs); if (tjsonAddItemToArray(pSummaryJson, pLogError) != 0) tjsonDelete(pLogError); SJson *pLogInfo = tjsonCreateObject(); if (pLogInfo == NULL) return; - tjsonAddStringToObject(pLogInfo, "level", "info"); - tjsonAddDoubleToObject(pLogInfo, "total", numOfInfoLogs); + (void)tjsonAddStringToObject(pLogInfo, "level", "info"); + (void)tjsonAddDoubleToObject(pLogInfo, "total", numOfInfoLogs); if (tjsonAddItemToArray(pSummaryJson, pLogInfo) != 0) tjsonDelete(pLogInfo); SJson *pLogDebug = tjsonCreateObject(); if (pLogDebug == NULL) return; - tjsonAddStringToObject(pLogDebug, "level", "debug"); - tjsonAddDoubleToObject(pLogDebug, "total", numOfDebugLogs); + (void)tjsonAddStringToObject(pLogDebug, "level", "debug"); + (void)tjsonAddDoubleToObject(pLogDebug, "total", numOfDebugLogs); if (tjsonAddItemToArray(pSummaryJson, pLogDebug) != 0) tjsonDelete(pLogDebug); SJson *pLogTrace = tjsonCreateObject(); if (pLogTrace == NULL) return; - tjsonAddStringToObject(pLogTrace, "level", "trace"); - tjsonAddDoubleToObject(pLogTrace, "total", numOfTraceLogs); + (void)tjsonAddStringToObject(pLogTrace, "level", "trace"); + (void)tjsonAddDoubleToObject(pLogTrace, "total", numOfTraceLogs); if (tjsonAddItemToArray(pSummaryJson, pLogTrace) != 0) tjsonDelete(pLogTrace); } diff --git a/source/libs/monitorfw/src/taos_collector.c b/source/libs/monitorfw/src/taos_collector.c index 8be4edaef9..01e37b6d76 100644 --- a/source/libs/monitorfw/src/taos_collector.c +++ b/source/libs/monitorfw/src/taos_collector.c @@ -39,18 +39,18 @@ taos_collector_t *taos_collector_new(const char *name) { self->name = taos_strdup(name); self->metrics = taos_map_new(); if (self->metrics == NULL) { - taos_collector_destroy(self); + (void)taos_collector_destroy(self); return NULL; } r = taos_map_set_free_value_fn(self->metrics, &taos_metric_free_generic); if (r) { - taos_collector_destroy(self); + (void)taos_collector_destroy(self); return NULL; } self->collect_fn = &taos_collector_default_collect; self->string_builder = taos_string_builder_new(); if (self->string_builder == NULL) { - taos_collector_destroy(self); + (void)taos_collector_destroy(self); return NULL; } self->proc_limits_file_path = NULL; @@ -93,7 +93,7 @@ int taos_collector_destroy_generic(void *gen) { void taos_collector_free_generic(void *gen) { taos_collector_t *self = (taos_collector_t *)gen; - taos_collector_destroy(self); + (void)taos_collector_destroy(self); } int taos_collector_set_collect_fn(taos_collector_t *self, taos_collect_fn *fn) { diff --git a/source/libs/monitorfw/src/taos_collector_registry.c b/source/libs/monitorfw/src/taos_collector_registry.c index 0c8385791d..88f56549e5 100644 --- a/source/libs/monitorfw/src/taos_collector_registry.c +++ b/source/libs/monitorfw/src/taos_collector_registry.c @@ -50,8 +50,8 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) { self->name = taos_strdup(name); self->collectors = taos_map_new(); - taos_map_set_free_value_fn(self->collectors, &taos_collector_free_generic); - taos_map_set(self->collectors, "default", taos_collector_new("default")); + (void)taos_map_set_free_value_fn(self->collectors, &taos_collector_free_generic); + if (taos_map_set(self->collectors, "default", taos_collector_new("default")) != 0) return NULL; self->metric_formatter = taos_metric_formatter_new(); self->string_builder = taos_string_builder_new(); @@ -237,15 +237,15 @@ int taos_collector_registry_clear_batch(taos_collector_registry_t *self){ } const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self, char *ts, char *format, char** prom_str) { - taos_metric_formatter_clear(self->metric_formatter); - + if (taos_metric_formatter_clear(self->metric_formatter) != 0) return NULL; + SJson* pJson = tjsonCreateArray(); SJson* item = tjsonCreateObject(); - tjsonAddItemToArray(pJson, item); - tjsonAddStringToObject(item, "ts", ts); - tjsonAddDoubleToObject(item, "protocol", 2); + (void)tjsonAddItemToArray(pJson, item); + (void)tjsonAddStringToObject(item, "ts", ts); + (void)tjsonAddDoubleToObject(item, "protocol", 2); SJson* array = tjsonCreateArray(); - tjsonAddItemToObject(item, "tables", array); + (void)tjsonAddItemToObject(item, "tables", array); if(taos_metric_formatter_load_metrics_new(self->metric_formatter, self->collectors, ts, format, array) != 0){ TAOS_LOG("failed to load metrics"); @@ -304,7 +304,7 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self, _OVER: tjsonDelete(pJson); if(tmp_builder != NULL){ - taos_string_builder_destroy(tmp_builder); + (void)taos_string_builder_destroy(tmp_builder); } return NULL; diff --git a/source/libs/monitorfw/src/taos_map.c b/source/libs/monitorfw/src/taos_map.c index 55aaabf1a7..64d5475af2 100644 --- a/source/libs/monitorfw/src/taos_map.c +++ b/source/libs/monitorfw/src/taos_map.c @@ -59,7 +59,7 @@ int taos_map_node_destroy(taos_map_node_t *self) { void taos_map_node_free(void *item) { taos_map_node_t *map_node = (taos_map_node_t *)item; - taos_map_node_destroy(map_node); + (void)taos_map_node_destroy(map_node); } taos_linked_list_compare_t taos_map_node_compare(void *item_a, void *item_b) { @@ -87,7 +87,7 @@ taos_map_t *taos_map_new() { // we will only have to deallocate each key once. That will happen on taos_map_node_destroy. r = taos_linked_list_set_free_fn(self->keys, taos_linked_list_no_op_free); if (r) { - taos_map_destroy(self); + (void)taos_map_destroy(self); return NULL; } @@ -98,12 +98,12 @@ taos_map_t *taos_map_new() { self->addrs[i] = taos_linked_list_new(); r = taos_linked_list_set_free_fn(self->addrs[i], taos_map_node_free); if (r) { - taos_map_destroy(self); + (void)taos_map_destroy(self); return NULL; } r = taos_linked_list_set_compare_fn(self->addrs[i], taos_map_node_compare); if (r) { - taos_map_destroy(self); + (void)taos_map_destroy(self); return NULL; } } @@ -112,7 +112,7 @@ taos_map_t *taos_map_new() { r = pthread_rwlock_init(self->rwlock, NULL); if (r) { TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR); - taos_map_destroy(self); + (void)taos_map_destroy(self); return NULL; } @@ -188,12 +188,12 @@ static void *taos_map_get_internal(const char *key, size_t *size, size_t *max_si taos_map_node_t *current_map_node = (taos_map_node_t *)current_node->item; taos_linked_list_compare_t result = taos_linked_list_compare(list, current_map_node, temp_map_node); if (result == TAOS_EQUAL) { - taos_map_node_destroy(temp_map_node); + (void)taos_map_node_destroy(temp_map_node); temp_map_node = NULL; return current_map_node->value; } } - taos_map_node_destroy(temp_map_node); + (void)taos_map_node_destroy(temp_map_node); temp_map_node = NULL; return NULL; } @@ -248,8 +248,8 @@ static int taos_map_set_internal(const char *key, void *value, size_t *size, siz return 0; } } - taos_linked_list_append(list, map_node); - taos_linked_list_append(keys, (char *)map_node->key); + if (taos_linked_list_append(list, map_node) != 0) return 1; + if (taos_linked_list_append(keys, (char *)map_node->key) != 0) return 1; (*size)++; return 0; } @@ -311,7 +311,8 @@ int taos_map_ensure_space(taos_map_t *self) { self->addrs[i] = NULL; } // Destroy the collection of keys in the map - taos_linked_list_destroy(self->keys); + r = taos_linked_list_destroy(self->keys); + if (r) return r; self->keys = NULL; // Deallocate the backbone of the map diff --git a/source/libs/monitorfw/src/taos_metric.c b/source/libs/monitorfw/src/taos_metric.c index 056bf131f2..f31cef79b0 100644 --- a/source/libs/monitorfw/src/taos_metric.c +++ b/source/libs/monitorfw/src/taos_metric.c @@ -49,12 +49,12 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name, for (int i = 0; i < label_key_count; i++) { if (strcmp(label_keys[i], "le") == 0) { TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME); - taos_metric_destroy(self); + (void)taos_metric_destroy(self); return NULL; } if (strcmp(label_keys[i], "quantile") == 0) { TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME); - taos_metric_destroy(self); + (void)taos_metric_destroy(self); return NULL; } k[i] = taos_strdup(label_keys[i]); @@ -68,14 +68,14 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name, } else { r = taos_map_set_free_value_fn(self->samples, &taos_metric_sample_free_generic); if (r) { - taos_metric_destroy(self); + (void)taos_metric_destroy(self); return NULL; } } self->formatter = taos_metric_formatter_new(); if (self->formatter == NULL) { - taos_metric_destroy(self); + (void)taos_metric_destroy(self); return NULL; } self->rwlock = (pthread_rwlock_t *)taos_malloc(sizeof(pthread_rwlock_t)); @@ -140,7 +140,7 @@ int taos_metric_destroy_generic(void *item) { void taos_metric_free_generic(void *item) { taos_metric_t *self = (taos_metric_t *)item; - taos_metric_destroy(self); + (void)taos_metric_destroy(self); } taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const char **label_values) { diff --git a/source/libs/monitorfw/src/taos_metric_formatter.c b/source/libs/monitorfw/src/taos_metric_formatter.c index 5f34edf3e6..e57c809815 100644 --- a/source/libs/monitorfw/src/taos_metric_formatter.c +++ b/source/libs/monitorfw/src/taos_metric_formatter.c @@ -34,12 +34,12 @@ taos_metric_formatter_t *taos_metric_formatter_new() { taos_metric_formatter_t *self = (taos_metric_formatter_t *)taos_malloc(sizeof(taos_metric_formatter_t)); self->string_builder = taos_string_builder_new(); if (self->string_builder == NULL) { - taos_metric_formatter_destroy(self); + (void)taos_metric_formatter_destroy(self); return NULL; } self->err_builder = taos_string_builder_new(); if (self->err_builder == NULL) { - taos_metric_formatter_destroy(self); + (void)taos_metric_formatter_destroy(self); return NULL; } return self; diff --git a/source/libs/monitorfw/src/taos_metric_formatter_custom.c b/source/libs/monitorfw/src/taos_metric_formatter_custom.c index 553227c801..0287641311 100644 --- a/source/libs/monitorfw/src/taos_metric_formatter_custom.c +++ b/source/libs/monitorfw/src/taos_metric_formatter_custom.c @@ -88,17 +88,17 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me char* value = *(pair + 1); SJson* tag = tjsonCreateObject(); - tjsonAddStringToObject(tag, "name", key); - tjsonAddStringToObject(tag, "value", value); + (void)tjsonAddStringToObject(tag, "name", key); + (void)tjsonAddStringToObject(tag, "value", value); - tjsonAddItemToArray(arrayTag, tag); + (void)tjsonAddItemToArray(arrayTag, tag); } - tjsonAddItemToObject(item, "tags", arrayTag); + (void)tjsonAddItemToObject(item, "tags", arrayTag); metrics = tjsonCreateArray(); - tjsonAddItemToObject(item, "metrics", metrics); + (void)tjsonAddItemToObject(item, "metrics", metrics); - tjsonAddItemToArray(arrayMetricGroups, item); + (void)tjsonAddItemToArray(arrayMetricGroups, item); } else{ metrics = tjsonGetObjectItem(item, "metrics"); @@ -109,20 +109,20 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me taosMemoryFreeClear(keyvalues); SJson* metric = tjsonCreateObject(); - tjsonAddStringToObject(metric, "name", metricName); - + (void)tjsonAddStringToObject(metric, "name", metricName); + double old_value = 0; #define USE_EXCHANGE #ifdef USE_EXCHANGE - taos_metric_sample_exchange(sample, 0, &old_value); + (void)taos_metric_sample_exchange(sample, 0, &old_value); #else old_value = sample->r_value; taos_metric_sample_set(sample, 0); #endif - tjsonAddDoubleToObject(metric, "value", old_value); - tjsonAddDoubleToObject(metric, "type", metric_type); - tjsonAddItemToArray(metrics, metric); + (void)tjsonAddDoubleToObject(metric, "value", old_value); + (void)tjsonAddDoubleToObject(metric, "type", metric_type); + (void)tjsonAddItemToArray(metrics, metric); return 0; } @@ -150,7 +150,7 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me SJson* table = tjsonGetArrayItem(tableArray, i); char tableName[MONITOR_TABLENAME_LEN] = {0}; - tjsonGetStringValue(table, "name", tableName); + (void)tjsonGetStringValue(table, "name", tableName); if(strcmp(tableName, arr[0]) == 0){ isFound = true; arrayMetricGroups = tjsonGetObjectItem(table, "metric_groups"); @@ -161,10 +161,10 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me if(!isFound){ table = tjsonCreateObject(); - tjsonAddStringToObject(table, "name", arr[0]); + (void)tjsonAddStringToObject(table, "name", arr[0]); arrayMetricGroups = tjsonCreateArray(); - tjsonAddItemToObject(table, "metric_groups", arrayMetricGroups); + (void)tjsonAddItemToObject(table, "metric_groups", arrayMetricGroups); } int32_t sample_count = 0; @@ -183,7 +183,7 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me } if(!isFound && sample_count > 0){ - tjsonAddItemToArray(tableArray, table); + (void)tjsonAddItemToArray(tableArray, table); } else{ if(table != NULL) tjsonDelete(table); diff --git a/source/libs/monitorfw/src/taos_metric_sample.c b/source/libs/monitorfw/src/taos_metric_sample.c index 4688672835..ccddefa17e 100644 --- a/source/libs/monitorfw/src/taos_metric_sample.c +++ b/source/libs/monitorfw/src/taos_metric_sample.c @@ -63,7 +63,7 @@ int taos_metric_sample_destroy_generic(void *gen) { void taos_metric_sample_free_generic(void *gen) { taos_metric_sample_t *self = (taos_metric_sample_t *)gen; - taos_metric_sample_destroy(self); + (void)taos_metric_sample_destroy(self); } int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) { diff --git a/source/libs/monitorfw/src/taos_monitor_util.c b/source/libs/monitorfw/src/taos_monitor_util.c index d338215426..2285ed9e71 100644 --- a/source/libs/monitorfw/src/taos_monitor_util.c +++ b/source/libs/monitorfw/src/taos_monitor_util.c @@ -84,10 +84,10 @@ bool taos_monitor_is_match(const SJson* tags, char** pairs, int32_t count) { SJson* item = tjsonGetArrayItem(tags, i); char item_name[MONITOR_TAG_NAME_LEN] = {0}; - tjsonGetStringValue(item, "name", item_name); + (void)tjsonGetStringValue(item, "name", item_name); char item_value[MONITOR_TAG_VALUE_LEN] = {0}; - tjsonGetStringValue(item, "value", item_value); + (void)tjsonGetStringValue(item, "value", item_value); bool isfound = false; for(int32_t j = 0; j < count; j++){ diff --git a/source/libs/monitorfw/src/taos_string_builder.c b/source/libs/monitorfw/src/taos_string_builder.c index e1bfa4142c..208f3f6d51 100644 --- a/source/libs/monitorfw/src/taos_string_builder.c +++ b/source/libs/monitorfw/src/taos_string_builder.c @@ -44,7 +44,7 @@ taos_string_builder_t *taos_string_builder_new(void) { self->init_size = TAOS_STRING_BUILDER_INIT_SIZE; r = taos_string_builder_init(self); if (r) { - taos_string_builder_destroy(self); + (void)taos_string_builder_destroy(self); return NULL; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 08fbbd7bad..0fd1121aaa 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -12984,7 +12984,11 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* } SNode* pCol; col_id_t index = 0; - tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols); + int32_t code = tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols); + if (TSDB_CODE_SUCCESS != code) { + tdDestroySVCreateTbReq(&req); + return code; + } FOREACH(pCol, pStmt->pCols) { SColumnDefNode* pColDef = (SColumnDefNode*)pCol; SSchema* pScheam = req.ntb.schemaRow.pSchema + index; diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 3d344a8a20..bce8cda125 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -128,7 +128,7 @@ static STaskQueue taskQueue = {0}; static void processTaskQueue(SQueueInfo *pInfo, SSchedMsg *pSchedMsg) { __async_exec_fn_t execFn = (__async_exec_fn_t)pSchedMsg->ahandle; - execFn(pSchedMsg->thandle); + (void)execFn(pSchedMsg->thandle); taosFreeQitem(pSchedMsg); } diff --git a/source/libs/stream/inc/streamBackendRocksdb.h b/source/libs/stream/inc/streamBackendRocksdb.h index e671a59cf6..df513f43b3 100644 --- a/source/libs/stream/inc/streamBackendRocksdb.h +++ b/source/libs/stream/inc/streamBackendRocksdb.h @@ -143,9 +143,9 @@ SListNode* streamBackendAddCompare(void* backend, void* arg); void streamBackendDelCompare(void* backend, void* arg); int32_t streamStateCvtDataFormat(char* path, char* key, void* cfInst); -STaskDbWrapper* taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer); -void taskDbDestroy(void* pBackend, bool flush); -void taskDbDestroy2(void* pBackend); +int32_t taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer, STaskDbWrapper** ppTaskDb); +void taskDbDestroy(void* pBackend, bool flush); +void taskDbDestroy2(void* pBackend); void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId); @@ -253,7 +253,7 @@ int32_t taskDbDestroySnap(void* arg, SArray* pSnapInfo); int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId, int64_t processId); -SBkdMgt* bkdMgtCreate(char* path); +int32_t bkdMgtCreate(char* path, SBkdMgt **bm); int32_t bkdMgtAddChkp(SBkdMgt* bm, char* task, char* path); int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* name); int32_t bkdMgtDumpTo(SBkdMgt* bm, char* taskId, char* dname); diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 64795842c8..428cbbe268 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -424,7 +424,7 @@ void cleanDir(const char* pPath, const char* id) { if (taosIsDir(pPath)) { taosRemoveDir(pPath); - taosMkDir(pPath); + (void)taosMkDir(pPath); stInfo("%s clear dir:%s, succ", id, pPath); } } @@ -531,7 +531,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId _EXIT: if (code != 0) { if (rename) { - taosRenameFile(defaultTmp, defaultPath); + (void)taosRenameFile(defaultTmp, defaultPath); } } @@ -652,13 +652,13 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) { taosMemoryFreeClear(srcName); taosMemoryFreeClear(dstName); - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); return code; _ERROR: taosMemoryFreeClear(srcName); taosMemoryFreeClear(dstName); - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); return code; } @@ -820,8 +820,8 @@ void* streamBackendInit(const char* streamPath, int64_t chkpId, int32_t vgId) { uint32_t dbMemLimit = nextPow2(tsMaxStreamBackendCache) << 20; SBackendWrapper* pHandle = taosMemoryCalloc(1, sizeof(SBackendWrapper)); pHandle->list = tdListNew(sizeof(SCfComparator)); - taosThreadMutexInit(&pHandle->mutex, NULL); - taosThreadMutexInit(&pHandle->cfMutex, NULL); + (void)taosThreadMutexInit(&pHandle->mutex, NULL); + (void)taosThreadMutexInit(&pHandle->cfMutex, NULL); pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); rocksdb_env_t* env = rocksdb_create_default_env(); // rocksdb_envoptions_create(); @@ -890,7 +890,7 @@ _EXIT: streamMutexDestroy(&pHandle->mutex); streamMutexDestroy(&pHandle->cfMutex); taosHashCleanup(pHandle->cfInst); - tdListFree(pHandle->list); + (void)tdListFree(pHandle->list); taosMemoryFree(pHandle); stDebug("failed to init stream backend at %s", backendPath); taosMemoryFree(backendPath); @@ -922,7 +922,7 @@ void streamBackendCleanup(void* arg) { head = tdListPopHead(pHandle->list); } - tdListFree(pHandle->list); + (void)tdListFree(pHandle->list); streamMutexDestroy(&pHandle->mutex); streamMutexDestroy(&pHandle->cfMutex); @@ -933,11 +933,11 @@ void streamBackendCleanup(void* arg) { void streamBackendHandleCleanup(void* arg) { SBackendCfWrapper* wrapper = arg; bool remove = wrapper->remove; - taosThreadRwlockWrlock(&wrapper->rwLock); + (void)taosThreadRwlockWrlock(&wrapper->rwLock); stDebug("start to do-close backendwrapper %p, %s", wrapper, wrapper->idstr); if (wrapper->rocksdb == NULL) { - taosThreadRwlockUnlock(&wrapper->rwLock); + (void)taosThreadRwlockUnlock(&wrapper->rwLock); return; } @@ -988,9 +988,9 @@ void streamBackendHandleCleanup(void* arg) { wrapper->readOpts = NULL; taosMemoryFreeClear(wrapper->cfOpts); taosMemoryFreeClear(wrapper->param); - taosThreadRwlockUnlock(&wrapper->rwLock); + (void)taosThreadRwlockUnlock(&wrapper->rwLock); - taosThreadRwlockDestroy(&wrapper->rwLock); + (void)taosThreadRwlockDestroy(&wrapper->rwLock); wrapper->rocksdb = NULL; // taosReleaseRef(streamBackendId, wrapper->backendId); @@ -1083,12 +1083,20 @@ int32_t delObsoleteCheckpoint(void* arg, const char* path) { int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) { STaskDbWrapper* pBackend = arg; - taosThreadRwlockWrlock(&pBackend->chkpDirLock); + (void)taosThreadRwlockWrlock(&pBackend->chkpDirLock); - taosArrayPush(pBackend->chkpSaved, &chkpId); + (void)taosArrayPush(pBackend->chkpSaved, &chkpId); SArray* chkpDel = taosArrayInit(8, sizeof(int64_t)); + if (chkpDel == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + SArray* chkpDup = taosArrayInit(8, sizeof(int64_t)); + if (chkpDup == NULL) { + taosArrayDestroy(chkpDel); + return TSDB_CODE_OUT_OF_MEMORY; + } int64_t firsId = 0; if (taosArrayGetSize(pBackend->chkpInUse) >= 1) { @@ -1097,9 +1105,9 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) { for (int i = 0; i < taosArrayGetSize(pBackend->chkpSaved); i++) { int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i); if (id >= firsId) { - taosArrayPush(chkpDup, &id); + (void)taosArrayPush(chkpDup, &id); } else { - taosArrayPush(chkpDel, &id); + (void)taosArrayPush(chkpDel, &id); } } } else { @@ -1108,11 +1116,11 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) { for (int i = 0; i < dsz; i++) { int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i); - taosArrayPush(chkpDel, &id); + (void)taosArrayPush(chkpDel, &id); } for (int i = dsz < 0 ? 0 : dsz; i < sz; i++) { int64_t id = *(int64_t*)taosArrayGet(pBackend->chkpSaved, i); - taosArrayPush(chkpDup, &id); + (void)taosArrayPush(chkpDup, &id); } } taosArrayDestroy(pBackend->chkpSaved); @@ -1263,7 +1271,7 @@ int32_t taskDbLoadChkpInfo(STaskDbWrapper* pBackend) { int ret = sscanf(taosGetDirEntryName(de), "checkpoint%" PRId64 "", &checkpointId); if (ret == 1) { - taosArrayPush(pBackend->chkpSaved, &checkpointId); + (void)taosArrayPush(pBackend->chkpSaved, &checkpointId); } } else { continue; @@ -1272,7 +1280,7 @@ int32_t taskDbLoadChkpInfo(STaskDbWrapper* pBackend) { taosArraySort(pBackend->chkpSaved, chkpIdComp); taosMemoryFree(pChkpDir); - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); return 0; } @@ -1281,7 +1289,7 @@ int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_ha for (int i = 0; i < sizeof(ginitDict) / sizeof(ginitDict[0]); i++) { if (pBackend->pCf[i]) { rocksdb_column_family_handle_t* p = pBackend->pCf[i]; - taosArrayPush(pHandle, &p); + (void)taosArrayPush(pHandle, &p); } } int32_t nCf = taosArrayGetSize(pHandle); @@ -1613,7 +1621,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) { code = 0; _EXIT: - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); taosMemoryFree(pDst); return code; } @@ -1671,7 +1679,7 @@ int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId, int64_t processId) { goto _EXIT; } - atomic_store_64(&pTaskDb->dataWritten, 0); + (void)atomic_store_64(&pTaskDb->dataWritten, 0); pTaskDb->chkpId = chkpId; _EXIT: @@ -1679,13 +1687,13 @@ _EXIT: // clear checkpoint dir if failed if (code != 0 && pChkpDir != NULL) { if (taosDirExist(pChkpIdDir)) { - taosRemoveDir(pChkpIdDir); + (void)taosRemoveDir(pChkpIdDir); } } taosMemoryFree(pChkpIdDir); taosMemoryFree(pChkpDir); - taosReleaseRef(taskDbWrapperId, refId); + (void)taosReleaseRef(taskDbWrapperId, refId); taosMemoryFree(ppCf); return code; } @@ -1758,7 +1766,7 @@ int defaultKeyComp(void* state, const char* aBuf, size_t aLen, const char* bBuf, } int streamStateValueIsStale(char* v) { int64_t ts = 0; - taosDecodeFixedI64(v, &ts); + (void)taosDecodeFixedI64(v, &ts); return (ts != 0 && ts < taosGetTimestampMs()) ? 1 : 0; } int iterValueIsStale(rocksdb_iterator_t* iter) { @@ -1801,8 +1809,8 @@ int stateKeyDBComp(void* state, const char* aBuf, size_t aLen, const char* bBuf, p1 = taosDecodeFixedI64(p1, &key1.key.ts); p2 = taosDecodeFixedI64(p2, &key2.key.ts); - taosDecodeFixedI64(p1, &key1.opNum); - taosDecodeFixedI64(p2, &key2.opNum); + (void)taosDecodeFixedI64(p1, &key1.opNum); + (void)taosDecodeFixedI64(p2, &key2.opNum); return stateKeyCmpr(&key1, sizeof(key1), &key2, sizeof(key2)); } @@ -1998,8 +2006,8 @@ int parKeyDBComp(void* state, const char* aBuf, size_t aLen, const char* bBuf, s char* p1 = (char*)aBuf; char* p2 = (char*)bBuf; - taosDecodeFixedI64(p1, &w1); - taosDecodeFixedI64(p2, &w2); + (void)taosDecodeFixedI64(p1, &w1); + (void)taosDecodeFixedI64(p2, &w2); if (w1 == w2) { return 0; } else { @@ -2320,7 +2328,7 @@ void taskDbRemoveRef(void* pTaskDb) { } STaskDbWrapper* pBackend = pTaskDb; - taosReleaseRef(taskDbWrapperId, pBackend->refId); + (void)taosReleaseRef(taskDbWrapperId, pBackend->refId); } void taskDbInitOpt(STaskDbWrapper* pTaskDb) { @@ -2386,22 +2394,22 @@ void taskDbInitChkpOpt(STaskDbWrapper* pTaskDb) { pTaskDb->chkpId = -1; pTaskDb->chkpCap = 4; pTaskDb->chkpSaved = taosArrayInit(4, sizeof(int64_t)); - taskDbLoadChkpInfo(pTaskDb); + (void)taskDbLoadChkpInfo(pTaskDb); pTaskDb->chkpInUse = taosArrayInit(4, sizeof(int64_t)); - taosThreadRwlockInit(&pTaskDb->chkpDirLock, NULL); + (void)taosThreadRwlockInit(&pTaskDb->chkpDirLock, NULL); } void taskDbRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) { - taosThreadRwlockWrlock(&pTaskDb->chkpDirLock); - taosArrayPush(pTaskDb->chkpInUse, &chkp); + (void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock); + (void)taosArrayPush(pTaskDb->chkpInUse, &chkp); taosArraySort(pTaskDb->chkpInUse, chkpIdComp); - taosThreadRwlockUnlock(&pTaskDb->chkpDirLock); + (void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock); } void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) { - taosThreadRwlockWrlock(&pTaskDb->chkpDirLock); + (void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock); int32_t size = taosArrayGetSize(pTaskDb->chkpInUse); for (int i = 0; i < size; i++) { int64_t* p = taosArrayGet(pTaskDb->chkpInUse, i); @@ -2410,13 +2418,13 @@ void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) { break; } } - taosThreadRwlockUnlock(&pTaskDb->chkpDirLock); + (void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock); } void taskDbDestroyChkpOpt(STaskDbWrapper* pTaskDb) { taosArrayDestroy(pTaskDb->chkpSaved); taosArrayDestroy(pTaskDb->chkpInUse); - taosThreadRwlockDestroy(&pTaskDb->chkpDirLock); + (void)taosThreadRwlockDestroy(&pTaskDb->chkpDirLock); } int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** stateFullPath) { @@ -2462,9 +2470,9 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId) { STaskDbWrapper* p = pTaskDb; - streamMutexLock(&p->mutex); + (void)streamMutexLock(&p->mutex); p->chkpId = chkpId; - streamMutexUnlock(&p->mutex); + (void)streamMutexUnlock(&p->mutex); } STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) { @@ -2476,7 +2484,7 @@ STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) { pTaskDb->idstr = key ? taosStrdup(key) : NULL; pTaskDb->path = statePath ? taosStrdup(statePath) : NULL; - taosThreadMutexInit(&pTaskDb->mutex, NULL); + (void)taosThreadMutexInit(&pTaskDb->mutex, NULL); taskDbInitChkpOpt(pTaskDb); taskDbInitOpt(pTaskDb); @@ -2525,35 +2533,35 @@ _EXIT: return NULL; } -STaskDbWrapper* taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer) { +int32_t taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer, STaskDbWrapper** ppTaskDb) { char* statePath = NULL; char* dbPath = NULL; int code = 0; - terrno = 0; if ((code = restoreCheckpointData(path, key, chkptId, &statePath, &dbPath, processVer)) < 0) { - terrno = code; stError("failed to restore checkpoint data, path:%s, key:%s, checkpointId: %" PRId64 "reason:%s", path, key, - chkptId, tstrerror(terrno)); - return NULL; + chkptId, tstrerror(code)); + return code; } STaskDbWrapper* pTaskDb = taskDbOpenImpl(key, statePath, dbPath); if (pTaskDb != NULL) { int64_t chkpId = -1, ver = -1; - if ((code = chkpLoadExtraInfo(dbPath, &chkpId, &ver) == 0)) { + if ((code = chkpLoadExtraInfo(dbPath, &chkpId, &ver)) == 0) { *processVer = ver; } else { - terrno = code; stError("failed to load extra info, path:%s, key:%s, checkpointId: %" PRId64 "reason:%s", path, key, chkptId, - tstrerror(terrno)); + tstrerror(code)); taskDbDestroy(pTaskDb, false); - return NULL; + return code; } + } else { + code = TSDB_CODE_INVALID_PARA; } taosMemoryFree(dbPath); taosMemoryFree(statePath); - return pTaskDb; + *ppTaskDb = pTaskDb; + return code; } void taskDbDestroy(void* pDb, bool flush) { @@ -2650,7 +2658,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char char* buf = taosMemoryCalloc(1, cap); if (buf == NULL) { - taosReleaseRef(taskDbWrapperId, refId); + (void)taosReleaseRef(taskDbWrapperId, refId); return TSDB_CODE_OUT_OF_MEMORY; } @@ -2658,7 +2666,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char snprintf(buf, cap, "%s%s%s%s%s%" PRId64 "", pDb->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, "checkpoint", chkpId); if (nBytes <= 0 || nBytes >= cap) { taosMemoryFree(buf); - taosReleaseRef(taskDbWrapperId, refId); + (void)taosReleaseRef(taskDbWrapperId, refId); return TSDB_CODE_OUT_OF_RANGE; } @@ -2669,7 +2677,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char taosMemoryFree(buf); } - taosReleaseRef(taskDbWrapperId, refId); + (void)taosReleaseRef(taskDbWrapperId, refId); return code; } @@ -2794,8 +2802,10 @@ int32_t streamStateCvtDataFormat(char* path, char* key, void* pCfInst) { int32_t code = 0; int64_t processVer = -1; - STaskDbWrapper* pTaskDb = taskDbOpen(path, key, 0, &processVer); - RocksdbCfInst* pSrcBackend = pCfInst; + STaskDbWrapper* pTaskDb = NULL; + + code = taskDbOpen(path, key, 0, &processVer, &pTaskDb); + RocksdbCfInst* pSrcBackend = pCfInst; for (int i = 0; i < nCf; i++) { rocksdb_column_family_handle_t* pSrcCf = pSrcBackend->pHandle[i]; @@ -2904,7 +2914,7 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t inst->dbOpt = handle->dbOpt; rocksdb_writeoptions_disable_WAL(inst->wOpt, 1); - taosHashPut(handle->cfInst, idstr, strlen(idstr) + 1, &inst, sizeof(void*)); + (void)taosHashPut(handle->cfInst, idstr, strlen(idstr) + 1, &inst, sizeof(void*)); } else { inst = *pInst; } @@ -3144,9 +3154,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe break; \ } \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ - atomic_add_fetch_64(&wrapper->dataWritten, 1); \ + (void)atomic_add_fetch_64(&wrapper->dataWritten, 1); \ char toString[128] = {0}; \ - if (stDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \ + if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \ int32_t klen = ginitDict[i].enFunc((void*)key, buf); \ rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \ rocksdb_writeoptions_t* opts = wrapper->writeOpt; \ @@ -3178,7 +3188,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe } \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ char toString[128] = {0}; \ - if (stDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \ + if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \ int32_t klen = ginitDict[i].enFunc((void*)key, buf); \ rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \ rocksdb_t* db = wrapper->db; \ @@ -3221,9 +3231,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe break; \ } \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ - atomic_add_fetch_64(&wrapper->dataWritten, 1); \ + (void)atomic_add_fetch_64(&wrapper->dataWritten, 1); \ char toString[128] = {0}; \ - if (stDebugFlag & DEBUG_TRACE) ginitDict[i].toStrFunc((void*)key, toString); \ + if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \ int32_t klen = ginitDict[i].enFunc((void*)key, buf); \ rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \ rocksdb_t* db = wrapper->db; \ @@ -3262,7 +3272,7 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) { stDebug("streamStateClear_rocksdb"); STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; - atomic_add_fetch_64(&wrapper->dataWritten, 1); + (void)atomic_add_fetch_64(&wrapper->dataWritten, 1); char sKeyStr[128] = {0}; char eKeyStr[128] = {0}; @@ -3278,8 +3288,8 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) { if (err != NULL) { char toStringStart[128] = {0}; char toStringEnd[128] = {0}; - stateKeyToString(&sKey, toStringStart); - stateKeyToString(&eKey, toStringEnd); + (void)stateKeyToString(&sKey, toStringStart); + (void)stateKeyToString(&eKey, toStringEnd); stWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err); taosMemoryFree(err); @@ -3296,15 +3306,21 @@ void streamStateCurNext_rocksdb(SStreamStateCur* pCur) { } } int32_t streamStateGetFirst_rocksdb(SStreamState* pState, SWinKey* key) { + int code = 0; stDebug("streamStateGetFirst_rocksdb"); SWinKey tmp = {.ts = 0, .groupId = 0}; - streamStatePut_rocksdb(pState, &tmp, NULL, 0); + code = streamStatePut_rocksdb(pState, &tmp, NULL, 0); + if (code != 0) { + return code; + } SStreamStateCur* pCur = streamStateSeekKeyNext_rocksdb(pState, &tmp); - int32_t code = streamStateGetKVByCur_rocksdb(pCur, key, NULL, 0); + code = streamStateGetKVByCur_rocksdb(pCur, key, NULL, 0); + if (code != 0) { + return code; + } streamStateFreeCur(pCur); - streamStateDel_rocksdb(pState, &tmp); - return code; + return streamStateDel_rocksdb(pState, &tmp); } int32_t streamStateGetGroupKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen) { @@ -3333,6 +3349,9 @@ int32_t streamStateAddIfNotExist_rocksdb(SStreamState* pState, const SWinKey* ke return 0; } *pVal = taosMemoryMalloc(size); + if (*pVal == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } memset(*pVal, 0, size); return 0; } @@ -3349,7 +3368,7 @@ int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, cons if (rocksdb_iter_valid(pCur->iter) && !iterValueIsStale(pCur->iter)) { size_t tlen; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &tlen); - stateKeyDecode((void*)pKtmp, keyStr); + (void)stateKeyDecode((void*)pKtmp, keyStr); if (pKtmp->opNum != pCur->number) { return -1; } @@ -3402,7 +3421,7 @@ SStreamStateCur* streamStateSeekKeyNext_rocksdb(SStreamState* pState, const SWin SStateKey curKey; size_t kLen; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); - stateKeyDecode((void*)&curKey, keyStr); + (void)stateKeyDecode((void*)&curKey, keyStr); if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) { return pCur; } @@ -3424,7 +3443,7 @@ SStreamStateCur* streamStateSeekToLast_rocksdb(SStreamState* pState) { { char tbuf[256] = {0}; - stateKeyToString((void*)&maxStateKey, tbuf); + (void)stateKeyToString((void*)&maxStateKey, tbuf); stDebug("seek to last:%s", tbuf); } @@ -3475,7 +3494,7 @@ SStreamStateCur* streamStateGetCur_rocksdb(SStreamState* pState, const SWinKey* SStateKey curKey; size_t kLen = 0; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); - stateKeyDecode((void*)&curKey, keyStr); + (void)stateKeyDecode((void*)&curKey, keyStr); if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) == 0) { pCur->number = pState->number; @@ -3623,7 +3642,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pSta size_t klen; const char* iKey = rocksdb_iter_key(pCur->iter, &klen); SStateSessionKey curKey = {0}; - stateSessionKeyDecode(&curKey, (char*)iKey); + (void)stateSessionKeyDecode(&curKey, (char*)iKey); if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) >= 0) return pCur; rocksdb_iter_prev(pCur->iter); @@ -3660,7 +3679,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pSta size_t klen; const char* iKey = rocksdb_iter_key(pCur->iter, &klen); SStateSessionKey curKey = {0}; - stateSessionKeyDecode(&curKey, (char*)iKey); + (void)stateSessionKeyDecode(&curKey, (char*)iKey); if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) <= 0) return pCur; rocksdb_iter_next(pCur->iter); @@ -3700,7 +3719,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, con size_t klen; const char* iKey = rocksdb_iter_key(pCur->iter, &klen); SStateSessionKey curKey = {0}; - stateSessionKeyDecode(&curKey, (char*)iKey); + (void)stateSessionKeyDecode(&curKey, (char*)iKey); if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) < 0) return pCur; rocksdb_iter_next(pCur->iter); @@ -3740,7 +3759,7 @@ SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, con size_t klen; const char* iKey = rocksdb_iter_key(pCur->iter, &klen); SStateSessionKey curKey = {0}; - stateSessionKeyDecode(&curKey, (char*)iKey); + (void)stateSessionKeyDecode(&curKey, (char*)iKey); if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur; rocksdb_iter_prev(pCur->iter); @@ -3763,7 +3782,7 @@ int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* return -1; } const char* curKey = rocksdb_iter_key(pCur->iter, (size_t*)&kLen); - stateSessionKeyDecode((void*)&ktmp, (char*)curKey); + (void)stateSessionKeyDecode((void*)&ktmp, (char*)curKey); if (pVal != NULL) *pVal = NULL; if (pVLen != NULL) *pVLen = 0; @@ -3842,7 +3861,7 @@ SStreamStateCur* streamStateFillGetCur_rocksdb(SStreamState* pState, const SWinK size_t kLen; SWinKey curKey; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); - winKeyDecode((void*)&curKey, keyStr); + (void)winKeyDecode((void*)&curKey, keyStr); if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) == 0) { return pCur; } @@ -3862,7 +3881,7 @@ int32_t streamStateFillGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, } size_t klen, vlen; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &klen); - winKeyDecode(&winKey, keyStr); + (void)winKeyDecode(&winKey, keyStr); const char* valStr = rocksdb_iter_value(pCur->iter, &vlen); int32_t len = valueDecode((void*)valStr, vlen, NULL, (char**)pVal); @@ -3903,7 +3922,7 @@ SStreamStateCur* streamStateFillSeekKeyNext_rocksdb(SStreamState* pState, const SWinKey curKey; size_t kLen = 0; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); - winKeyDecode((void*)&curKey, keyStr); + (void)winKeyDecode((void*)&curKey, keyStr); if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) < 0) { return pCur; } @@ -3940,7 +3959,7 @@ SStreamStateCur* streamStateFillSeekKeyPrev_rocksdb(SStreamState* pState, const SWinKey curKey; size_t kLen = 0; char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); - winKeyDecode((void*)&curKey, keyStr); + (void)winKeyDecode((void*)&curKey, keyStr); if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) > 0) { return pCur; } @@ -4029,11 +4048,12 @@ int32_t streamStateSessionAddIfNotExist_rocksdb(SStreamState* pState, SSessionKe int32_t valSize = *pVLen; void* tmp = taosMemoryMalloc(valSize); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev_rocksdb(pState, key); - if (pCur == NULL) { - } - int32_t code = streamStateSessionGetKVByCur_rocksdb(pCur, key, pVal, pVLen); + int32_t code = streamStateSessionGetKVByCur_rocksdb(pCur, key, pVal, pVLen); if (code == 0) { if (sessionRangeKeyCmpr(&searchKey, key) == 0) { @@ -4219,7 +4239,7 @@ int32_t streamDefaultIterGet_rocksdb(SStreamState* pState, const void* start, co if (strncmp(key, start, strlen(start)) == 0 && strlen(key) >= strlen(start) + 1) { int64_t checkPoint = 0; if (sscanf(key + strlen(key), ":%" PRId64 "", &checkPoint) == 1) { - taosArrayPush(result, &checkPoint); + (void)taosArrayPush(result, &checkPoint); } } else { break; @@ -4311,7 +4331,7 @@ int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb { char tbuf[256] = {0}; - ginitDict[i].toStrFunc((void*)key, tbuf); + (void)(ginitDict[i].toStrFunc((void*)key, tbuf)); stTrace("streamState str: %s succ to write to %s_%s, len: %d", tbuf, wrapper->idstr, ginitDict[i].key, vlen); } return 0; @@ -4326,7 +4346,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; - atomic_add_fetch_64(&wrapper->dataWritten, 1); + (void)atomic_add_fetch_64(&wrapper->dataWritten, 1); rocksdb_column_family_handle_t* pCf = wrapper->pCf[ginitDict[cfIdx].idx]; rocksdb_writebatch_put_cf((rocksdb_writebatch_t*)pBatch, pCf, buf, (size_t)klen, ttlV, (size_t)ttlVLen); @@ -4434,8 +4454,8 @@ int32_t compareHashTableImpl(SHashObj* p1, SHashObj* p2, SArray* diff) { if (fname == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - strncpy(fname, name, len); - taosArrayPush(diff, &fname); + (void)strncpy(fname, name, len); + (void)taosArrayPush(diff, &fname); } pIter = taosHashIterate(p2, pIter); } @@ -4511,7 +4531,7 @@ void dbChkpDebugInfo(SDbChkp* pDb) { int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { int32_t code = 0; int32_t nBytes; - taosThreadRwlockWrlock(&p->rwLock); + (void)taosThreadRwlockWrlock(&p->rwLock); p->preCkptId = p->curChkpId; p->curChkpId = chkpId; @@ -4529,7 +4549,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { nBytes = snprintf(p->buf, p->len, "%s%s%s%scheckpoint%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId); if (nBytes <= 0 || nBytes >= p->len) { - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return TSDB_CODE_OUT_OF_RANGE; } @@ -4539,7 +4559,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { TdDirPtr pDir = taosOpenDir(p->buf); if (pDir == NULL) { - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return TAOS_SYSTEM_ERROR(errno); } @@ -4575,9 +4595,9 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { continue; } } - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); if (code != 0) { - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return code; } @@ -4589,12 +4609,12 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { if (name != NULL && !isBkdDataMeta(name, len)) { char* fname = taosMemoryCalloc(1, len + 1); if (fname == NULL) { - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return TSDB_CODE_OUT_OF_MEMORY; } - strncpy(fname, name, len); - taosArrayPush(p->pAdd, &fname); + (void)strncpy(fname, name, len); + (void)taosArrayPush(p->pAdd, &fname); } pIter = taosHashIterate(p->pSstTbl[1 - p->idx], pIter); } @@ -4626,17 +4646,18 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { p->idx = 1 - p->idx; - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return code; } void dbChkpDestroy(SDbChkp* pChkp); -SDbChkp* dbChkpCreate(char* path, int64_t initChkpId) { +int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { + int32_t code = 0; SDbChkp* p = taosMemoryCalloc(1, sizeof(SDbChkp)); if (p == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } @@ -4644,57 +4665,57 @@ SDbChkp* dbChkpCreate(char* path, int64_t initChkpId) { p->preCkptId = -1; p->pSST = taosArrayInit(64, sizeof(void*)); if (p->pSST == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; dbChkpDestroy(p); - return NULL; + return code; } p->path = path; p->len = strlen(path) + 128; p->buf = taosMemoryCalloc(1, p->len); if (p->buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->idx = 0; p->pSstTbl[0] = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (p->pSstTbl[0] == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->pSstTbl[1] = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (p->pSstTbl[1] == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->pAdd = taosArrayInit(64, sizeof(void*)); if (p->pAdd == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->pDel = taosArrayInit(64, sizeof(void*)); if (p->pDel == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->update = 0; - taosThreadRwlockInit(&p->rwLock, NULL); + (void)taosThreadRwlockInit(&p->rwLock, NULL); SArray* list = NULL; - int32_t code = dbChkpGetDelta(p, initChkpId, list); + code = dbChkpGetDelta(p, initChkpId, list); if (code != 0) { goto _EXIT; } - - return p; + *ppChkp = p; + return code; _EXIT: dbChkpDestroy(p); - return NULL; + return code; } void dbChkpDestroy(SDbChkp* pChkp) { @@ -4797,7 +4818,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { code = TSDB_CODE_OUT_OF_MEMORY; goto _ERROR; } - taosArrayPush(list, &p); + (void)taosArrayPush(list, &p); } // copy current file to dst dir @@ -4863,7 +4884,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { if (nBytes <= 0 || nBytes >= sizeof(content)) { code = TSDB_CODE_OUT_OF_RANGE; stError("chkp failed to format meta file: %s, reason: invalid msg", dstDir); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); goto _ERROR; } @@ -4871,10 +4892,10 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { if (nBytes != strlen(content)) { code = TAOS_SYSTEM_ERROR(errno); stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code)); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); goto _ERROR; } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); // clear delta data buf taosArrayClearP(p->pAdd, taosMemoryFree); @@ -4883,39 +4904,40 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { _ERROR: taosMemoryFree(buffer); - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return code; } -SBkdMgt* bkdMgtCreate(char* path) { - terrno = 0; +int32_t bkdMgtCreate(char* path, SBkdMgt** mgt) { + int32_t code = 0; SBkdMgt* p = taosMemoryCalloc(1, sizeof(SBkdMgt)); if (p == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + code = TSDB_CODE_OUT_OF_MEMORY; + return code; } p->pDbChkpTbl = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (p->pDbChkpTbl == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; bkdMgtDestroy(p); - return NULL; + return code; } p->path = taosStrdup(path); if (p->path == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; bkdMgtDestroy(p); - return NULL; + return code; } if (taosThreadRwlockInit(&p->rwLock, NULL) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); + code = TAOS_SYSTEM_ERROR(errno); bkdMgtDestroy(p); - return NULL; + return code; } + *mgt = p; - return p; + return code; } void bkdMgtDestroy(SBkdMgt* bm) { @@ -4928,7 +4950,7 @@ void bkdMgtDestroy(SBkdMgt* bm) { pIter = taosHashIterate(bm->pDbChkpTbl, pIter); } - taosThreadRwlockDestroy(&bm->rwLock); + (void)taosThreadRwlockDestroy(&bm->rwLock); taosMemoryFree(bm->path); taosHashCleanup(bm->pDbChkpTbl); @@ -4936,7 +4958,7 @@ void bkdMgtDestroy(SBkdMgt* bm) { } int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* dname) { int32_t code = 0; - taosThreadRwlockWrlock(&bm->rwLock); + (void)taosThreadRwlockWrlock(&bm->rwLock); SDbChkp** ppChkp = taosHashGet(bm->pDbChkpTbl, taskId, strlen(taskId)); SDbChkp* pChkp = ppChkp != NULL ? *ppChkp : NULL; @@ -4944,36 +4966,36 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, int32_t cap = strlen(bm->path) + 64; char* path = taosMemoryCalloc(1, cap); if (path == NULL) { - taosThreadRwlockUnlock(&bm->rwLock); + (void)taosThreadRwlockUnlock(&bm->rwLock); return TSDB_CODE_OUT_OF_MEMORY; } int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId); if (nBytes <= 0 || nBytes >= cap) { taosMemoryFree(path); - taosThreadRwlockUnlock(&bm->rwLock); + (void)taosThreadRwlockUnlock(&bm->rwLock); code = TSDB_CODE_OUT_OF_RANGE; return code; } - SDbChkp* p = dbChkpCreate(path, chkpId); - if (p == NULL) { + SDbChkp* p = NULL; + code = dbChkpCreate(path, chkpId, &p); + if (code != 0) { taosMemoryFree(path); - taosThreadRwlockUnlock(&bm->rwLock); - code = terrno; + (void)taosThreadRwlockUnlock(&bm->rwLock); return code; } if (taosHashPut(bm->pDbChkpTbl, taskId, strlen(taskId), &p, sizeof(void*)) != 0) { dbChkpDestroy(p); - taosThreadRwlockUnlock(&bm->rwLock); + (void)taosThreadRwlockUnlock(&bm->rwLock); code = terrno; return code; } pChkp = p; code = dbChkpDumpTo(pChkp, dname, list); - taosThreadRwlockUnlock(&bm->rwLock); + (void)taosThreadRwlockUnlock(&bm->rwLock); return code; } else { code = dbChkpGetDelta(pChkp, chkpId, NULL); @@ -4982,7 +5004,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, } } - taosThreadRwlockUnlock(&bm->rwLock); + (void)taosThreadRwlockUnlock(&bm->rwLock); return code; } @@ -4993,8 +5015,9 @@ int32_t bkdMgtAddChkp(SBkdMgt* bm, char* task, char* path) { taosThreadRwlockWrlock(&bm->rwLock); SDbChkp** pp = taosHashGet(bm->pDbChkpTbl, task, strlen(task)); if (pp == NULL) { - SDbChkp* p = dbChkpCreate(path, 0); - if (p != NULL) { + SDbChkp* p = NULL; + code = dbChkpCreate(path, 0, &p); + if (code != 0) { taosHashPut(bm->pDbChkpTbl, task, strlen(task), &p, sizeof(void*)); code = 0; } diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 7b410501ca..81640e0050 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -68,12 +68,12 @@ static void streamMetaEnvInit() { } } -void streamMetaInit() { (void) taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); } +void streamMetaInit() { (void)taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); } void streamMetaCleanup() { - (void) taosCloseRef(streamBackendId); - (void) taosCloseRef(streamBackendCfWrapperId); - (void) taosCloseRef(streamMetaId); + (void)taosCloseRef(streamBackendId); + (void)taosCloseRef(streamBackendCfWrapperId); + (void)taosCloseRef(streamMetaId); metaRefMgtCleanup(); streamTimerCleanUp(); @@ -128,12 +128,12 @@ int32_t metaRefMgtAdd(int64_t vgId, int64_t* rid) { code = taosHashPut(gMetaRefMgt.pTable, &vgId, sizeof(vgId), &list, sizeof(void*)); if (code) { - stError("vgId:%d failed to put into metaRef table, rid:%" PRId64, (int32_t) vgId, *rid); + stError("vgId:%d failed to put into metaRef table, rid:%" PRId64, (int32_t)vgId, *rid); return code; } } else { SArray* list = *(SArray**)p; - void* px = taosArrayPush(list, &rid); + void* px = taosArrayPush(list, &rid); if (px == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -186,7 +186,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) { code = tdbTbcMoveToFirst(pCur); if (code) { - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); stError("vgId:%d failed to open stream meta file cursor, not perform compatible check", pMeta->vgId); return ret; } @@ -215,7 +215,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) { tdbFree(pKey); tdbFree(pVal); - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return ret; } @@ -276,6 +276,7 @@ int32_t streamMetaMayCvtDbFormat(SStreamMeta* pMeta) { } int32_t streamTaskSetDb(SStreamMeta* pMeta, SStreamTask* pTask, const char* key) { + int32_t code = 0; int64_t chkpId = pTask->chkInfo.checkpointId; streamMutexLock(&pMeta->backendMutex); @@ -299,8 +300,8 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, SStreamTask* pTask, const char* key) STaskDbWrapper* pBackend = NULL; int64_t processVer = -1; while (1) { - pBackend = taskDbOpen(pMeta->path, key, chkpId, &processVer); - if (pBackend != NULL) { + code = taskDbOpen(pMeta->path, key, chkpId, &processVer, &pBackend); + if (code == 0) { break; } @@ -319,7 +320,7 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, SStreamTask* pTask, const char* key) if (processVer != -1) pTask->chkInfo.processedVer = processVer; - int32_t code = taosHashPut(pMeta->pTaskDbUnique, key, strlen(key), &pBackend, sizeof(void*)); + code = taosHashPut(pMeta->pTaskDbUnique, key, strlen(key), &pBackend, sizeof(void*)); if (code) { stError("s-task:0x%x failed to put taskDb backend, code:out of memory", pTask->id.taskId); } @@ -469,8 +470,8 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, pMeta->qHandle = taosInitScheduler(32, 1, "stream-chkp", NULL); - pMeta->bkdChkptMgt = bkdMgtCreate(tpath); - if (pMeta->bkdChkptMgt == NULL) { + code = bkdMgtCreate(tpath, (SBkdMgt**)&pMeta->bkdChkptMgt); + if (code != 0) { goto _err; } @@ -485,7 +486,7 @@ _err: if (pMeta->pTaskList) taosArrayDestroy(pMeta->pTaskList); if (pMeta->pTaskDb) (void)tdbTbClose(pMeta->pTaskDb); if (pMeta->pCheckpointDb) (void)tdbTbClose(pMeta->pCheckpointDb); - if (pMeta->db) (void) tdbClose(pMeta->db); + if (pMeta->db) (void)tdbClose(pMeta->db); if (pMeta->pHbInfo) taosMemoryFreeClear(pMeta->pHbInfo); if (pMeta->updateInfo.pTasks) taosHashCleanup(pMeta->updateInfo.pTasks); if (pMeta->startInfo.pReadyTaskSet) taosHashCleanup(pMeta->startInfo.pReadyTaskSet); @@ -531,7 +532,7 @@ void streamMetaClear(SStreamMeta* pMeta) { // release the ref by timer if (p->info.delaySchedParam != 0 && p->info.fillHistory == 0) { // one more ref in timer stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", p->id.idStr, p->refCnt); - (void) taosTmrStop(p->schedInfo.pDelayTimer); + (void)taosTmrStop(p->schedInfo.pDelayTimer); p->info.delaySchedParam = 0; streamMetaReleaseTask(pMeta, p); } @@ -566,7 +567,7 @@ void streamMetaClose(SStreamMeta* pMeta) { if (pMeta == NULL) { return; } - (void) taosRemoveRef(streamMetaId, pMeta->rid); + (void)taosRemoveRef(streamMetaId, pMeta->rid); } void streamMetaCloseImpl(void* arg) { @@ -583,10 +584,10 @@ void streamMetaCloseImpl(void* arg) { streamMetaWUnLock(pMeta); // already log the error, ignore here - (void) tdbAbort(pMeta->db, pMeta->txn); - (void) tdbTbClose(pMeta->pTaskDb); - (void) tdbTbClose(pMeta->pCheckpointDb); - (void) tdbClose(pMeta->db); + (void)tdbAbort(pMeta->db, pMeta->txn); + (void)tdbTbClose(pMeta->pTaskDb); + (void)tdbTbClose(pMeta->pCheckpointDb); + (void)tdbClose(pMeta->db); taosArrayDestroy(pMeta->pTaskList); taosArrayDestroy(pMeta->chkpSaved); @@ -610,7 +611,7 @@ void streamMetaCloseImpl(void* arg) { bkdMgtDestroy(pMeta->bkdChkptMgt); pMeta->role = NODE_ROLE_UNINIT; - (void) taosThreadRwlockDestroy(&pMeta->lock); + (void)taosThreadRwlockDestroy(&pMeta->lock); taosMemoryFree(pMeta); stDebug("vgId:%d end to close stream meta", vgId); @@ -691,13 +692,13 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa p = taosArrayPush(pMeta->pTaskList, &pTask->id); if (p == NULL) { - stError("s-task:0x%"PRIx64" failed to register task into meta-list, code: out of memory", id.taskId); + stError("s-task:0x%" PRIx64 " failed to register task into meta-list, code: out of memory", id.taskId); return TSDB_CODE_OUT_OF_MEMORY; } code = taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES); if (code) { - stError("s-task:0x%"PRIx64" failed to register task into meta-list, code: out of memory", id.taskId); + stError("s-task:0x%" PRIx64 " failed to register task into meta-list, code: out of memory", id.taskId); return code; } @@ -710,7 +711,7 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa } if (pTask->info.fillHistory == 0) { - (void) atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); + (void)atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } *pAdded = true; @@ -779,7 +780,7 @@ static void doRemoveIdFromList(SArray* pTaskList, int32_t num, SStreamTaskId* id static int32_t streamTaskSendTransSuccessMsg(SStreamTask* pTask, void* param) { if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { - (void) streamTaskSendCheckpointSourceRsp(pTask); + (void)streamTaskSendCheckpointSourceRsp(pTask); } return 0; } @@ -802,7 +803,7 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t } // handle the dropping event - (void) streamTaskHandleEventAsync(pTask->status.pSM, TASK_EVENT_DROPPING, streamTaskSendTransSuccessMsg, NULL); + (void)streamTaskHandleEventAsync(pTask->status.pSM, TASK_EVENT_DROPPING, streamTaskSendTransSuccessMsg, NULL); } else { stDebug("vgId:%d failed to find the task:0x%x, it may be dropped already", pMeta->vgId, taskId); streamMetaWUnLock(pMeta); @@ -841,12 +842,12 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t pTask = *ppTask; // it is an fill-history task, remove the related stream task's id that points to it if (pTask->info.fillHistory == 0) { - (void) atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); + (void)atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); } - (void) taosHashRemove(pMeta->pTasksMap, &id, sizeof(id)); + (void)taosHashRemove(pMeta->pTasksMap, &id, sizeof(id)); doRemoveIdFromList(pMeta->pTaskList, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id); - (void) streamMetaRemoveTask(pMeta, &id); + (void)streamMetaRemoveTask(pMeta, &id); ASSERT(taosHashGetSize(pMeta->pTasksMap) == taosArrayGetSize(pMeta->pTaskList)); streamMetaWUnLock(pMeta); @@ -854,7 +855,7 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t ASSERT(pTask->status.timerActive == 0); if (pTask->info.delaySchedParam != 0 && pTask->info.fillHistory == 0) { stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", pTask->id.idStr, pTask->refCnt); - (void) taosTmrStop(pTask->schedInfo.pDelayTimer); + (void)taosTmrStop(pTask->schedInfo.pDelayTimer); pTask->info.delaySchedParam = 0; streamMetaReleaseTask(pMeta, pTask); } @@ -915,7 +916,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) { code = tdbTbcMoveToFirst(pCur); if (code) { - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); stError("failed to open stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId); return checkpointId; } @@ -953,7 +954,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { SDecoder decoder; int32_t vgId = 0; int32_t code = 0; - SArray* pRecycleList = NULL; + SArray* pRecycleList = NULL; if (pMeta == NULL) { return; @@ -975,7 +976,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (code) { stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno)); taosArrayDestroy(pRecycleList); - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return; } @@ -1008,7 +1009,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { tFreeStreamTask(pTask); STaskId id = streamTaskGetTaskId(pTask); - (void) taosArrayPush(pRecycleList, &id); + (void)taosArrayPush(pRecycleList, &id); int32_t total = taosArrayGetSize(pRecycleList); stDebug("s-task:0x%x is already dropped, add into recycle list, total:%d", taskId, total); @@ -1029,7 +1030,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { continue; } - (void) taosArrayPush(pMeta->pTaskList, &pTask->id); + (void)taosArrayPush(pMeta->pTaskList, &pTask->id); } else { // todo this should replace the existed object put by replay creating stream task msg from mnode stError("s-task:0x%x already added into table meta by replaying WAL, need check", pTask->id.taskId); @@ -1039,17 +1040,17 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES) != 0) { stError("s-task:0x%x failed to put into hashTable, code:%s, continue", pTask->id.taskId, tstrerror(terrno)); - (void) taosArrayPop(pMeta->pTaskList); + (void)taosArrayPop(pMeta->pTaskList); tFreeStreamTask(pTask); continue; } if (pTask->info.fillHistory == 0) { - (void) atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); + (void)atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } if (streamTaskShouldPause(pTask)) { - (void) atomic_add_fetch_32(&pMeta->numOfPausedTasks, 1); + (void)atomic_add_fetch_32(&pMeta->numOfPausedTasks, 1); } ASSERT(pTask->status.downstreamReady == 0); @@ -1065,7 +1066,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (taosArrayGetSize(pRecycleList) > 0) { for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) { STaskId* pId = taosArrayGet(pRecycleList, i); - (void) streamMetaRemoveTask(pMeta, pId); + (void)streamMetaRemoveTask(pMeta, pId); } } @@ -1093,7 +1094,7 @@ bool streamMetaTaskInTimer(SStreamMeta* pMeta) { SStreamTask* pTask = *(SStreamTask**)pIter; if (pTask->status.timerActive >= 1) { stDebug("s-task:%s in timer, blocking tasks in vgId:%d restart, set closing again", pTask->id.idStr, pMeta->vgId); - (void) streamTaskStop(pTask); + (void)streamTaskStop(pTask); inTimer = true; } } @@ -1126,7 +1127,7 @@ void streamMetaNotifyClose(SStreamMeta* pMeta) { SStreamTask* pTask = *(SStreamTask**)pIter; stDebug("vgId:%d s-task:%s set task closing flag", vgId, pTask->id.idStr); - (void) streamTaskStop(pTask); + (void)streamTaskStop(pTask); } streamMetaWUnLock(pMeta); @@ -1173,7 +1174,7 @@ void streamMetaResetStartInfo(STaskStartInfo* pStartInfo, int32_t vgId) { void streamMetaRLock(SStreamMeta* pMeta) { // stTrace("vgId:%d meta-rlock", pMeta->vgId); - (void) taosThreadRwlockRdlock(&pMeta->lock); + (void)taosThreadRwlockRdlock(&pMeta->lock); } void streamMetaRUnLock(SStreamMeta* pMeta) { @@ -1188,13 +1189,13 @@ void streamMetaRUnLock(SStreamMeta* pMeta) { void streamMetaWLock(SStreamMeta* pMeta) { // stTrace("vgId:%d meta-wlock", pMeta->vgId); - (void) taosThreadRwlockWrlock(&pMeta->lock); + (void)taosThreadRwlockWrlock(&pMeta->lock); // stTrace("vgId:%d meta-wlock completed", pMeta->vgId); } void streamMetaWUnLock(SStreamMeta* pMeta) { // stTrace("vgId:%d meta-wunlock", pMeta->vgId); - (void) taosThreadRwlockUnlock(&pMeta->lock); + (void)taosThreadRwlockUnlock(&pMeta->lock); } int32_t streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta, SArray** pList) { @@ -1320,7 +1321,7 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) { code = streamMetaAcquireTask(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); if (pTask == NULL) { stError("vgId:%d failed to acquire task:0x%x during start tasks", pMeta->vgId, pTaskId->taskId); - (void) streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); + (void)streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); continue; } @@ -1343,7 +1344,7 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) { code = streamMetaAcquireTask(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); if (pTask == NULL) { stError("vgId:%d failed to acquire task:0x%x during start tasks", pMeta->vgId, pTaskId->taskId); - (void) streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); + (void)streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); continue; } @@ -1361,10 +1362,11 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) { if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { stDebug("s-task:%s downstream ready, no need to check downstream, check only related fill-history task", pTask->id.idStr); - (void) streamLaunchFillHistoryTask(pTask); // todo: how about retry launch fill-history task? + (void)streamLaunchFillHistoryTask(pTask); // todo: how about retry launch fill-history task? } - (void) streamMetaAddTaskLaunchResult(pMeta, pTaskId->streamId, pTaskId->taskId, pInfo->checkTs, pInfo->readyTs, true); + (void)streamMetaAddTaskLaunchResult(pMeta, pTaskId->streamId, pTaskId->taskId, pInfo->checkTs, pInfo->readyTs, + true); streamMetaReleaseTask(pMeta, pTask); continue; } @@ -1420,14 +1422,14 @@ int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) { for (int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pTaskId = taosArrayGet(pTaskList, i); - SStreamTask* pTask = NULL; + SStreamTask* pTask = NULL; code = streamMetaAcquireTaskNoLock(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); if (code != TSDB_CODE_SUCCESS) { continue; } - (void) streamTaskStop(pTask); + (void)streamTaskStop(pTask); streamMetaReleaseTask(pMeta, pTask); } @@ -1467,7 +1469,7 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas code = streamMetaAcquireTask(pMeta, streamId, taskId, &pTask); if (pTask == NULL) { stError("vgId:%d failed to acquire task:0x%x when starting task", pMeta->vgId, taskId); - (void) streamMetaAddFailedTask(pMeta, streamId, taskId); + (void)streamMetaAddFailedTask(pMeta, streamId, taskId); return TSDB_CODE_STREAM_TASK_IVLD_STATUS; } @@ -1558,9 +1560,8 @@ int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int3 SHashObj* pDst = ready ? pStartInfo->pReadyTaskSet : pStartInfo->pFailedTaskSet; STaskInitTs initTs = {.start = startTs, .end = endTs, .success = ready}; - int32_t code = taosHashPut(pDst, &id, sizeof(id), &initTs, sizeof(STaskInitTs)); + int32_t code = taosHashPut(pDst, &id, sizeof(id), &initTs, sizeof(STaskInitTs)); if (code) { - } int32_t numOfTotal = streamMetaGetNumOfTasks(pMeta); @@ -1632,9 +1633,9 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta streamMetaRUnLock(pMeta); // add the failed task info, along with the related fill-history task info into tasks list. - (void) streamMetaAddTaskLaunchResult(pMeta, streamId, taskId, startTs, now, false); + (void)streamMetaAddTaskLaunchResult(pMeta, streamId, taskId, startTs, now, false); if (hasFillhistoryTask) { - (void) streamMetaAddTaskLaunchResult(pMeta, hId.streamId, hId.taskId, startTs, now, false); + (void)streamMetaAddTaskLaunchResult(pMeta, hId.streamId, hId.taskId, startTs, now, false); } } else { streamMetaRUnLock(pMeta); @@ -1649,12 +1650,12 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs) { int32_t startTs = pTask->execInfo.checkTs; - (void) streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, startTs, failedTs, false); + (void)streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, startTs, failedTs, false); // automatically set the related fill-history task to be failed. if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { STaskId* pId = &pTask->hTaskInfo.id; - (void) streamMetaAddTaskLaunchResult(pTask->pMeta, pId->streamId, pId->taskId, startTs, failedTs, false); + (void)streamMetaAddTaskLaunchResult(pTask->pMeta, pId->streamId, pId->taskId, startTs, failedTs, false); } } @@ -1662,7 +1663,7 @@ void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SSt int64_t startTs) { const char* id = pTask->id.idStr; int32_t vgId = pTask->pMeta->vgId; - int32_t code = 0; + int32_t code = 0; // keep the already updated info STaskUpdateEntry entry = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId, .transId = transId}; diff --git a/source/libs/stream/src/streamStartHistory.c b/source/libs/stream/src/streamStartHistory.c index db0784d572..0dbb6ed454 100644 --- a/source/libs/stream/src/streamStartHistory.c +++ b/source/libs/stream/src/streamStartHistory.c @@ -80,7 +80,7 @@ int32_t streamStartScanHistoryAsync(SStreamTask* pTask, int8_t igUntreated) { return tmsgPutToQueue(pTask->pMsgCb, STREAM_QUEUE, &rpcMsg); } -int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration) { +void streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration) { int32_t numOfTicks = idleDuration / SCANHISTORY_IDLE_TIME_SLICE; if (numOfTicks <= 0) { numOfTicks = 1; @@ -91,10 +91,10 @@ int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration) // add ref for task SStreamTask* p = NULL; int32_t code = streamMetaAcquireTask(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, &p); - if (p == NULL) { + if (p == NULL || code != 0) { stError("s-task:0x%x failed to acquire task, status:%s, not exec scan-history data", pTask->id.taskId, streamTaskGetStatus(pTask).name); - return TSDB_CODE_SUCCESS; + return; } pTask->schedHistoryInfo.numOfTicks = numOfTicks; @@ -109,8 +109,6 @@ int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration) streamTmrReset(doExecScanhistoryInFuture, SCANHISTORY_IDLE_TIME_SLICE, pTask, streamTimer, &pTask->schedHistoryInfo.pTimer, pTask->pMeta->vgId, " start-history-task-tmr"); } - - return TSDB_CODE_SUCCESS; } int32_t streamTaskStartScanHistory(SStreamTask* pTask) { diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 141bd8fc3e..99528d01b0 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -766,8 +766,7 @@ int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t resetRelHalt) { int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId, int64_t resetRelHalt) { SVDropStreamTaskReq* pReq = rpcMallocCont(sizeof(SVDropStreamTaskReq)); if (pReq == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return terrno; } pReq->head.vgId = vgId; @@ -1089,11 +1088,10 @@ int32_t streamTaskSetActiveCheckpointInfo(SStreamTask* pTask, int64_t activeChec return TSDB_CODE_SUCCESS; } -int32_t streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t checkpointId) { +void streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t checkpointId) { pTask->chkInfo.pActiveInfo->transId = transId; pTask->chkInfo.pActiveInfo->activeId = checkpointId; pTask->chkInfo.pActiveInfo->failedId = checkpointId; - return TSDB_CODE_SUCCESS; } int32_t streamTaskCreateActiveChkptInfo(SActiveCheckpointInfo** pRes) { diff --git a/source/libs/stream/src/streamTaskSm.c b/source/libs/stream/src/streamTaskSm.c index c3e0df52d4..275c9255d2 100644 --- a/source/libs/stream/src/streamTaskSm.c +++ b/source/libs/stream/src/streamTaskSm.c @@ -270,7 +270,7 @@ int32_t streamTaskRestoreStatus(SStreamTask* pTask) { code = TSDB_CODE_FAILED; // failed to restore the status, since it is not in pause status } - (void)taosThreadMutexUnlock(&pTask->lock); + streamMutexUnlock(&pTask->lock); return code; } diff --git a/source/libs/stream/test/backendTest.cpp b/source/libs/stream/test/backendTest.cpp index 1b2f961726..2b21510e45 100644 --- a/source/libs/stream/test/backendTest.cpp +++ b/source/libs/stream/test/backendTest.cpp @@ -69,7 +69,7 @@ void *backendOpen() { key.ts = ts; const char *val = "value data"; int32_t vlen = strlen(val); - int32_t code = streamStatePut_rocksdb(p, &key, (char *)val, vlen); + int32_t code = streamStatePut_rocksdb(p, &key, (char *)val, vlen); ASSERT(code == 0); tsArray.push_back(ts); @@ -83,7 +83,7 @@ void *backendOpen() { const char *val = "value data"; int32_t len = 0; char *newVal = NULL; - int32_t code = streamStateGet_rocksdb(p, &key, (void **)&newVal, &len); + int32_t code = streamStateGet_rocksdb(p, &key, (void **)&newVal, &len); ASSERT(code == 0); ASSERT(len == strlen(val)); @@ -377,7 +377,7 @@ TEST_F(BackendEnv, checkOpen) { char val[128] = {0}; sprintf(val, "val_%d", i); int32_t code = streamStatePutBatch(p, "default", (rocksdb_writebatch_t *)pBatch, (void *)key, (void *)val, - (int32_t)(strlen(val)), tsStart + 100000); + (int32_t)(strlen(val)), tsStart + 100000); ASSERT(code == 0); } @@ -396,7 +396,7 @@ TEST_F(BackendEnv, checkOpen) { char val[128] = {0}; sprintf(val, "val_%d", i); int32_t code = streamStatePutBatchOptimize(p, 0, (rocksdb_writebatch_t *)pBatch, (void *)key, (void *)val, - (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); + (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); ASSERT(code == 0); } int32_t code = streamStatePutBatch_rocksdb(p, pBatch); @@ -417,7 +417,7 @@ TEST_F(BackendEnv, checkOpen) { char val[128] = {0}; sprintf(val, "val_%d", i); int32_t code = streamStatePutBatchOptimize(p, 0, (rocksdb_writebatch_t *)pBatch, (void *)key, (void *)val, - (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); + (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); ASSERT(code == 0); } code = streamStatePutBatch_rocksdb(p, pBatch); @@ -432,13 +432,12 @@ TEST_F(BackendEnv, checkOpen) { const char *path = "/tmp/backend/stream"; const char *dump = "/tmp/backend/stream/dump"; // taosMkDir(dump); - code = taosMulMkDir(dump); - ASSERT(code == 0); + taosMulMkDir(dump); + SBkdMgt *mgt = NULL; - SBkdMgt *mgt = bkdMgtCreate((char *)path); - SArray *result = taosArrayInit(4, sizeof(void *)); - code = bkdMgtGetDelta(mgt, p->pTdbState->idstr, 3, result, (char *)dump); - ASSERT(code == 0); + code = bkdMgtCreate((char *)path, &mgt); + SArray *result = taosArrayInit(4, sizeof(void *)); + bkdMgtGetDelta(mgt, p->pTdbState->idstr, 3, result, (char *)dump); code = taskDbDoCheckpoint(p->pTdbState->pOwner->pBackend, 4, 0); ASSERT(code == 0); @@ -475,7 +474,7 @@ TEST_F(BackendEnv, backendUtil) { } TEST_F(BackendEnv, oldBackendInit) { const char *path = "/tmp/backend1"; - int32_t code = taosMulMkDir(path); + int32_t code = taosMulMkDir(path); ASSERT(code == 0); { diff --git a/source/libs/stream/test/tstreamUpdateTest.cpp b/source/libs/stream/test/tstreamUpdateTest.cpp index 59171876ff..4360fc7d54 100644 --- a/source/libs/stream/test/tstreamUpdateTest.cpp +++ b/source/libs/stream/test/tstreamUpdateTest.cpp @@ -53,7 +53,7 @@ TEST(TD_STREAM_UPDATE_TEST, update) { void *p = NULL; // SBackendWrapper *p = streamBackendInit(streamPath, -1, 2); // p = taskDbOpen((char *)streamPath, (char *)"test", -1); - p = bkdMgtCreate((char *)streamPath); + int32_t code = bkdMgtCreate((char *)streamPath, (SBkdMgt **)&p); // const int64_t interval = 20 * 1000; // const int64_t watermark = 10 * 60 * 1000; diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index b55267a0e7..3e2b98c35b 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -76,10 +76,8 @@ int64_t syncNodeUpdateCommitIndex(SSyncNode* ths, SyncIndex commitIndex) { SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore); commitIndex = TMAX(commitIndex, ths->commitIndex); ths->commitIndex = TMIN(commitIndex, lastVer); - if ((code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex)) != 0) { - // TODO add return when error - sError("failed to update commit index since %s", tstrerror(code)); - } + // TODO add return when error + (void)ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex); return ths->commitIndex; } @@ -87,10 +85,8 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) { int32_t code = 0; if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) { SyncIndex commitIndex = indexLikely; - if ((code = syncNodeUpdateCommitIndex(ths, commitIndex)) != 0) { - // TODO add return when error - sError("failed to update commit index since %s", tstrerror(code)); - } + // TODO add return when error + (void)syncNodeUpdateCommitIndex(ths, commitIndex); sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state, raftStoreGetTerm(ths), commitIndex); } @@ -102,9 +98,7 @@ int64_t syncNodeUpdateAssignedCommitIndex(SSyncNode* ths, SyncIndex assignedComm SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore); assignedCommitIndex = TMAX(assignedCommitIndex, ths->assignedCommitIndex); ths->assignedCommitIndex = TMIN(assignedCommitIndex, lastVer); - if ((code = ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex)) != 0) { - // TODO add return when error - sError("failed to update commit index since %s", tstrerror(code)); - } + // TODO add return when error + (void)ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex); return ths->commitIndex; } diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index cce8149037..8d1e2cfebd 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -69,13 +69,13 @@ void syncCleanUp() { if (gNodeRefId != -1) { sDebug("sync rsetId:%d is closed", gNodeRefId); - taosCloseRef(gNodeRefId); + (void)taosCloseRef(gNodeRefId); gNodeRefId = -1; } if (gHbDataRefId != -1) { sDebug("sync rsetId:%d is closed", gHbDataRefId); - taosCloseRef(gHbDataRefId); + (void)taosCloseRef(gHbDataRefId); gHbDataRefId = -1; } } @@ -88,7 +88,7 @@ int64_t syncNodeAdd(SSyncNode *pNode) { return pNode->rid; } -void syncNodeRemove(int64_t rid) { taosRemoveRef(gNodeRefId, rid); } +void syncNodeRemove(int64_t rid) { (void)taosRemoveRef(gNodeRefId, rid); } SSyncNode *syncNodeAcquire(int64_t rid) { SSyncNode *pNode = taosAcquireRef(gNodeRefId, rid); @@ -101,7 +101,7 @@ SSyncNode *syncNodeAcquire(int64_t rid) { } void syncNodeRelease(SSyncNode *pNode) { - if (pNode) taosReleaseRef(gNodeRefId, pNode->rid); + if (pNode) (void)taosReleaseRef(gNodeRefId, pNode->rid); } int64_t syncHbTimerDataAdd(SSyncHbTimerData *pData) { @@ -110,7 +110,7 @@ int64_t syncHbTimerDataAdd(SSyncHbTimerData *pData) { return pData->rid; } -void syncHbTimerDataRemove(int64_t rid) { taosRemoveRef(gHbDataRefId, rid); } +void syncHbTimerDataRemove(int64_t rid) { (void)taosRemoveRef(gHbDataRefId, rid); } SSyncHbTimerData *syncHbTimerDataAcquire(int64_t rid) { SSyncHbTimerData *pData = taosAcquireRef(gHbDataRefId, rid); @@ -122,7 +122,7 @@ SSyncHbTimerData *syncHbTimerDataAcquire(int64_t rid) { return pData; } -void syncHbTimerDataRelease(SSyncHbTimerData *pData) { taosReleaseRef(gHbDataRefId, pData->rid); } +void syncHbTimerDataRelease(SSyncHbTimerData *pData) { (void)taosReleaseRef(gHbDataRefId, pData->rid); } #if 0 void syncEnvStartTimer() { diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index f93b52dd2a..171b73eba7 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -181,17 +181,18 @@ int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg) { TAOS_RETURN(code); } - syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg); + TAOS_CHECK_RETURN(syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg)); syncNodeDoConfigChange(pSyncNode, pNewCfg, pNewCfg->lastIndex); if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { - syncNodeStopHeartbeatTimer(pSyncNode); + // TODO check return value + (void)syncNodeStopHeartbeatTimer(pSyncNode); for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { - syncHbTimerInit(pSyncNode, &pSyncNode->peerHeartbeatTimerArr[i], pSyncNode->replicasId[i]); + (void)syncHbTimerInit(pSyncNode, &pSyncNode->peerHeartbeatTimerArr[i], pSyncNode->replicasId[i]); } - syncNodeStartHeartbeatTimer(pSyncNode); + (void)syncNodeStartHeartbeatTimer(pSyncNode); // syncNodeReplicate(pSyncNode); } @@ -394,7 +395,8 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) { syncNodeRelease(pNode); if (ret == 1) { sInfo("send timeout response, seq:%" PRId64 " handle:%p ahandle:%p", seq, rpcMsg.info.handle, rpcMsg.info.ahandle); - rpcSendResponse(&rpcMsg); + // TODO check return value + (void)rpcSendResponse(&rpcMsg); return 0; } else { sError("no message handle to send timeout response, seq:%" PRId64, seq); @@ -674,9 +676,9 @@ int32_t syncGetArbToken(int64_t rid, char* outToken) { } memset(outToken, 0, TSDB_ARB_TOKEN_SIZE); - taosThreadMutexLock(&pSyncNode->arbTokenMutex); + (void)taosThreadMutexLock(&pSyncNode->arbTokenMutex); strncpy(outToken, pSyncNode->arbToken, TSDB_ARB_TOKEN_SIZE); - taosThreadMutexUnlock(&pSyncNode->arbTokenMutex); + (void)taosThreadMutexUnlock(&pSyncNode->arbTokenMutex); syncNodeRelease(pSyncNode); TAOS_RETURN(code); @@ -956,8 +958,8 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { sTrace("vgId:%d, start hb timer, rid:%" PRId64 " addr:%" PRId64, pSyncNode->vgId, pData->rid, pData->destId.addr); - taosTmrReset(pSyncTimer->timerCb, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)(pData->rid), - syncEnv()->pTimerManager, &pSyncTimer->pTimer); + (void)taosTmrReset(pSyncTimer->timerCb, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)(pData->rid), + syncEnv()->pTimerManager, &pSyncTimer->pTimer); } else { ret = TSDB_CODE_SYN_INTERNAL_ERROR; sError("vgId:%d, start ctrl hb timer error, sync env is stop", pSyncNode->vgId); @@ -967,7 +969,7 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { int32_t ret = 0; - atomic_add_fetch_64(&pSyncTimer->logicClock, 1); + (void)atomic_add_fetch_64(&pSyncTimer->logicClock, 1); if (!taosTmrStop(pSyncTimer->pTimer)) { return TSDB_CODE_SYN_INTERNAL_ERROR; } @@ -983,7 +985,8 @@ int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) { ASSERTS(pNode->pFsm != NULL, "pFsm not registered"); ASSERTS(pNode->pFsm->FpGetSnapshotInfo != NULL, "FpGetSnapshotInfo not registered"); SSnapshot snapshot = {0}; - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + // TODO check return value + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); SyncIndex commitIndex = snapshot.lastApplyIndex; SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore); @@ -1112,7 +1115,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { } pSyncNode->arbTerm = -1; - taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL); + (void)taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL); syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncInfo->vgId, pSyncNode->arbToken); sInfo("vgId:%d, arb token:%s", pSyncNode->vgId, pSyncNode->arbToken); @@ -1220,7 +1223,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { SyncIndex commitIndex = SYNC_INDEX_INVALID; if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { SSnapshot snapshot = {0}; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + // TODO check return value + (void)pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (snapshot.lastApplyIndex > commitIndex) { commitIndex = snapshot.lastApplyIndex; sNTrace(pSyncNode, "reset commit index by snapshot"); @@ -1373,7 +1377,7 @@ _error: void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) { if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { SSnapshot snapshot = {0}; - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + (void)pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (snapshot.lastApplyIndex > pSyncNode->commitIndex) { pSyncNode->commitIndex = snapshot.lastApplyIndex; } @@ -1386,11 +1390,11 @@ int32_t syncNodeRestore(SSyncNode* pSyncNode) { ASSERTS(pSyncNode->pLogStore != NULL, "log store not created"); ASSERTS(pSyncNode->pLogBuf != NULL, "ring log buffer not created"); - taosThreadMutexLock(&pSyncNode->pLogBuf->mutex); + (void)taosThreadMutexLock(&pSyncNode->pLogBuf->mutex); SyncIndex lastVer = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); SyncIndex commitIndex = pSyncNode->pLogStore->syncLogCommitIndex(pSyncNode->pLogStore); SyncIndex endIndex = pSyncNode->pLogBuf->endIndex; - taosThreadMutexUnlock(&pSyncNode->pLogBuf->mutex); + (void)taosThreadMutexUnlock(&pSyncNode->pLogBuf->mutex); if (lastVer != -1 && endIndex != lastVer + 1) { code = TSDB_CODE_WAL_LOG_INCOMPLETE; @@ -1439,7 +1443,8 @@ int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) { // state change pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->roleTimeMs = taosGetTimestampMs(); - syncNodeStopHeartbeatTimer(pSyncNode); + // TODO check return value + (void)syncNodeStopHeartbeatTimer(pSyncNode); // reset elect timer, long enough int32_t electMS = TIMER_MAX_MS; @@ -1464,13 +1469,13 @@ void syncNodePreClose(SSyncNode* pSyncNode) { ASSERT(pSyncNode->pFsm->FpApplyQueueItems != NULL); // stop elect timer - syncNodeStopElectTimer(pSyncNode); + (void)syncNodeStopElectTimer(pSyncNode); // stop heartbeat timer - syncNodeStopHeartbeatTimer(pSyncNode); + (void)syncNodeStopHeartbeatTimer(pSyncNode); // stop ping timer - syncNodeStopPingTimer(pSyncNode); + (void)syncNodeStopPingTimer(pSyncNode); // clean rsp syncRespCleanRsp(pSyncNode->pSyncRespMgr); @@ -1497,9 +1502,9 @@ void syncNodeClose(SSyncNode* pSyncNode) { syncRespCleanRsp(pSyncNode->pSyncRespMgr); - syncNodeStopPingTimer(pSyncNode); - syncNodeStopElectTimer(pSyncNode); - syncNodeStopHeartbeatTimer(pSyncNode); + (void)syncNodeStopPingTimer(pSyncNode); + (void)syncNodeStopElectTimer(pSyncNode); + (void)syncNodeStopHeartbeatTimer(pSyncNode); syncNodeLogReplDestroy(pSyncNode); syncRespMgrDestroy(pSyncNode->pSyncRespMgr); @@ -1517,7 +1522,7 @@ void syncNodeClose(SSyncNode* pSyncNode) { syncLogBufferDestroy(pSyncNode->pLogBuf); pSyncNode->pLogBuf = NULL; - taosThreadMutexDestroy(&pSyncNode->arbTokenMutex); + (void)taosThreadMutexDestroy(&pSyncNode->arbTokenMutex); for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { if (pSyncNode->senders[i] != NULL) { @@ -1557,8 +1562,8 @@ ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode) { return pSyncNode->raftCfg int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) { int32_t ret = 0; if (syncIsInit()) { - taosTmrReset(pSyncNode->FpPingTimerCB, pSyncNode->pingTimerMS, (void*)pSyncNode->rid, syncEnv()->pTimerManager, - &pSyncNode->pPingTimer); + (void)taosTmrReset(pSyncNode->FpPingTimerCB, pSyncNode->pingTimerMS, (void*)pSyncNode->rid, + syncEnv()->pTimerManager, &pSyncNode->pPingTimer); atomic_store_64(&pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser); } else { sError("vgId:%d, start ping timer error, sync env is stop", pSyncNode->vgId); @@ -1568,8 +1573,9 @@ int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) { int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode) { int32_t ret = 0; - atomic_add_fetch_64(&pSyncNode->pingTimerLogicClockUser, 1); - taosTmrStop(pSyncNode->pPingTimer); + (void)atomic_add_fetch_64(&pSyncNode->pingTimerLogicClockUser, 1); + // TODO check return value + (void)taosTmrStop(pSyncNode->pPingTimer); pSyncNode->pPingTimer = NULL; return ret; } @@ -1585,11 +1591,8 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) { pSyncNode->electTimerParam.pSyncNode = pSyncNode; pSyncNode->electTimerParam.pData = NULL; - if (!taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, (void*)(pSyncNode->rid), - syncEnv()->pTimerManager, &pSyncNode->pElectTimer)) { - ret = TSDB_CODE_SYN_INTERNAL_ERROR; - } - + (void)taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, (void*)(pSyncNode->rid), + syncEnv()->pTimerManager, &pSyncNode->pElectTimer); } else { sError("vgId:%d, start elect timer error, sync env is stop", pSyncNode->vgId); } @@ -1598,8 +1601,9 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) { int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode) { int32_t ret = 0; - atomic_add_fetch_64(&pSyncNode->electTimerLogicClock, 1); - taosTmrStop(pSyncNode->pElectTimer); + (void)atomic_add_fetch_64(&pSyncNode->electTimerLogicClock, 1); + // TODO check return value + (void)taosTmrStop(pSyncNode->pElectTimer); pSyncNode->pElectTimer = NULL; return ret; @@ -1622,9 +1626,8 @@ void syncNodeResetElectTimer(SSyncNode* pSyncNode) { electMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine); } - if ((code = syncNodeRestartElectTimer(pSyncNode, electMS)) != 0) { - sError("failed to restart elect timer since %s", tstrerror(code)); - } + // TODO check return value + (void)syncNodeRestartElectTimer(pSyncNode, electMS); sNTrace(pSyncNode, "reset elect timer, min:%d, max:%d, ms:%d", pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine, electMS); @@ -1634,8 +1637,8 @@ void syncNodeResetElectTimer(SSyncNode* pSyncNode) { static int32_t syncNodeDoStartHeartbeatTimer(SSyncNode* pSyncNode) { int32_t ret = 0; if (syncIsInit()) { - taosTmrReset(pSyncNode->FpHeartbeatTimerCB, pSyncNode->heartbeatTimerMS, (void*)pSyncNode->rid, - syncEnv()->pTimerManager, &pSyncNode->pHeartbeatTimer); + (void)taosTmrReset(pSyncNode->FpHeartbeatTimerCB, pSyncNode->heartbeatTimerMS, (void*)pSyncNode->rid, + syncEnv()->pTimerManager, &pSyncNode->pHeartbeatTimer); atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser); } else { sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId); @@ -1668,8 +1671,9 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { int32_t ret = 0; #if 0 - atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1); - taosTmrStop(pSyncNode->pHeartbeatTimer); + //TODO check return value + (void)atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1); + (void)taosTmrStop(pSyncNode->pHeartbeatTimer); pSyncNode->pHeartbeatTimer = NULL; #endif @@ -1685,8 +1689,9 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { #ifdef BUILD_NO_CALL int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) { - syncNodeStopHeartbeatTimer(pSyncNode); - syncNodeStartHeartbeatTimer(pSyncNode); + // TODO check return value + (void)syncNodeStopHeartbeatTimer(pSyncNode); + (void)syncNodeStartHeartbeatTimer(pSyncNode); return 0; } #endif @@ -1801,7 +1806,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // add last config index - syncAddCfgIndex(pSyncNode, lastConfigChangeIndex); + (void)syncAddCfgIndex(pSyncNode, lastConfigChangeIndex); if (IamInNew) { //----------------------------------------- @@ -1818,7 +1823,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde // init internal pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; - syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); + (void)syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); // init peersNum, peers, peersId pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1; @@ -1831,14 +1836,14 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } } for (int32_t i = 0; i < pSyncNode->peersNum; ++i) { - syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i]); + (void)syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i]); } // init replicaNum, replicasId pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; pSyncNode->totalReplicaNum = pSyncNode->raftCfg.cfg.totalReplicaNum; for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) { - syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); + (void)syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); } // update quorum first @@ -1884,7 +1889,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde // create new for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { if (pSyncNode->senders[i] == NULL) { - snapshotSenderCreate(pSyncNode, i, &pSyncNode->senders[i]); + (void)snapshotSenderCreate(pSyncNode, i, &pSyncNode->senders[i]); if (pSyncNode->senders[i] == NULL) { // will be created later while send snapshot sSError(pSyncNode->senders[i], "snapshot sender create failed while reconfig"); @@ -1906,10 +1911,10 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde } // persist cfg - syncWriteCfgFile(pSyncNode); + (void)syncWriteCfgFile(pSyncNode); } else { // persist cfg - syncWriteCfgFile(pSyncNode); + (void)syncWriteCfgFile(pSyncNode); sNInfo(pSyncNode, "do not config change from %d to %d", oldConfig.totalReplicaNum, pNewConfig->totalReplicaNum); } @@ -1937,10 +1942,10 @@ void syncNodeStepDown(SSyncNode* pSyncNode, SyncTerm newTerm) { } while (0); if (pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { - taosThreadMutexLock(&pSyncNode->arbTokenMutex); + (void)taosThreadMutexLock(&pSyncNode->arbTokenMutex); syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncNode->vgId, pSyncNode->arbToken); sInfo("vgId:%d, step down as assigned leader, new arbToken:%s", pSyncNode->vgId, pSyncNode->arbToken); - taosThreadMutexUnlock(&pSyncNode->arbTokenMutex); + (void)taosThreadMutexUnlock(&pSyncNode->arbTokenMutex); } if (currentTerm < newTerm) { @@ -1969,7 +1974,7 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // state change pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->roleTimeMs = taosGetTimestampMs(); - syncNodeStopHeartbeatTimer(pSyncNode); + (void)syncNodeStopHeartbeatTimer(pSyncNode); // trace log sNTrace(pSyncNode, "become follower %s", debugStr); @@ -1986,7 +1991,7 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); // reset elect timer syncNodeResetElectTimer(pSyncNode); @@ -2011,7 +2016,7 @@ void syncNodeBecomeLearner(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); } // TLA+ Spec @@ -2061,7 +2066,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { } // init peer mgr - syncNodePeerStateInit(pSyncNode); + (void)syncNodePeerStateInit(pSyncNode); #if 0 // update sender private term @@ -2082,13 +2087,13 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { } // stop elect timer - syncNodeStopElectTimer(pSyncNode); + (void)syncNodeStopElectTimer(pSyncNode); // start heartbeat timer - syncNodeStartHeartbeatTimer(pSyncNode); + (void)syncNodeStartHeartbeatTimer(pSyncNode); // send heartbeat right now - syncNodeHeartbeatPeers(pSyncNode); + (void)syncNodeHeartbeatPeers(pSyncNode); // call back if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpBecomeLeaderCb != NULL) { @@ -2099,7 +2104,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); // trace log sNInfo(pSyncNode, "become leader %s", debugStr); @@ -2134,7 +2139,7 @@ void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { } // init peer mgr - syncNodePeerStateInit(pSyncNode); + (void)syncNodePeerStateInit(pSyncNode); // close receiver if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { @@ -2142,13 +2147,13 @@ void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { } // stop elect timer - syncNodeStopElectTimer(pSyncNode); + (void)syncNodeStopElectTimer(pSyncNode); // start heartbeat timer - syncNodeStartHeartbeatTimer(pSyncNode); + (void)syncNodeStartHeartbeatTimer(pSyncNode); // send heartbeat right now - syncNodeHeartbeatPeers(pSyncNode); + (void)syncNodeHeartbeatPeers(pSyncNode); // call back if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpBecomeAssignedLeaderCb != NULL) { @@ -2159,7 +2164,7 @@ void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); // trace log sNInfo(pSyncNode, "become assigned leader"); @@ -2262,7 +2267,8 @@ bool syncNodeHasSnapshot(SSyncNode* pSyncNode) { bool ret = false; SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + // TODO check return value + (void)pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (snapshot.lastApplyIndex >= SYNC_INDEX_BEGIN) { ret = true; } @@ -2275,7 +2281,8 @@ bool syncNodeHasSnapshot(SSyncNode* pSyncNode) { SyncIndex syncNodeGetLastIndex(const SSyncNode* pSyncNode) { SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + // TODO check return value + (void)pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); } SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); @@ -2291,7 +2298,8 @@ SyncTerm syncNodeGetLastTerm(SSyncNode* pSyncNode) { // has snapshot SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0, .lastConfigIndex = -1}; if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + // TODO check return value + (void)pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); } SyncIndex logLastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); @@ -2386,7 +2394,8 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { return preTerm; } else { if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) { - pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); + // TODO check return value + (void)pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (snapshot.lastApplyIndex == preIndex) { return snapshot.lastApplyTerm; } @@ -2433,8 +2442,8 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) { } _out: - taosTmrReset(syncNodeEqPingTimer, pNode->pingTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, - &pNode->pPingTimer); + (void)taosTmrReset(syncNodeEqPingTimer, pNode->pingTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, + &pNode->pPingTimer); } } @@ -2510,8 +2519,8 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { } _out: - taosTmrReset(syncNodeEqHeartbeatTimer, pNode->heartbeatTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, - &pNode->pHeartbeatTimer); + (void)taosTmrReset(syncNodeEqHeartbeatTimer, pNode->heartbeatTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, + &pNode->pHeartbeatTimer); } else { sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRId64 ", heartbeatTimerLogicClockUser:%" PRId64, @@ -2585,14 +2594,14 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { // send msg sTrace("vgId:%d, send heartbeat to dnode:%d", pSyncNode->vgId, DID(&(pSyncMsg->destId))); syncLogSendHeartbeat(pSyncNode, pSyncMsg, false, timerElapsed, pData->execTime); - syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); + (void)syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); } else { } if (syncIsInit()) { // sTrace("vgId:%d, reset peer hb timer", pSyncNode->vgId); - taosTmrReset(syncNodeEqPeerHeartbeatTimer, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)hbDataRid, - syncEnv()->pTimerManager, &pSyncTimer->pTimer); + (void)taosTmrReset(syncNodeEqPeerHeartbeatTimer, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)hbDataRid, + syncEnv()->pTimerManager, &pSyncTimer->pTimer); } else { sError("sync env is stop, reset peer hb timer error"); } diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index 8b6092e839..ef2cbece79 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -134,7 +134,7 @@ int32_t syncLogReplGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncI } SSnapshot snapshot = {0}; - (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); // TODO: check the return code + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); if (prevIndex == snapshot.lastApplyIndex) { *pSyncTerm = snapshot.lastApplyTerm; return 0; @@ -184,7 +184,7 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) { int32_t code = 0, lino = 0; SSnapshot snapshot = {0}; - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + TAOS_CHECK_EXIT(pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot)); SyncIndex commitIndex = snapshot.lastApplyIndex; SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index cb07a63eed..cc2aa7d91e 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -134,7 +134,7 @@ int32_t raftStoreWriteFile(SSyncNode *pNode) { if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); if (taosRenameFile(file, realfile) != 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER); code = 0; diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 40a359379a..8644ba6bb9 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -84,7 +84,7 @@ int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) { int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { SyncAppendEntries* pMsg = pRpcMsg->pCont; pMsg->destId = *destRaftId; - syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); + (void)syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -113,7 +113,7 @@ int32_t syncNodeHeartbeatPeers(SSyncNode* pSyncNode) { // send msg syncLogSendHeartbeat(pSyncNode, pSyncMsg, true, 0, 0); - syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); + (void)syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); } TAOS_RETURN(TSDB_CODE_SUCCESS); diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 0e50cca94c..a30b9a4930 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -135,7 +135,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // trace log syncLogRecvRequestVote(ths, pMsg, pReply->voteGranted, ""); syncLogSendRequestVoteReply(ths, pReply, ""); - syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + (void)syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); if (resetElect) syncNodeResetElectTimer(ths); diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 450d22528d..8a2c53997b 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -86,14 +86,17 @@ int32_t snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex, SSyncSn pSender->replicaIndex = replicaIndex; pSender->term = raftStoreGetTerm(pSyncNode); pSender->startTime = -1; - pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; + code = pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); + if (code != 0) { + taosMemoryFreeClear(pSender); + TAOS_RETURN(code); + } SSyncSnapBuffer *pSndBuf = NULL; code = syncSnapBufferCreate(&pSndBuf); if (pSndBuf == NULL) { - taosMemoryFree(pSender); - pSender = NULL; + taosMemoryFreeClear(pSender); TAOS_RETURN(code); } pSndBuf->entryDeleteCb = syncSnapBlockDestroy; @@ -472,7 +475,7 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { syncSnapBufferDestroy(&pReceiver->pRcvBuf); } - snapshotReceiverClearInfoData(pReceiver); + (void)snapshotReceiverClearInfoData(pReceiver); // free receiver taosMemoryFree(pReceiver); @@ -592,7 +595,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true, &pReceiver->snapshot); if (code != 0) { - sRError(pReceiver, "snapshot receiver apply failed since %s", tstrerror(code)); + sRError(pReceiver, "snapshot receiver apply failed since %s", tstrerror(code)); TAOS_RETURN(code); } pReceiver->pWriter = NULL; @@ -603,7 +606,11 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap // get fsmState SSnapshot snapshot = {0}; - pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + code = pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + if (code != 0) { + sRError(pReceiver, "snapshot receiver get snapshot info failed since %s", tstrerror(code)); + TAOS_RETURN(code); + } pReceiver->pSyncNode->fsmState = snapshot.state; // reset wal @@ -1276,13 +1283,13 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { sSInfo(pSender, "process end rsp"); snapshotSenderStop(pSender, true); - syncNodeReplicateReset(pSyncNode, &pMsg->srcId); + (void)syncNodeReplicateReset(pSyncNode, &pMsg->srcId); } return 0; _ERROR: snapshotSenderStop(pSender, false); - syncNodeReplicateReset(pSyncNode, &pMsg->srcId); + (void)syncNodeReplicateReset(pSyncNode, &pMsg->srcId); TAOS_RETURN(code); } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 2076de6ec7..49737b9045 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -183,7 +183,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); } SyncIndex logLastIndex = SYNC_INDEX_INVALID; @@ -253,7 +253,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); } SyncIndex logLastIndex = SYNC_INDEX_INVALID; @@ -302,7 +302,7 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); } SyncIndex logLastIndex = SYNC_INDEX_INVALID; diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index d3a5711352..0935e87ab0 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -48,7 +48,7 @@ int32_t tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyC int8_t rollback); int32_t tdbTbClose(TTB *pTb); bool tdbTbExist(const char *tbname, TDB *pEnv); -int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN* pTxn); +int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN *pTxn); int32_t tdbTbDrop(TTB *pTb); int32_t tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int valLen, TXN *pTxn); int32_t tdbTbDelete(TTB *pTb, const void *pKey, int kLen, TXN *pTxn); @@ -80,10 +80,10 @@ int32_t tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, i int32_t tdbTxnOpen(TXN *pTxn, int64_t txnid, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg, int flags); int32_t tdbTxnCloseImpl(TXN *pTxn); -#define tdbTxnClose(pTxn) \ - do { \ - tdbTxnCloseImpl(pTxn); \ - (pTxn) = NULL; \ +#define tdbTxnClose(pTxn) \ + do { \ + (void)tdbTxnCloseImpl(pTxn); \ + (pTxn) = NULL; \ } while (0) // other diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index f86ed69fc3..c07f442c4a 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -122,7 +122,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg zArg.pBt = pBt; ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, txn); if (ret < 0) { - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -130,7 +130,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg ret = tdbPagerWrite(pPager, pPage); if (ret < 0) { tdbError("failed to write page since %s", terrstr()); - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -143,7 +143,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pBt->info, sizeof(pBt->info), txn); if (ret < 0) { - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -194,14 +194,14 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in int idx; int c; - tdbBtcOpen(&btc, pBt, pTxn); + (void)tdbBtcOpen(&btc, pBt, pTxn); tdbTrace("tdb insert, btc: %p, pTxn: %p", &btc, pTxn); // move to the position to insert ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret); return ret; } @@ -213,7 +213,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in btc.idx++; } else if (c == 0) { // dup key not allowed with insert - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn); return TSDB_CODE_DUP_KEY; } @@ -221,12 +221,12 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret); return ret; } - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -235,7 +235,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { int c; int ret; - tdbBtcOpen(&btc, pBt, pTxn); + (void)tdbBtcOpen(&btc, pBt, pTxn); /* btc.coder.ofps = taosArrayInit(8, sizeof(SPage *)); // btc.coder.ofps = taosArrayInit(8, sizeof(SPgno)); @@ -246,20 +246,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { // move the cursor ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret); return ret; } if (btc.idx < 0 || c != 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return TSDB_CODE_NOT_FOUND; } // delete the key ret = tdbBtcDelete(&btc); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return ret; } /* @@ -274,7 +274,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { btc.coder.ofps = NULL; } */ - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -337,26 +337,26 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL void *pTVal = NULL; SCellDecoder cd = {0}; - tdbBtcOpen(&btc, pBt, NULL); + (void)tdbBtcOpen(&btc, pBt, NULL); tdbTrace("tdb pget, btc: %p", &btc); ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret); return ret; } if (btc.idx < 0 || cret) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return TSDB_CODE_NOT_FOUND; } pCell = tdbPageGetCell(btc.pPage, btc.idx); ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret); return ret; } @@ -364,7 +364,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL if (ppKey) { pTKey = tdbRealloc(*ppKey, cd.kLen); if (pTKey == NULL) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: realloc pTKey failed."); return terrno; } @@ -376,7 +376,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL if (ppVal) { pTVal = tdbRealloc(*ppVal, cd.vLen); if (pTVal == NULL) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: realloc pTVal failed."); return terrno; } @@ -397,7 +397,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL tdbTrace("tdb pget end, btc decoder: %p/0x%x, local decoder:%p", &btc.coder, btc.coder.freeKV, &cd); - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -512,7 +512,7 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild, TXN } // Copy the root page content to the child page - tdbPageCopy(pRoot, pChild, 0); + (void)tdbPageCopy(pRoot, pChild, 0); // Reinitialize the root page zArg.flags = TDB_BTREE_ROOT; @@ -602,7 +602,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx if (i < nOlds - 1) { ((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno; ((SIntHdr *)pOlds[i]->pData)->pgno = 0; - tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); + (void)tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); } } rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno; @@ -626,14 +626,14 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx } } - tdbPageDropCell(pParent, sIdx, pTxn, pBt); + (void)tdbPageDropCell(pParent, sIdx, pTxn, pBt); if (!childNotLeaf) { SArray *ofps = pParent->pPager->ofps; if (ofps) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { SPage *ofp = *(SPage **)taosArrayGet(ofps, i); - tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); + (void)tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); } if (destroyOfps) { @@ -791,15 +791,15 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx iarg.pBt = pBt; iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]); for (int i = 0; i < nOlds; i++) { - tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); - tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); - tdbPageCopy(pOlds[i], pOldsCopy[i], 0); + (void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); + (void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); + (void)tdbPageCopy(pOlds[i], pOldsCopy[i], 0); pOlds[i]->nOverflow = 0; } iNew = 0; nNewCells = 0; - tdbBtreeInitPage(pNews[iNew], &iarg, 0); + (void)tdbBtreeInitPage(pNews[iNew], &iarg, 0); for (int iOld = 0; iOld < nOlds; iOld++) { SPage *pPage; @@ -818,7 +818,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx } if (nNewCells < infoNews[iNew].cnt) { - tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); + (void)tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); nNewCells++; // insert parent page @@ -828,16 +828,16 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx if (iNew == nNews - 1 && pIntHdr->pgno == 0) { pIntHdr->pgno = TDB_PAGE_PGNO(pNews[iNew]); } else { - tdbBtreeDecodeCell(pPage, pCell, &cd, pTxn, pBt); + (void)tdbBtreeDecodeCell(pPage, pCell, &cd, pTxn, pBt); // TODO: pCell here may be inserted as an overflow cell, handle it SCell *pNewCell = tdbOsMalloc(cd.kLen + 9); int szNewCell; SPgno pgno; pgno = TDB_PAGE_PGNO(pNews[iNew]); - tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, pTxn, - pBt); - tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); + (void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, + pTxn, pBt); + (void)tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); tdbOsFree(pNewCell); if (TDB_CELLDECODER_FREE_VAL(&cd)) { @@ -850,7 +850,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx iNew++; nNewCells = 0; if (iNew < nNews) { - tdbBtreeInitPage(pNews[iNew], &iarg, 0); + (void)tdbBtreeInitPage(pNews[iNew], &iarg, 0); } } } else { @@ -869,13 +869,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx return TSDB_CODE_FAILED; } ((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]); - tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0); + (void)tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0); // move to next new page iNew++; nNewCells = 0; if (iNew < nNews) { - tdbBtreeInitPage(pNews[iNew], &iarg, 0); + (void)tdbBtreeInitPage(pNews[iNew], &iarg, 0); } } } @@ -892,26 +892,26 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]); } else { ((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]); - tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0); + (void)tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0); } } for (int i = 0; i < nOlds; i++) { - tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL); + (void)tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL); } } if (TDB_BTREE_PAGE_IS_ROOT(pParent) && TDB_PAGE_TOTAL_CELLS(pParent) == 0) { i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]); // copy content to the parent page - tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0); - tdbPageCopy(pNews[0], pParent, 1); + (void)tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0); + (void)tdbPageCopy(pNews[0], pParent, 1); if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) { ((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno; } - tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn); + (void)tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn); } for (int i = 0; i < 3; i++) { @@ -922,7 +922,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx for (pageIdx = 0; pageIdx < nOlds; ++pageIdx) { if (pageIdx >= nNews) { - tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); + (void)tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); } tdbPagerReturnPage(pBt->pPager, pOlds[pageIdx], pTxn); } @@ -1986,7 +1986,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) { return 0; } - tdbBtcMoveUpward(pBtc); + (void)tdbBtcMoveUpward(pBtc); pBtc->idx++; if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { @@ -2029,7 +2029,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) { return 0; } - tdbBtcMoveUpward(pBtc); + (void)tdbBtcMoveUpward(pBtc); pBtc->idx--; if (pBtc->idx >= 0) { break; @@ -2040,7 +2040,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) { for (;;) { if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break; - tdbBtcMoveDownward(pBtc); + (void)tdbBtcMoveDownward(pBtc); if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1; } else { @@ -2119,7 +2119,7 @@ int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int } pCell = tdbPageGetCell(pBtc->pPage, pBtc->idx); - tdbBtreeDecodeCell(pBtc->pPage, pCell, &pBtc->coder, pBtc->pTxn, pBtc->pBt); + (void)tdbBtreeDecodeCell(pBtc->pPage, pCell, &pBtc->coder, pBtc->pTxn, pBtc->pBt); if (ppKey) { *ppKey = (void *)pBtc->coder.pKey; @@ -2165,13 +2165,13 @@ int tdbBtcDelete(SBTC *pBtc) { destroyOfps = true; } - tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt); + (void)tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt); SArray *ofps = pBtc->pPage->pPager->ofps; if (ofps) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { SPage *ofp = *(SPage **)taosArrayGet(ofps, i); - tdbPagerInsertFreePage(pBtc->pPage->pPager, ofp, pBtc->pTxn); + (void)tdbPagerInsertFreePage(pBtc->pPage->pPager, ofp, pBtc->pTxn); } if (destroyOfps) { @@ -2184,7 +2184,7 @@ int tdbBtcDelete(SBTC *pBtc) { if (idx == nCells - 1) { if (idx) { pBtc->idx--; - tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); + (void)tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); // loop to update the interial page pgno = TDB_PAGE_PGNO(pBtc->pPage); @@ -2202,7 +2202,7 @@ int tdbBtcDelete(SBTC *pBtc) { // update the cell with new key pCell = tdbOsMalloc(nKey + 9); - tdbBtreeEncodeCell(pPage, pKey, nKey, &pgno, sizeof(pgno), pCell, &szCell, pBtc->pTxn, pBtc->pBt); + (void)tdbBtreeEncodeCell(pPage, pKey, nKey, &pgno, sizeof(pgno), pCell, &szCell, pBtc->pTxn, pBtc->pBt); ret = tdbPageUpdateCell(pPage, idx, pCell, szCell, pBtc->pTxn, pBtc->pBt); if (ret < 0) { @@ -2429,7 +2429,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { // compare first cell pBtc->idx = lidx; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c <= 0) { ridx = lidx - 1; @@ -2439,7 +2439,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { // compare last cell if (lidx <= ridx) { pBtc->idx = ridx; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c >= 0) { lidx = ridx + 1; @@ -2454,7 +2454,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { if (lidx > ridx) break; pBtc->idx = (lidx + ridx) >> 1; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c < 0) { // pKey < cd.pKey @@ -2476,7 +2476,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { if (c > 0) { pBtc->idx += 1; } - tdbBtcMoveDownward(pBtc); + (void)tdbBtcMoveDownward(pBtc); } } diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index 47a7b6fe7a..825a6e2b94 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -101,10 +101,10 @@ int tdbClose(TDB *pDb) { for (pPager = pDb->pgrList; pPager; pPager = pDb->pgrList) { pDb->pgrList = pPager->pNext; - tdbPagerClose(pPager); + (void)tdbPagerClose(pPager); } - tdbPCacheClose(pDb->pCache); + (void)tdbPCacheClose(pDb->pCache); tdbOsFree(pDb->pgrHash); tdbOsFree(pDb); } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 6cb5f89758..c1a2943bee 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -44,10 +44,10 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage); static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage); static int tdbPCacheCloseImpl(SPCache *pCache); -static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); } -static void tdbPCacheDestroyLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); } -static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); } -static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexUnlock(&(pCache->mutex)); } +static void tdbPCacheInitLock(SPCache *pCache) { (void)tdbMutexInit(&(pCache->mutex), NULL); } +static void tdbPCacheDestroyLock(SPCache *pCache) { (void)tdbMutexDestroy(&(pCache->mutex)); } +static void tdbPCacheLock(SPCache *pCache) { (void)tdbMutexLock(&(pCache->mutex)); } +static void tdbPCacheUnlock(SPCache *pCache) { (void)tdbMutexUnlock(&(pCache->mutex)); } int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { int32_t code = 0; @@ -74,7 +74,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { _exit: if (code) { tdbError("%s failed at %s:%d since %s", __func__, __FILE__, __LINE__, tstrerror(code)); - tdbPCacheClose(pCache); + (void)tdbPCacheClose(pCache); *ppCache = NULL; } else { *ppCache = pCache; @@ -84,7 +84,7 @@ _exit: int tdbPCacheClose(SPCache *pCache) { if (pCache) { - tdbPCacheCloseImpl(pCache); + (void)tdbPCacheCloseImpl(pCache); tdbOsFree(pCache->aPage); tdbOsFree(pCache); } @@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) { SPage *pPage = *ppPage; *ppPage = pPage->pFreeNext; pCache->aPage[pPage->id] = NULL; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pCache->nFree--; } else { ppPage = &(*ppPage)->pFreeNext; @@ -209,7 +209,7 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) { tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage)); tdbPCacheRemovePageFromHash(pCache, pPage); - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); } } @@ -268,7 +268,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) { tdbPCacheRemovePageFromHash(pCache, pPage); } - tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg); + (void)tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg); } // } } @@ -349,7 +349,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn) for (int nLoops = 0;;) { if (pPageH->pPager) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -432,7 +432,7 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) { tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id); tdbPCacheRemovePageFromHash(pCache, pPage); - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); } } @@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) { // free free page for (SPage *pPage = pCache->pFree; pPage;) { SPage *pPageT = pPage->pFreeNext; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pPage = pPageT; } for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) { for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) { SPage *pPageT = pPage->pHashNext; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pPage = pPageT; } } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 322b735163..26c1c108d2 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -64,7 +64,7 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t) memset(ptr, 0, size); pPage = (SPage *)(ptr + pageSize); - TDB_INIT_PAGE_LOCK(pPage); + (void)TDB_INIT_PAGE_LOCK(pPage); pPage->pageSize = pageSize; pPage->pData = ptr; if (pageSize < 65536) { @@ -194,7 +194,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl iOvfl++; } else { // page must has enough space to hold the cell locally - tdbPageAllocate(pPage, szCell, &pNewCell); + (void)tdbPageAllocate(pPage, szCell, &pNewCell); memcpy(pNewCell, pCell, szCell); @@ -220,7 +220,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl } int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt) { - tdbPageDropCell(pPage, idx, pTxn, pBt); + (void)tdbPageDropCell(pPage, idx, pTxn, pBt); return tdbPageInsertCell(pPage, idx, pCell, szCell, 0); } @@ -259,7 +259,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) { lidx = idx - iOvfl; pCell = TDB_PAGE_CELL_AT(pPage, lidx); szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt); - tdbPageFree(pPage, lidx, pCell, szCell); + (void)tdbPageFree(pPage, lidx, pCell, szCell); TDB_PAGE_NCELLS_SET(pPage, nCells - 1); for (; iOvfl < pPage->nOverflow; iOvfl++) { diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 414ca42a02..01dd0ac766 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -107,7 +107,7 @@ static int hashset_add(hashset_t set, void *item) { set->nitems = 0; for (size_t i = 0; i < old_capacity; ++i) { - hashset_add_member(set, (void *)old_items[i]); + (void)hashset_add_member(set, (void *)old_items[i]); } tdbOsFree(old_items); } @@ -223,7 +223,7 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) { int tdbPagerClose(SPager *pPager) { if (pPager) { - tdbOsClose(pPager->fd); + (void)tdbOsClose(pPager->fd); tdbOsFree(pPager); } return 0; @@ -236,14 +236,14 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { if (pPage->isDirty) return 0; // ref page one more time so the page will not be release - tdbRefPage(pPage); + (void)tdbRefPage(pPage); tdbTrace("pager/mdirty page %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id); // Set page as dirty pPage->isDirty = 1; tdbTrace("tdb/pager-write: put page: %p %d to dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); - tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); + (void)tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); // Write page to journal if neccessary if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize && @@ -256,7 +256,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { } if (pPager->pActiveTxn->jPageSet) { - hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } } @@ -352,7 +352,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); if (pTxn->jPageSet) { - hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } tdbTrace("tdb/pager-commit: remove page: %p %d from dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); @@ -590,7 +590,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { pPage->isDirty = 0; tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); - hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); tdbPCacheMarkFree(pPager->pCache, pPage); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } @@ -712,7 +712,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPa memcpy(&pgid, pPager->fid, TDB_FILE_ID_LEN); pgid.pgno = pgno; while ((pPage = tdbPCacheFetch(pPager->pCache, &pgid, pTxn)) == NULL) { - tdbPagerFlushPage(pPager, pTxn); + (void)tdbPagerFlushPage(pPager, pTxn); } tdbTrace("tdbttl fetch pager:%p", pPage->pPager); @@ -815,7 +815,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcMoveToFirst(pCur); if (code) { tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -825,7 +825,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL); if (code < 0) { // tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -836,10 +836,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcDelete(pCur); if (code < 0) { tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -892,7 +892,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage lcode = TDB_TRY_LOCK_PAGE(pPage); if (lcode == P_LOCK_SUCC) { if (TDB_PAGE_INITIALIZED(pPage)) { - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return 0; } @@ -906,7 +906,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage tdbTrace("tdb/pager:%p, pgno:%d, nRead:%" PRId64, pPager, pgno, nRead); if (nRead < pPage->pageSize) { tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32, pPager, pgno, nRead, pPage->pageSize); - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return TAOS_SYSTEM_ERROR(errno); } @@ -953,7 +953,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage if (ret < 0) { tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32 " init page failed.", pPager, pgno, nRead, pPage->pageSize); - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return ret; } @@ -961,14 +961,14 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage pPage->pPager = pPager; - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); } else if (lcode == P_LOCK_BUSY) { nLoops = 0; for (;;) { if (TDB_PAGE_INITIALIZED(pPage)) break; nLoops++; if (nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -1162,7 +1162,7 @@ int tdbPagerRestoreJournals(SPager *pPager) { char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { int64_t txnId = -1; - sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); + (void)sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); if (taosArrayPush(pTxnList, &txnId) == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1179,14 +1179,14 @@ int tdbPagerRestoreJournals(SPager *pPager) { code = tdbPagerRestore(pPager, jname); if (code) { taosArrayDestroy(pTxnList); - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); tdbError("failed to restore file due to %s. jFileName:%s", strerror(code), jname); return code; } } taosArrayDestroy(pTxnList); - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); return 0; } @@ -1209,7 +1209,7 @@ int tdbPagerRollback(SPager *pPager) { jname[dirLen] = '/'; memcpy(jname + dirLen + 1, name, strlen(name)); if (tdbOsRemove(jname) < 0 && errno != ENOENT) { - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name); return terrno = TAOS_SYSTEM_ERROR(errno); @@ -1217,7 +1217,7 @@ int tdbPagerRollback(SPager *pPager) { } } - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); return 0; } diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 365be222ef..d885c38864 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -112,7 +112,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF return ret; } } else { - tdbPagerRollback(pPager); + (void)tdbPagerRollback(pPager); } // pTb->pBt @@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF int tdbTbClose(TTB *pTb) { if (pTb) { - tdbBtreeClose(pTb->pBt); + (void)tdbBtreeClose(pTb->pBt); tdbOsFree(pTb); } return 0; @@ -202,7 +202,7 @@ int tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int va int tdbTbDelete(TTB *pTb, const void *pKey, int kLen, TXN *pTxn) { return tdbBtreeDelete(pTb->pBt, pKey, kLen, pTxn); } int tdbTbUpsert(TTB *pTb, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) { - tdbTbDelete(pTb, pKey, kLen, pTxn); + (void)tdbTbDelete(pTb, pKey, kLen, pTxn); return tdbTbInsert(pTb, pKey, kLen, pVal, vLen, pTxn); } @@ -224,7 +224,7 @@ int tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn) { return -1; } - tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); + (void)tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); *ppTbc = pTbc; return 0; @@ -238,7 +238,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data, return ret; } - tdbTbcMoveToFirst(pCur); + (void)tdbTbcMoveToFirst(pCur); void *pKey = NULL; int kLen = 0; @@ -257,7 +257,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data, } tdbFree(pKey); tdbFree(pValue); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -292,7 +292,7 @@ int tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, int n int tdbTbcClose(TBC *pTbc) { if (pTbc) { - tdbBtcClose(&pTbc->btc); + (void)tdbBtcClose(&pTbc->btc); tdbOsFree(pTbc); } diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index fe97f9c986..4382513f73 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -13,6 +13,8 @@ * along with this program. If not, see . */ +#include "tdbInt.h" + #ifndef _TDB_UTIL_H_ #define _TDB_UTIL_H_ @@ -56,8 +58,6 @@ static inline int tdbPutVarInt(u8 *p, int v) { v >>= 7; } - ASSERT(n < 6); - return n; } @@ -79,8 +79,6 @@ static inline int tdbGetVarInt(const u8 *p, int *v) { n++; } - ASSERT(n < 6); - *v = tv; return n; } diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index ede7636011..f81bbbdeb7 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -483,7 +483,7 @@ const STfsFile *tfsReaddir(STfsDir *pTfsDir) { void tfsClosedir(STfsDir *pTfsDir) { if (pTfsDir) { if (pTfsDir->pDir != NULL) { - taosCloseDir(&pTfsDir->pDir); + (void)taosCloseDir(&pTfsDir->pDir); pTfsDir->pDir = NULL; } taosMemoryFree(pTfsDir); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index acb9bd20f3..e66941244c 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -103,11 +103,11 @@ typedef void* queue[2]; #define TRANS_MAGIC_NUM 0x5f375a86 #define TRANS_NOVALID_PACKET(src) ((src) != TRANS_MAGIC_NUM ? 1 : 0) -typedef struct SRpcMsg STransMsg; -typedef SRpcCtx STransCtx; -typedef SRpcCtxVal STransCtxVal; -typedef SRpcInfo STrans; -typedef SRpcConnInfo STransHandleInfo; +typedef struct SRpcMsg STransMsg; +typedef SRpcCtx STransCtx; +typedef SRpcCtxVal STransCtxVal; +typedef SRpcInfo STrans; +typedef SRpcConnInfo STransHandleInfo; // ref mgt handle typedef struct SExHandle { @@ -250,10 +250,10 @@ typedef struct { int8_t stop; } SAsyncPool; -SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb); -void transAsyncPoolDestroy(SAsyncPool* pool); -int transAsyncSend(SAsyncPool* pool, queue* mq); -bool transAsyncPoolIsEmpty(SAsyncPool* pool); +int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAsyncPool** pPool); +void transAsyncPoolDestroy(SAsyncPool* pool); +int transAsyncSend(SAsyncPool* pool, queue* mq); +bool transAsyncPoolIsEmpty(SAsyncPool* pool); #define TRANS_DESTROY_ASYNC_POOL_MSG(pool, msgType, freeFunc, param) \ do { \ @@ -279,6 +279,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); if (exh2 == NULL || id != exh2->refId) { \ tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, \ exh2 ? exh2->refId : 0, id); \ + code = terrno; \ goto _return1; \ } \ } else if (id == 0) { \ @@ -287,6 +288,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); if (exh2 == NULL || id == exh2->refId) { \ tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, id, \ exh2 ? exh2->refId : 0); \ + code = terrno; \ goto _return1; \ } else { \ id = exh1->refId; \ @@ -297,13 +299,13 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); } \ } while (0) -int transInitBuffer(SConnBuffer* buf); -int transClearBuffer(SConnBuffer* buf); -int transDestroyBuffer(SConnBuffer* buf); -int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf); -bool transReadComplete(SConnBuffer* connBuf); -int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf); -int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf); +int32_t transInitBuffer(SConnBuffer* buf); +int32_t transClearBuffer(SConnBuffer* buf); +int32_t transDestroyBuffer(SConnBuffer* buf); +int32_t transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf); +bool transReadComplete(SConnBuffer* connBuf); +int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf); +int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf); int transSetConnOption(uv_tcp_t* stream, int keepalive); @@ -316,14 +318,14 @@ void transUnrefCliHandle(void* handle); int transReleaseCliHandle(void* handle); int transReleaseSrvHandle(void* handle); -int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransCtx* pCtx); -int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp); -int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp, int8_t* epUpdated, - int32_t timeoutMs); -int transSendResponse(const STransMsg* msg); -int transRegisterMsg(const STransMsg* msg); -int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn); -void transSetIpWhiteList(void* shandle, void* arg, FilteFunc* func); +int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransCtx* pCtx); +int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp); +int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp, int8_t* epUpdated, + int32_t timeoutMs); +int transSendResponse(const STransMsg* msg); +int transRegisterMsg(const STransMsg* msg); +int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn); +int32_t transSetIpWhiteList(void* shandle, void* arg, FilteFunc* func); int transSockInfo2Str(struct sockaddr* sockname, char* dst); @@ -363,7 +365,7 @@ typedef struct { * init queue * note: queue'size is small, default 1 */ -void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)); +int32_t transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)); /* * put arg into queue @@ -420,7 +422,7 @@ typedef struct SDelayQueue { uv_loop_t* loop; } SDelayQueue; -int transDQCreate(uv_loop_t* loop, SDelayQueue** queue); +int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue); void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)); SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs); void transDQCancel(SDelayQueue* queue, SDelayTask* task); @@ -433,9 +435,9 @@ bool transEpSetIsEqual2(SEpSet* a, SEpSet* b); */ void transThreadOnce(); -void transInit(); -void transCleanup(); -void transPrintEpSet(SEpSet* pEpSet); +int32_t transInit(); +void transCleanup(); +void transPrintEpSet(SEpSet* pEpSet); void transFreeMsg(void* msg); int32_t transCompressMsg(char* msg, int32_t len); diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index 28c1c15ea3..908468f094 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -209,7 +209,7 @@ static FORCE_INLINE int32_t taosBuildDstAddr(const char* server, uint16_t port, static void* httpThread(void* arg) { SHttpModule* http = (SHttpModule*)arg; setThreadName("http-cli-send-thread"); - uv_run(http->loop, UV_RUN_DEFAULT); + (void)uv_run(http->loop, UV_RUN_DEFAULT); return NULL; } @@ -332,7 +332,7 @@ static FORCE_INLINE void clientCloseCb(uv_handle_t* handle) { SHttpModule* http = taosAcquireRef(httpRefMgt, cli->chanId); if (http != NULL) { http->connNum -= 1; - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); } destroyHttpClient(cli); @@ -389,7 +389,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) { if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); } - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; } http->connNum += 1; @@ -404,7 +404,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) { uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); } } - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); } int32_t httpSendQuit(SHttpModule* http, int64_t chanId) { @@ -449,7 +449,7 @@ static void httpHandleQuit(SHttpMsg* msg) { SHttpModule* http = taosAcquireRef(httpRefMgt, chanId); if (http == NULL) return; uv_walk(http->loop, httpWalkCb, NULL); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); } static bool httpFailFastShoudIgnoreMsg(SHashObj* pTable, char* server, int16_t port) { @@ -474,10 +474,10 @@ static void httpFailFastMayUpdate(SHashObj* pTable, char* server, int16_t port, sprintf(buf, "%s:%d", server, port); if (succ) { - taosHashRemove(pTable, buf, strlen(buf)); + (void)taosHashRemove(pTable, buf, strlen(buf)); } else { int32_t st = taosGetTimestampSec(); - taosHashPut(pTable, buf, strlen(buf), &st, sizeof(st)); + (void)taosHashPut(pTable, buf, strlen(buf), &st, sizeof(st)); } return; } @@ -559,7 +559,7 @@ static void httpHandleReq(SHttpMsg* msg) { tError("http-report failed to alloc read buf, dst:%s:%d,chanId:%" PRId64 ", reason:%s", cli->addr, cli->port, chanId, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); destroyHttpClient(cli); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; } @@ -568,7 +568,7 @@ static void httpHandleReq(SHttpMsg* msg) { tError("http-report failed to init socket handle, dst:%s:%d,chanId:%" PRId64 ", reason:%s", cli->addr, cli->port, chanId, uv_strerror(err)); destroyHttpClient(cli); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; } @@ -578,7 +578,7 @@ static void httpHandleReq(SHttpMsg* msg) { tError("http-report failed to open socket, dst:%s:%d, chanId:%" PRId64 ", reason:%s", cli->addr, cli->port, chanId, tstrerror(TAOS_SYSTEM_ERROR(errno))); destroyHttpClient(cli); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; } @@ -587,7 +587,7 @@ static void httpHandleReq(SHttpMsg* msg) { tError("http-report failed to open socket, reason:%s, dst:%s:%d, chanId:%" PRId64 ",reason:%s", uv_strerror(ret), cli->addr, cli->port, chanId, uv_strerror(ret)); destroyHttpClient(cli); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; } @@ -598,7 +598,7 @@ static void httpHandleReq(SHttpMsg* msg) { httpFailFastMayUpdate(http->connStatusTable, cli->addr, cli->port, 0); destroyHttpClient(cli); } - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; END: @@ -608,7 +608,7 @@ END: } httpDestroyMsg(msg); taosMemoryFree(header); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); } static void httpModuleDestroy(SHttpModule* http) { @@ -619,7 +619,7 @@ static void httpModuleDestroy(SHttpModule* http) { transAsyncPoolDestroy(http->asyncPool); } if (http->loop) { - uv_loop_close(http->loop); + (void)uv_loop_close(http->loop); taosMemoryFree(http->loop); } @@ -673,7 +673,7 @@ int32_t taosSendHttpReportByChan(const char* server, const char* uri, uint16_t p int32_t taosSendHttpReport(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen, EHttpCompFlag flag) { - taosThreadOnce(&transHttpInit, transHttpEnvInit); + (void)taosThreadOnce(&transHttpInit, transHttpEnvInit); return taosSendHttpReportImplByChan(server, uri, port, pCont, contLen, flag, httpDefaultChanId); } @@ -719,9 +719,8 @@ int64_t transInitHttpChanImpl() { goto _ERROR; } - http->asyncPool = transAsyncPoolCreate(http->loop, 1, http, httpAsyncCb); - if (http->asyncPool == NULL) { - code = terrno; + code = transAsyncPoolCreate(http->loop, 1, http, httpAsyncCb, &http->asyncPool); + if (code != 0) { goto _ERROR; } @@ -744,7 +743,7 @@ _ERROR: return code; } int64_t taosInitHttpChan() { - taosThreadOnce(&transHttpInit, transHttpEnvInit); + (void)taosThreadOnce(&transHttpInit, transHttpEnvInit); return transInitHttpChanImpl(); } @@ -763,14 +762,14 @@ void taosDestroyHttpChan(int64_t chanId) { ret = httpSendQuit(load, chanId); if (ret != 0) { tDebug("http-report already destroyed, chanId %" PRId64 ",reason:%s", chanId, tstrerror(ret)); - taosReleaseRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); return; } - taosThreadJoin(load->thread, NULL); + (void)taosThreadJoin(load->thread, NULL); httpModuleDestroy(load); - taosReleaseRef(httpRefMgt, chanId); - taosRemoveRef(httpRefMgt, chanId); + (void)taosReleaseRef(httpRefMgt, chanId); + (void)taosRemoveRef(httpRefMgt, chanId); } \ No newline at end of file diff --git a/source/libs/transport/src/tmsgcb.c b/source/libs/transport/src/tmsgcb.c index e44328c683..619592c82c 100644 --- a/source/libs/transport/src/tmsgcb.c +++ b/source/libs/transport/src/tmsgcb.c @@ -59,7 +59,7 @@ int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg) { void tmsgSendRsp(SRpcMsg* pMsg) { #if 1 - rpcSendResponse(pMsg); + (void)rpcSendResponse(pMsg); #else return (*defaultMsgCb.sendRspFp)(pMsg); #endif @@ -81,6 +81,6 @@ bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint1 void tmsgUpdateDnodeEpSet(SEpSet* epset) { for (int32_t i = 0; i < epset->numOfEps; ++i) { - tmsgUpdateDnodeInfo(NULL, NULL, epset->eps[i].fqdn, &epset->eps[i].port); + (void)tmsgUpdateDnodeInfo(NULL, NULL, epset->eps[i].fqdn, &epset->eps[i].port); } } diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index c35f147fc5..fbcc74e8e1 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -27,18 +27,20 @@ int (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transRelease static int32_t transValidLocalFqdn(const char* localFqdn, uint32_t* ip) { int32_t code = taosGetIpv4FromFqdn(localFqdn, ip); - if (code) { - terrno = TSDB_CODE_RPC_FQDN_ERROR; - return -1; + if (code != 0) { + return TSDB_CODE_RPC_FQDN_ERROR; } return 0; } void* rpcOpen(const SRpcInit* pInit) { - rpcInit(); + int32_t code = rpcInit(); + if (code != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } SRpcInfo* pRpc = taosMemoryCalloc(1, sizeof(SRpcInfo)); if (pRpc == NULL) { - return NULL; + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); } if (pInit->label) { int len = strlen(pInit->label) > sizeof(pRpc->label) ? sizeof(pRpc->label) : strlen(pInit->label); @@ -84,10 +86,9 @@ void* rpcOpen(const SRpcInit* pInit) { uint32_t ip = 0; if (pInit->connType == TAOS_CONN_SERVER) { - if (transValidLocalFqdn(pInit->localFqdn, &ip) != 0) { - tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, terrstr()); - taosMemoryFree(pRpc); - return NULL; + if ((code = transValidLocalFqdn(pInit->localFqdn, &ip)) != 0) { + tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, tstrerror(code)); + TAOS_CHECK_GOTO(code, NULL, _end); } } @@ -105,19 +106,24 @@ void* rpcOpen(const SRpcInit* pInit) { (*taosInitHandle[pRpc->connType])(ip, pInit->localPort, pRpc->label, pRpc->numOfThreads, NULL, pRpc); if (pRpc->tcphandle == NULL) { - taosMemoryFree(pRpc); - return NULL; + tError("failed to init rpc handle"); + TAOS_CHECK_GOTO(terrno, NULL, _end); } int64_t refId = transAddExHandle(transGetInstMgt(), pRpc); - transAcquireExHandle(transGetInstMgt(), refId); + (void)transAcquireExHandle(transGetInstMgt(), refId); pRpc->refId = refId; return (void*)refId; +_end: + taosMemoryFree(pRpc); + terrno = code; + + return NULL; } void rpcClose(void* arg) { tInfo("start to close rpc"); - transRemoveExHandle(transGetInstMgt(), (int64_t)arg); - transReleaseExHandle(transGetInstMgt(), (int64_t)arg); + (void)transRemoveExHandle(transGetInstMgt(), (int64_t)arg); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)arg); tInfo("end to close rpc"); return; } @@ -186,7 +192,7 @@ int rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) { return transSetDefaultAddr(thandle, ip, fqdn); } // server only -void rpcSetIpWhite(void* thandle, void* arg) { transSetIpWhiteList(thandle, arg, NULL); } +int32_t rpcSetIpWhite(void* thandle, void* arg) { return transSetIpWhiteList(thandle, arg, NULL); } void* rpcAllocHandle() { return (void*)transAllocHandle(); } @@ -202,10 +208,8 @@ int32_t rpcCvtErrCode(int32_t code) { return code; } -int32_t rpcInit() { - transInit(); - return 0; -} +int32_t rpcInit() { return transInit(); } + void rpcCleanup(void) { transCleanup(); transHttpEnvDestroy(); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 19af63b24f..2e61f19af8 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -114,7 +114,7 @@ typedef struct SCliThrd { SDelayQueue* timeoutQueue; SDelayQueue* waitConnQueue; uint64_t nextTimeout; // next timeout - void* pTransInst; // + STrans* pTransInst; // int connCount; void (*destroyAhandleFp)(void* ahandle); @@ -180,12 +180,12 @@ static int32_t allocConnRef(SCliConn* conn, bool update); static int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg); -static SCliConn* cliCreateConn(SCliThrd* thrd); -static void cliDestroyConn(SCliConn* pConn, bool clear /*clear tcp handle or not*/); -static void cliDestroy(uv_handle_t* handle); -static void cliSend(SCliConn* pConn); -static void cliSendBatch(SCliConn* pConn); -static void cliDestroyConnMsgs(SCliConn* conn, bool destroy); +static int32_t cliCreateConn(SCliThrd* thrd, SCliConn** pCliConn); +static void cliDestroyConn(SCliConn* pConn, bool clear /*clear tcp handle or not*/); +static void cliDestroy(uv_handle_t* handle); +static void cliSend(SCliConn* pConn); +static void cliSendBatch(SCliConn* pConn); +static void cliDestroyConnMsgs(SCliConn* conn, bool destroy); static void doFreeTimeoutMsg(void* param); static int32_t cliPreCheckSessionLimitForMsg(SCliThrd* pThrd, char* addr, SCliMsg** pMsg); @@ -196,8 +196,8 @@ static FORCE_INLINE void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr); static FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* resp); -static FORCE_INLINE int32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn, uint32_t* ip); -static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn); +static FORCE_INLINE int32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn, uint32_t* ipaddr); +static FORCE_INLINE int32_t cliUpdateFqdnCache(SHashObj* cache, char* fqdn); static FORCE_INLINE void cliMayUpdateFqdnCache(SHashObj* cache, char* dst); // process data read from server, add decompress etc later @@ -226,16 +226,15 @@ static FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst); static FORCE_INLINE void transDestroyConnCtx(STransConnCtx* ctx); // thread obj -static SCliThrd* createThrdObj(void* trans); -static void destroyThrdObj(SCliThrd* pThrd); +static int32_t createThrdObj(void* trans, SCliThrd** pThrd); +static void destroyThrdObj(SCliThrd* pThrd); +static void cliWalkCb(uv_handle_t* handle, void* arg); -static void cliWalkCb(uv_handle_t* handle, void* arg); - -#define CLI_RELEASE_UV(loop) \ - do { \ - uv_walk(loop, cliWalkCb, NULL); \ - uv_run(loop, UV_RUN_DEFAULT); \ - uv_loop_close(loop); \ +#define CLI_RELEASE_UV(loop) \ + do { \ + (void)uv_walk(loop, cliWalkCb, NULL); \ + (void)uv_run(loop, UV_RUN_DEFAULT); \ + (void)uv_loop_close(loop); \ } while (0); // snprintf may cause performance problem @@ -245,7 +244,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg); int16_t len = strlen(ip); \ if (ip != NULL) memcpy(t, ip, len); \ t[len] = ':'; \ - titoa(port, 10, &t[len + 1]); \ + (void)titoa(port, 10, &t[len + 1]); \ } while (0) #define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para)) @@ -358,15 +357,15 @@ bool cliConnSendSeqMsg(int64_t refId, SCliConn* conn) { taosWUnLockLatch(&exh->latch); SCliMsg* t = QUEUE_DATA(h, SCliMsg, seqq); transCtxMerge(&conn->ctx, &t->ctx->appCtx); - transQueuePush(&conn->cliMsgs, t); + (void)transQueuePush(&conn->cliMsgs, t); tDebug("pop from conn %p, refId: %" PRId64 "", conn, refId); - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); cliSend(conn); return true; } taosWUnLockLatch(&exh->latch); tDebug("empty conn %p, refId: %" PRId64 "", conn, refId); - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); return false; } @@ -377,9 +376,9 @@ void cliHandleResp(SCliConn* conn) { if (conn->timer) { if (uv_is_active((uv_handle_t*)conn->timer)) { tDebug("%s conn %p stop timer", CONN_GET_INST_LABEL(conn), conn); - uv_timer_stop(conn->timer); + (void)uv_timer_stop(conn->timer); } - taosArrayPush(pThrd->timerList, &conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer->data = NULL; conn->timer = NULL; } @@ -487,7 +486,7 @@ void cliHandleResp(SCliConn* conn) { return addConnToPool(pThrd->pool, conn); } - uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); + (void)uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); } static void cliDestroyMsgInExhandle(int64_t refId) { if (refId == 0) return; @@ -501,7 +500,7 @@ static void cliDestroyMsgInExhandle(int64_t refId) { destroyCmsg(t); } taosWUnLockLatch(&exh->latch); - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); } } @@ -589,9 +588,9 @@ void cliConnTimeout(uv_timer_t* handle) { tTrace("%s conn %p conn timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn)); - uv_timer_stop(handle); + (void)uv_timer_stop(handle); handle->data = NULL; - taosArrayPush(pThrd->timerList, &conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; cliMayUpdateFqdnCache(pThrd->fqdn2ipCache, conn->dstAddr); @@ -601,7 +600,7 @@ void cliReadTimeoutCb(uv_timer_t* handle) { // set up timeout cb SCliConn* conn = handle->data; tTrace("%s conn %p timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn)); - uv_read_stop(conn->stream); + (void)uv_read_stop(conn->stream); cliHandleExceptImpl(conn, TSDB_CODE_RPC_TIMEOUT); } @@ -647,7 +646,7 @@ static SCliConn* getConnFromPool(SCliThrd* pThrd, char* key, bool* exceed) { SConnList* plist = taosHashGet((SHashObj*)pool, key, klen); if (plist == NULL) { SConnList list = {0}; - taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list)); + (void)taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list)); plist = taosHashGet(pool, key, klen); SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList)); @@ -688,7 +687,7 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) { SConnList* plist = taosHashGet((SHashObj*)pool, key, klen); if (plist == NULL) { SConnList list = {0}; - taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list)); + (void)taosHashPut((SHashObj*)pool, key, klen, (void*)&list, sizeof(list)); plist = taosHashGet(pool, key, klen); SMsgList* nList = taosMemoryCalloc(1, sizeof(SMsgList)); @@ -714,10 +713,22 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) { } STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); + if (arg == NULL) { + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } arg->param1 = *pMsg; arg->param2 = pThrd; - (*pMsg)->ctx->task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + SDelayTask* task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + if (task == NULL) { + taosMemoryFree(arg); + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } + (*pMsg)->ctx->task = task; tGTrace("%s msg %s delay to send, wait for avaiable connect", pTransInst->label, TMSG_INFO((*pMsg)->msg.msgType)); QUEUE_PUSH(&(list)->msgQ, &(*pMsg)->q); *pMsg = NULL; @@ -725,9 +736,23 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) { // send msg in delay queue if (!(QUEUE_IS_EMPTY(&(list)->msgQ))) { STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); + if (arg == NULL) { + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } arg->param1 = *pMsg; arg->param2 = pThrd; - (*pMsg)->ctx->task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + + SDelayTask* task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + if (task == NULL) { + taosMemoryFree(arg); + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } + + (*pMsg)->ctx->task = task; tGTrace("%s msg %s delay to send, wait for avaiable connect", pTransInst->label, TMSG_INFO((*pMsg)->msg.msgType)); @@ -767,12 +792,16 @@ static void addConnToPool(void* pool, SCliConn* conn) { if (conn->status == ConnInPool) { return; } - allocConnRef(conn, true); + int32_t code = allocConnRef(conn, true); + if (code != 0) { + cliDestroyConn(conn, true); + return; + } SCliThrd* thrd = conn->hostThrd; if (conn->timer != NULL) { - uv_timer_stop(conn->timer); - taosArrayPush(thrd->timerList, &conn->timer); + (void)uv_timer_stop(conn->timer); + (void)taosArrayPush(thrd->timerList, &conn->timer); conn->timer->data = NULL; conn->timer = NULL; } @@ -798,7 +827,7 @@ static void addConnToPool(void* pool, SCliConn* conn) { pMsg->ctx->task = NULL; transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx); - transQueuePush(&conn->cliMsgs, pMsg); + (void)transQueuePush(&conn->cliMsgs, pMsg); conn->status = ConnNormal; cliSend(conn); @@ -812,6 +841,7 @@ static void addConnToPool(void* pool, SCliConn* conn) { if (conn->list->size >= 10) { STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg)); + if (arg == NULL) return; arg->param1 = conn; arg->param2 = thrd; @@ -821,15 +851,18 @@ static void addConnToPool(void* pool, SCliConn* conn) { } static int32_t allocConnRef(SCliConn* conn, bool update) { if (update) { - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetRefMgt(), conn->refId); conn->refId = -1; } SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); + if (exh == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + exh->refId = transAddExHandle(transGetRefMgt(), exh); - SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); - if (self != exh) { + if (exh->refId < 0) { taosMemoryFree(exh); return TSDB_CODE_REF_INVALID_ID; } @@ -839,8 +872,14 @@ static int32_t allocConnRef(SCliConn* conn, bool update) { exh->handle = conn; exh->pThrd = conn->hostThrd; + SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); + if (self != exh) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + conn->refId = exh->refId; - if (conn->refId == -1) { + if (conn->refId < 0) { taosMemoryFree(exh); } return 0; @@ -848,8 +887,8 @@ static int32_t allocConnRef(SCliConn* conn, bool update) { static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) { if (update) { - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetRefMgt(), conn->refId); conn->refId = -1; } SExHandle* exh = transAcquireExHandle(transGetRefMgt(), handle); @@ -864,14 +903,18 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) { conn->refId = exh->refId; taosWUnLockLatch(&exh->latch); - transReleaseExHandle(transGetRefMgt(), handle); + (void)transReleaseExHandle(transGetRefMgt(), handle); return 0; } static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SCliConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; - transAllocBuffer(pBuf, buf); + int32_t code = transAllocBuffer(pBuf, buf); + if (code < 0) { + tError("conn %p failed to alloc buffer, since %s", conn, tstrerror(code)); + // cliDestroyConn(conn, true); + } } static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { // impl later @@ -909,36 +952,69 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { } } -static SCliConn* cliCreateConn(SCliThrd* pThrd) { +static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn) { + int32_t code = 0; SCliConn* conn = taosMemoryCalloc(1, sizeof(SCliConn)); + if (conn == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + // read/write stream handle conn->stream = (uv_stream_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); - uv_tcp_init(pThrd->loop, (uv_tcp_t*)(conn->stream)); + if (conn->stream == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TAOS_CHECK_GOTO(code, NULL, _failed); + } + + code = uv_tcp_init(pThrd->loop, (uv_tcp_t*)(conn->stream)); + if (code != 0) { + tError("failed to init tcp handle, code:%d, %s", code, uv_strerror(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + TAOS_CHECK_GOTO(code, NULL, _failed); + } conn->stream->data = conn; uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL; if (timer == NULL) { timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); + if (timer == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _failed); + } + tDebug("no available timer, create a timer %p", timer); - uv_timer_init(pThrd->loop, timer); + (void)uv_timer_init(pThrd->loop, timer); } timer->data = conn; conn->timer = timer; conn->connReq.data = conn; transReqQueueInit(&conn->wreqQueue); - transQueueInit(&conn->cliMsgs, NULL); - transInitBuffer(&conn->readBuf); + + TAOS_CHECK_GOTO(transQueueInit(&conn->cliMsgs, NULL), NULL, _failed); + + TAOS_CHECK_GOTO(transInitBuffer(&conn->readBuf), NULL, _failed); + QUEUE_INIT(&conn->q); conn->hostThrd = pThrd; conn->status = ConnNormal; conn->broken = false; transRefCliHandle(conn); - atomic_add_fetch_32(&pThrd->connCount, 1); - allocConnRef(conn, false); + (void)atomic_add_fetch_32(&pThrd->connCount, 1); - return conn; + TAOS_CHECK_GOTO(allocConnRef(conn, false), NULL, _failed); + + *pCliConn = conn; + return code; +_failed: + if (conn) { + taosMemoryFree(conn->stream); + transReqQueueClear(&conn->wreqQueue); + (void)transDestroyBuffer(&conn->readBuf); + transQueueDestroy(&conn->cliMsgs); + } + taosMemoryFree(conn); + return code; } static void cliDestroyConn(SCliConn* conn, bool clear) { SCliThrd* pThrd = conn->hostThrd; @@ -962,8 +1038,8 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { conn->list = NULL; - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetRefMgt(), conn->refId); conn->refId = -1; if (conn->task != NULL) { @@ -971,15 +1047,15 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { conn->task = NULL; } if (conn->timer != NULL) { - uv_timer_stop(conn->timer); + (void)uv_timer_stop(conn->timer); conn->timer->data = NULL; - taosArrayPush(pThrd->timerList, &conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; } if (clear) { if (!uv_is_closing((uv_handle_t*)conn->stream)) { - uv_read_stop(conn->stream); + (void)uv_read_stop(conn->stream); uv_close((uv_handle_t*)conn->stream, cliDestroy); } } @@ -991,16 +1067,16 @@ static void cliDestroy(uv_handle_t* handle) { SCliConn* conn = handle->data; SCliThrd* pThrd = conn->hostThrd; if (conn->timer != NULL) { - uv_timer_stop(conn->timer); - taosArrayPush(pThrd->timerList, &conn->timer); + (void)uv_timer_stop(conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer->data = NULL; conn->timer = NULL; } - atomic_sub_fetch_32(&pThrd->connCount, 1); + (void)atomic_sub_fetch_32(&pThrd->connCount, 1); - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetRefMgt(), conn->refId); taosMemoryFree(conn->dstAddr); taosMemoryFree(conn->stream); @@ -1008,7 +1084,7 @@ static void cliDestroy(uv_handle_t* handle) { tTrace("%s conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); transReqQueueClear(&conn->wreqQueue); - transDestroyBuffer(&conn->readBuf); + (void)transDestroyBuffer(&conn->readBuf); taosMemoryFree(conn); } @@ -1017,7 +1093,7 @@ static bool cliHandleNoResp(SCliConn* conn) { if (!transQueueEmpty(&conn->cliMsgs)) { SCliMsg* pMsg = transQueueGet(&conn->cliMsgs, 0); if (REQUEST_NO_RESP(&pMsg->msg)) { - transQueuePop(&conn->cliMsgs); + (void)transQueuePop(&conn->cliMsgs); destroyCmsg(pMsg); res = true; } @@ -1062,7 +1138,7 @@ static void cliSendCb(uv_write_t* req, int status) { tTrace("%s conn %p no resp required", CONN_GET_INST_LABEL(pConn), pConn); return; } - uv_read_start((uv_stream_t*)pConn->stream, cliAllocRecvBufferCb, cliRecvCb); + (void)uv_read_start((uv_stream_t*)pConn->stream, cliAllocRecvBufferCb, cliRecvCb); } void cliSendBatch(SCliConn* pConn) { SCliThrd* pThrd = pConn->hostThrd; @@ -1121,7 +1197,7 @@ void cliSendBatch(SCliConn* pConn) { req->data = pConn; tDebug("%s conn %p start to send batch msg, batch size:%d, msgLen:%d", CONN_GET_INST_LABEL(pConn), pConn, pBatch->wLen, pBatch->batchSize); - uv_write(req, (uv_stream_t*)pConn->stream, wb, wLen, cliSendBatchCb); + (void)uv_write(req, (uv_stream_t*)pConn->stream, wb, wLen, cliSendBatchCb); taosMemoryFree(wb); } void cliSend(SCliConn* pConn) { @@ -1176,13 +1252,13 @@ void cliSend(SCliConn* pConn) { if (timer == NULL) { timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); tDebug("no available timer, create a timer %p", timer); - uv_timer_init(pThrd->loop, timer); + (void)uv_timer_init(pThrd->loop, timer); } timer->data = pConn; pConn->timer = timer; tGTrace("%s conn %p start timer for msg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType)); - uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0); + (void)uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0); } if (pHead->comp == 0 && pMsg->info.compressed == 0 && pConn->clientIp != pConn->serverIp) { @@ -1225,6 +1301,7 @@ static void cliDestroyBatch(SCliBatch* pBatch) { taosMemoryFree(pBatch); } static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) { + int32_t code = 0; if (pThrd->quit == true) { cliDestroyBatch(pBatch); return; @@ -1249,22 +1326,33 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) { return; } if (conn == NULL) { - conn = cliCreateConn(pThrd); - conn->pBatch = pBatch; - conn->dstAddr = taosStrdup(pList->dst); - - uint32_t ipaddr = 0; - int32_t code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, pList->ip, &ipaddr); - if (code) { - uv_timer_stop(conn->timer); - conn->timer->data = NULL; - taosArrayPush(pThrd->timerList, &conn->timer); - conn->timer = NULL; - - cliHandleFastFail(conn, terrno); - terrno = 0; + code = cliCreateConn(pThrd, &conn); + if (code != 0) { + tError("%s failed to send batch msg, batch size:%d, msgLen: %d, conn limit:%d, reason:%s", pTransInst->label, + pBatch->wLen, pBatch->batchSize, pTransInst->connLimitNum, tstrerror(code)); + cliDestroyBatch(pBatch); return; } + + conn->pBatch = pBatch; + conn->dstAddr = taosStrdup(pList->dst); + if (conn->dstAddr == NULL) { + tError("%s conn %p failed to send batch msg, reason:%s", transLabel(pTransInst), conn, + tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + cliHandleFastFail(conn, -1); + return; + } + + uint32_t ipaddr = 0; + if ((code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, pList->ip, &ipaddr)) != 0) { + (void)uv_timer_stop(conn->timer); + conn->timer->data = NULL; + (void)taosArrayPush(pThrd->timerList, &conn->timer); + conn->timer = NULL; + cliHandleFastFail(conn, code); + return; + } + struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = ipaddr; @@ -1293,16 +1381,16 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) { ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); if (ret != 0) { - uv_timer_stop(conn->timer); + (void)uv_timer_stop(conn->timer); conn->timer->data = NULL; - taosArrayPush(pThrd->timerList, &conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; cliMayUpdateFqdnCache(pThrd->fqdn2ipCache, conn->dstAddr); cliHandleFastFail(conn, -1); return; } - uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); + (void)uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); return; } @@ -1373,7 +1461,7 @@ static void cliHandleFastFail(SCliConn* pConn, int status) { } } else { SFailFastItem item = {.count = 1, .timestamp = cTimestamp}; - taosHashPut(pThrd->failFastCache, pConn->dstAddr, strlen(pConn->dstAddr), &item, sizeof(SFailFastItem)); + (void)taosHashPut(pThrd->failFastCache, pConn->dstAddr, strlen(pConn->dstAddr), &item, sizeof(SFailFastItem)); } } } else { @@ -1393,9 +1481,9 @@ void cliConnCb(uv_connect_t* req, int status) { if (pConn->timer == NULL) { timeout = true; } else { - uv_timer_stop(pConn->timer); + (void)uv_timer_stop(pConn->timer); pConn->timer->data = NULL; - taosArrayPush(pThrd->timerList, &pConn->timer); + (void)taosArrayPush(pThrd->timerList, &pConn->timer); pConn->timer = NULL; } @@ -1411,12 +1499,12 @@ void cliConnCb(uv_connect_t* req, int status) { struct sockaddr peername, sockname; int addrlen = sizeof(peername); - uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen); - transSockInfo2Str(&peername, pConn->dst); + (void)uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen); + (void)transSockInfo2Str(&peername, pConn->dst); addrlen = sizeof(sockname); - uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen); - transSockInfo2Str(&sockname, pConn->src); + (void)uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen); + (void)transSockInfo2Str(&sockname, pConn->src); struct sockaddr_in addr = *(struct sockaddr_in*)&sockname; struct sockaddr_in saddr = *(struct sockaddr_in*)&peername; @@ -1466,8 +1554,8 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrd* pThrd) { tDebug("cli work thread %p start to quit", pThrd); destroyCmsg(pMsg); - destroyConnPool(pThrd); - uv_walk(pThrd->loop, cliWalkCb, NULL); + (void)destroyConnPool(pThrd); + (void)uv_walk(pThrd->loop, cliWalkCb, NULL); } static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) { int64_t refId = (int64_t)(pMsg->msg.info.handle); @@ -1482,7 +1570,7 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) { SCliConn* conn = exh->handle; taosRUnLockLatch(&exh->latch); - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn); if (T_REF_VAL_GET(conn) == 2) { @@ -1521,7 +1609,7 @@ SCliConn* cliGetConn(SCliMsg** pMsg, SCliThrd* pThrd, bool* ignore, char* addr) conn = getConnFromPool2(pThrd, addr, pMsg); if (conn != NULL) specifyConnRef(conn, true, refId); } - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); } return conn; }; @@ -1553,37 +1641,45 @@ FORCE_INLINE bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx) { FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) { if (pMsg == NULL) return -1; - memset(pResp, 0, sizeof(STransMsg)); + // memset(pResp, 0, sizeof(STransMsg)); - pResp->code = TSDB_CODE_RPC_BROKEN_LINK; + if (pResp->code == 0) { + pResp->code = TSDB_CODE_RPC_BROKEN_LINK; + } pResp->msgType = pMsg->msg.msgType + 1; pResp->info.ahandle = pMsg->ctx ? pMsg->ctx->ahandle : NULL; pResp->info.traceId = pMsg->msg.info.traceId; return 0; } + static FORCE_INLINE int32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn, uint32_t* ip) { + int32_t code = 0; + uint32_t addr = 0; size_t len = strlen(fqdn); uint32_t* v = taosHashGet(cache, fqdn, len); if (v == NULL) { - int32_t code = taosGetIpv4FromFqdn(fqdn, ip); - if (code) { - tError("failed to get ip from fqdn:%s since %s", fqdn, terrstr()); + code = taosGetIpv4FromFqdn(fqdn, &addr); + if (code != 0) { + code = TSDB_CODE_RPC_FQDN_ERROR; + tError("failed to get ip from fqdn:%s since %s", fqdn, tstrerror(code)); return code; } - taosHashPut(cache, fqdn, len, ip, sizeof(*ip)); + if ((code = taosHashPut(cache, fqdn, len, &addr, sizeof(addr)) != 0)) { + return code; + } + *ip = addr; } else { *ip = *v; } - - return TSDB_CODE_SUCCESS; + return 0; } -static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn) { +static FORCE_INLINE int32_t cliUpdateFqdnCache(SHashObj* cache, char* fqdn) { // impl later uint32_t addr = 0; - int32_t code = taosGetIpv4FromFqdn(fqdn, &addr); - if (TSDB_CODE_SUCCESS == code) { + int32_t code = taosGetIpv4FromFqdn(fqdn, &addr); + if (code == 0) { size_t len = strlen(fqdn); uint32_t* v = taosHashGet(cache, fqdn, len); if (addr != *v) { @@ -1591,10 +1687,12 @@ static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn) { tinet_ntoa(old, *v); tinet_ntoa(new, addr); tWarn("update ip of fqdn:%s, old: %s, new: %s", fqdn, old, new); - taosHashPut(cache, fqdn, strlen(fqdn), &addr, sizeof(addr)); + code = taosHashPut(cache, fqdn, strlen(fqdn), &addr, sizeof(addr)); } + } else { + code = TSDB_CODE_RPC_FQDN_ERROR; // TSDB_CODE_RPC_INVALID_FQDN; } - return; + return code; } static void cliMayUpdateFqdnCache(SHashObj* cache, char* dst) { @@ -1607,7 +1705,7 @@ static void cliMayUpdateFqdnCache(SHashObj* cache, char* dst) { if (i > 0) { char fqdn[TSDB_FQDN_LEN + 1] = {0}; memcpy(fqdn, dst, i); - cliUpdateFqdnCache(cache, fqdn); + (void)cliUpdateFqdnCache(cache, fqdn); } } @@ -1623,7 +1721,9 @@ static void doFreeTimeoutMsg(void* param) { doNotifyApp(pMsg, pThrd, code); taosMemoryFree(arg); } + void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { + int32_t code = 0; STrans* pTransInst = pThrd->pTransInst; cliMayCvtFqdnToIp(&pMsg->ctx->epSet, &pThrd->cvtAddr); @@ -1641,8 +1741,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { SCliConn* conn = cliGetConn(&pMsg, pThrd, &ignore, addr); if (ignore == true) { // persist conn already release by server - STransMsg resp; - cliBuildExceptResp(pMsg, &resp); + STransMsg resp = {0}; + (void)cliBuildExceptResp(pMsg, &resp); // refactorr later resp.info.cliVer = pTransInst->compatibilityVer; @@ -1659,29 +1759,40 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { if (conn != NULL) { transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx); - transQueuePush(&conn->cliMsgs, pMsg); + (void)transQueuePush(&conn->cliMsgs, pMsg); cliSend(conn); } else { - conn = cliCreateConn(pThrd); + code = cliCreateConn(pThrd, &conn); + if (code != 0) { + tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code)); + STransMsg resp = {.code = code}; + (void)cliBuildExceptResp(pMsg, &resp); + + resp.info.cliVer = pTransInst->compatibilityVer; + if (pMsg->type != Release) { + pTransInst->cfp(pTransInst->parent, &resp, NULL); + } + destroyCmsg(pMsg); + return; + } int64_t refId = (int64_t)pMsg->msg.info.handle; if (refId != 0) specifyConnRef(conn, true, refId); transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx); - transQueuePush(&conn->cliMsgs, pMsg); + (void)transQueuePush(&conn->cliMsgs, pMsg); conn->dstAddr = taosStrdup(addr); - uint32_t ipaddr = 0; - int32_t code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, fqdn, &ipaddr); - if (code) { - uv_timer_stop(conn->timer); + uint32_t ipaddr; + int32_t code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, fqdn, &ipaddr); + if (code != 0) { + (void)uv_timer_stop(conn->timer); conn->timer->data = NULL; - taosArrayPush(pThrd->timerList, &conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; - cliHandleExcept(conn, terrno); - terrno = 0; + cliHandleExcept(conn, code); return; } @@ -1699,12 +1810,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { errno = 0; return; } + int ret = uv_tcp_open((uv_tcp_t*)conn->stream, fd); if (ret != 0) { tGError("%s conn %p failed to set stream, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret)); cliHandleExcept(conn, -1); return; } + ret = transSetConnOption((uv_tcp_t*)conn->stream, tsKeepAliveIdle); if (ret != 0) { tGError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret)); @@ -1714,16 +1827,16 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { ret = uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); if (ret != 0) { - uv_timer_stop(conn->timer); + (void)uv_timer_stop(conn->timer); conn->timer->data = NULL; - taosArrayPush(pThrd->timerList, &conn->timer); + (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; cliMayUpdateFqdnCache(pThrd->fqdn2ipCache, conn->dstAddr); cliHandleFastFail(conn, ret); return; } - uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); + (void)uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); } tGTrace("%s conn %p ready", pTransInst->label, conn); } @@ -1810,7 +1923,7 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) { QUEUE_PUSH(&pBatchList->wq, &pBatch->listq); - taosHashPut(pThrd->batchCache, key, klen, &pBatchList, sizeof(void*)); + (void)taosHashPut(pThrd->batchCache, key, klen, &pBatchList, sizeof(void*)); } else { if (QUEUE_IS_EMPTY(&(*ppBatchList)->wq)) { SCliBatch* pBatch = taosMemoryCalloc(1, sizeof(SCliBatch)); @@ -1876,9 +1989,9 @@ static void cliAsyncCb(uv_async_t* handle) { // batch process to avoid to lock/unlock frequently queue wq; - taosThreadMutexLock(&item->mtx); + (void)taosThreadMutexLock(&item->mtx); QUEUE_MOVE(&item->qmsg, &wq); - taosThreadMutexUnlock(&item->mtx); + (void)taosThreadMutexUnlock(&item->mtx); int8_t supportBatch = pTransInst->supportBatch; if (supportBatch == 0) { @@ -1899,9 +2012,9 @@ static void cliPrepareCb(uv_prepare_t* handle) { SAsyncItem* item = async->data; queue wq; - taosThreadMutexLock(&item->mtx); + (void)taosThreadMutexLock(&item->mtx); QUEUE_MOVE(&item->qmsg, &wq); - taosThreadMutexUnlock(&item->mtx); + (void)taosThreadMutexUnlock(&item->mtx); int count = 0; while (!QUEUE_IS_EMPTY(&wq)) { @@ -1955,7 +2068,7 @@ bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) { tDebug("%s conn %p receive release request, refId:%" PRId64 ", may ignore", CONN_GET_INST_LABEL(conn), conn, conn->refId); - transClearBuffer(&conn->readBuf); + (void)transClearBuffer(&conn->readBuf); transFreeMsg(transContFromHead((char*)pHead)); for (int i = 0; ahandle == 0 && i < transQueueSize(&conn->cliMsgs); i++) { @@ -1981,37 +2094,47 @@ bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) { } static void* cliWorkThread(void* arg) { + char threadName[TSDB_LABEL_LEN] = {0}; + SCliThrd* pThrd = (SCliThrd*)arg; pThrd->pid = taosGetSelfPthreadId(); - char threadName[TSDB_LABEL_LEN] = {0}; - STrans* pInst = pThrd->pTransInst; - strtolower(threadName, pInst->label); + (void)strtolower(threadName, pThrd->pTransInst->label); setThreadName(threadName); - uv_run(pThrd->loop, UV_RUN_DEFAULT); + (void)uv_run(pThrd->loop, UV_RUN_DEFAULT); tDebug("thread quit-thread:%08" PRId64, pThrd->pid); return NULL; } void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { + int32_t code = 0; SCliObj* cli = taosMemoryCalloc(1, sizeof(SCliObj)); + if (cli == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _err); + } STrans* pTransInst = shandle; memcpy(cli->label, label, TSDB_LABEL_LEN); cli->numOfThreads = numOfThreads; + cli->pThreadObj = (SCliThrd**)taosMemoryCalloc(cli->numOfThreads, sizeof(SCliThrd*)); + if (cli->pThreadObj == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _err); + } for (int i = 0; i < cli->numOfThreads; i++) { - SCliThrd* pThrd = createThrdObj(shandle); - if (pThrd == NULL) { + SCliThrd* pThrd = NULL; + code = createThrdObj(shandle, &pThrd); + if (code != 0) { goto _err; } int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd)); if (err != 0) { - goto _err; + code = TAOS_SYSTEM_ERROR(errno); + TAOS_CHECK_GOTO(code, NULL, _err); } else { tDebug("success to create tranport-cli thread:%d", i); } @@ -2020,8 +2143,11 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, return cli; _err: - taosMemoryFree(cli->pThreadObj); - taosMemoryFree(cli); + if (cli) { + taosMemoryFree(cli->pThreadObj); + taosMemoryFree(cli); + } + terrno = code; return NULL; } @@ -2037,11 +2163,9 @@ static FORCE_INLINE void destroyCmsg(void* arg) { taosMemoryFree(pMsg); } static FORCE_INLINE void destroyCmsgWrapper(void* arg, void* param) { - SCliMsg* pMsg = arg; - if (pMsg == NULL) { - return; - } + if (arg == NULL) return; + SCliMsg* pMsg = arg; SCliThrd* pThrd = param; if (pMsg->msg.info.notFreeAhandle == 0 && pThrd != NULL) { if (pThrd->destroyAhandleFp) (*pThrd->destroyAhandleFp)(pMsg->msg.info.ahandle); @@ -2064,76 +2188,133 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) { taosMemoryFree(pMsg); } -static SCliThrd* createThrdObj(void* trans) { +static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) { + int32_t code = 0; STrans* pTransInst = trans; SCliThrd* pThrd = (SCliThrd*)taosMemoryCalloc(1, sizeof(SCliThrd)); + if (pThrd == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } QUEUE_INIT(&pThrd->msg); - taosThreadMutexInit(&pThrd->msgMtx, NULL); + (void)taosThreadMutexInit(&pThrd->msgMtx, NULL); pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); - int err = uv_loop_init(pThrd->loop); - if (err != 0) { - tError("failed to init uv_loop, reason:%s", uv_err_name(err)); - taosMemoryFree(pThrd->loop); - taosThreadMutexDestroy(&pThrd->msgMtx); - taosMemoryFree(pThrd); - return NULL; + if (pThrd->loop == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); } - int32_t nSync = pTransInst->supportBatch ? 4 : 8; - pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, nSync, pThrd, cliAsyncCb); - if (pThrd->asyncPool == NULL) { - tError("failed to init async pool"); - uv_loop_close(pThrd->loop); - taosMemoryFree(pThrd->loop); - taosThreadMutexDestroy(&pThrd->msgMtx); - taosMemoryFree(pThrd); - return NULL; + code = uv_loop_init(pThrd->loop); + if (code != 0) { + tError("failed to init uv_loop, reason:%s", uv_err_name(code)); + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end); + } + + int32_t nSync = pTransInst->supportBatch ? 4 : 8; + code = transAsyncPoolCreate(pThrd->loop, nSync, pThrd, cliAsyncCb, &pThrd->asyncPool); + if (code != 0) { + tError("failed to init async pool since:%s", tstrerror(code)); + TAOS_CHECK_GOTO(code, NULL, _end); } pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); - uv_prepare_init(pThrd->loop, pThrd->prepare); + if (pThrd->prepare == NULL) { + tError("failed to create prepre since:%s", tstrerror(code)); + TAOS_CHECK_GOTO(code, NULL, _end); + } + + code = uv_prepare_init(pThrd->loop, pThrd->prepare); + if (code != 0) { + tError("failed to create prepre since:%s", uv_err_name(code)); + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end); + } pThrd->prepare->data = pThrd; - // uv_prepare_start(pThrd->prepare, cliPrepareCb); int32_t timerSize = 64; pThrd->timerList = taosArrayInit(timerSize, sizeof(void*)); + if (pThrd->timerList == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + for (int i = 0; i < timerSize; i++) { uv_timer_t* timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); - uv_timer_init(pThrd->loop, timer); - taosArrayPush(pThrd->timerList, &timer); + if (timer == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + (void)uv_timer_init(pThrd->loop, timer); + (void)taosArrayPush(pThrd->timerList, &timer); } pThrd->pool = createConnPool(4); - transDQCreate(pThrd->loop, &pThrd->delayQueue); + if (pThrd->pool == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + if ((code = transDQCreate(pThrd->loop, &pThrd->delayQueue)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } - transDQCreate(pThrd->loop, &pThrd->timeoutQueue); + if ((code = transDQCreate(pThrd->loop, &pThrd->timeoutQueue)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } - transDQCreate(pThrd->loop, &pThrd->waitConnQueue); - - pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); - pThrd->pTransInst = trans; + if ((code = transDQCreate(pThrd->loop, &pThrd->waitConnQueue)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } pThrd->destroyAhandleFp = pTransInst->destroyFp; pThrd->fqdn2ipCache = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pThrd->fqdn2ipCache == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } pThrd->failFastCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pThrd->failFastCache == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } pThrd->batchCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pThrd->batchCache == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); + pThrd->pTransInst = trans; pThrd->quit = false; - return pThrd; + *ppThrd = pThrd; + return code; + +_end: + if (pThrd) { + (void)uv_loop_close(pThrd->loop); + taosMemoryFree(pThrd->loop); + taosMemoryFree(pThrd->prepare); + (void)taosThreadMutexDestroy(&pThrd->msgMtx); + transAsyncPoolDestroy(pThrd->asyncPool); + for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) { + uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i); + taosMemoryFree(timer); + } + taosArrayDestroy(pThrd->timerList); + taosMemoryFree(pThrd->prepare); + taosHashCleanup(pThrd->fqdn2ipCache); + taosHashCleanup(pThrd->failFastCache); + taosHashCleanup(pThrd->batchCache); + + taosMemoryFree(pThrd); + } + return code; } static void destroyThrdObj(SCliThrd* pThrd) { if (pThrd == NULL) { return; } - taosThreadJoin(pThrd->thread, NULL); + (void)taosThreadJoin(pThrd->thread, NULL); CLI_RELEASE_UV(pThrd->loop); - taosThreadMutexDestroy(&pThrd->msgMtx); + (void)taosThreadMutexDestroy(&pThrd->msgMtx); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsgWrapper, (void*)pThrd); transAsyncPoolDestroy(pThrd->asyncPool); @@ -2177,21 +2358,32 @@ static FORCE_INLINE void transDestroyConnCtx(STransConnCtx* ctx) { taosMemoryFree(ctx); } -void cliSendQuit(SCliThrd* thrd) { +int32_t cliSendQuit(SCliThrd* thrd) { // cli can stop gracefully + int32_t code = 0; SCliMsg* msg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (msg == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + msg->type = Quit; - transAsyncSend(thrd->asyncPool, &msg->q); + if ((code = transAsyncSend(thrd->asyncPool, &msg->q)) != 0) { + code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); + taosMemoryFree(msg); + return code; + } + atomic_store_8(&thrd->asyncPool->stop, 1); + return 0; } void cliWalkCb(uv_handle_t* handle, void* arg) { if (!uv_is_closing(handle)) { if (uv_handle_get_type(handle) == UV_TIMER) { // do nothing } else { - uv_read_stop((uv_stream_t*)handle); + (void)uv_read_stop((uv_stream_t*)handle); } - uv_close(handle, cliDestroy); + (void)uv_close(handle, cliDestroy); } } @@ -2229,7 +2421,7 @@ static void cliSchedMsgToDebug(SCliMsg* pMsg, char* label) { STransConnCtx* pCtx = pMsg->ctx; STraceId* trace = &pMsg->msg.info.traceId; char tbuf[512] = {0}; - epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)); + (void)epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)); tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", label, tbuf, pCtx->retryStep, pCtx->retryNextInterval); return; @@ -2244,7 +2436,7 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) { arg->param1 = pMsg; arg->param2 = pThrd; - transDQSched(pThrd->delayQueue, doDelayTask, arg, pCtx->retryNextInterval); + (void)transDQSched(pThrd->delayQueue, doDelayTask, arg, pCtx->retryNextInterval); } FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) { @@ -2462,7 +2654,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { if (hasEpSet) { if (rpcDebugFlag & DEBUG_TRACE) { char tbuf[512] = {0}; - epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)); + (void)epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)); tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn); } } @@ -2474,7 +2666,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { } else { memcpy((char*)pCtx->pRsp, (char*)pResp, sizeof(*pResp)); } - tsem_post(pCtx->pSem); + (void)tsem_post(pCtx->pSem); pCtx->pRsp = NULL; } else { STransSyncMsg* pSyncMsg = taosAcquireRef(transGetSyncMsgMgt(), pCtx->syncMsgRef); @@ -2484,8 +2676,8 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pSyncMsg->hasEpSet = 1; epsetAssign(&pSyncMsg->epSet, &pCtx->epSet); } - tsem2_post(pSyncMsg->pSem); - taosReleaseRef(transGetSyncMsgMgt(), pCtx->syncMsgRef); + (void)tsem2_post(pSyncMsg->pSem); + (void)taosReleaseRef(transGetSyncMsgMgt(), pCtx->syncMsgRef); } else { rpcFreeCont(pResp->pCont); } @@ -2506,9 +2698,14 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { } void transCloseClient(void* arg) { + int32_t code = 0; SCliObj* cli = arg; for (int i = 0; i < cli->numOfThreads; i++) { - cliSendQuit(cli->pThreadObj[i]); + code = cliSendQuit(cli->pThreadObj[i]); + if (code != 0) { + tError("failed to send quit to thread:%d, reason:%s", i, tstrerror(code)); + } + destroyThrdObj(cli->pThreadObj[i]); } taosMemoryFree(cli->pThreadObj); @@ -2549,7 +2746,7 @@ static FORCE_INLINE SCliThrd* transGetWorkThrdFromHandle(STrans* trans, int64_t pThrd = exh->pThrd; taosWUnLockLatch(&exh->latch); - transReleaseExHandle(transGetRefMgt(), handle); + (void)transReleaseExHandle(transGetRefMgt(), handle); return pThrd; } @@ -2563,9 +2760,7 @@ SCliThrd* transGetWorkThrd(STrans* trans, int64_t handle) { return pThrd; } int transReleaseCliHandle(void* handle) { - int idx = -1; - bool valid = false; - + int32_t code = 0; SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle); if (pThrd == NULL) { return TSDB_CODE_RPC_BROKEN_LINK; @@ -2575,9 +2770,17 @@ int transReleaseCliHandle(void* handle) { TRACE_SET_MSGID(&tmsg.info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCtx->ahandle = tmsg.info.ahandle; SCliMsg* cmsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cmsg == NULL) { + taosMemoryFree(pCtx); + return TSDB_CODE_OUT_OF_MEMORY; + } cmsg->msg = tmsg; cmsg->st = taosGetTimestampUs(); cmsg->type = Release; @@ -2586,15 +2789,20 @@ int transReleaseCliHandle(void* handle) { STraceId* trace = &tmsg.info.traceId; tGDebug("send release request at thread:%08" PRId64 ", malloc memory:%p", pThrd->pid, cmsg); - if (0 != transAsyncSend(pThrd->asyncPool, &cmsg->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &cmsg->q)) != 0) { destroyCmsg(cmsg); - return TSDB_CODE_RPC_BROKEN_LINK; + return code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code; } - return 0; + return code; } -static SCliMsg* transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) { + +static int32_t transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx, SCliMsg** pCliMsg) { TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + epsetAssign(&pCtx->epSet, pEpSet); epsetAssign(&pCtx->origEpSet, pEpSet); @@ -2604,13 +2812,20 @@ static SCliMsg* transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pRe if (ctx != NULL) pCtx->appCtx = *ctx; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + taosMemoryFree(pCtx); + return TSDB_CODE_OUT_OF_MEMORY; + } + cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); cliMsg->type = Normal; cliMsg->refId = (int64_t)shandle; QUEUE_INIT(&cliMsg->seqq); - return cliMsg; + *pCliMsg = cliMsg; + + return 0; } int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) { @@ -2619,12 +2834,12 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran transFreeMsg(pReq->pCont); return TSDB_CODE_RPC_BROKEN_LINK; } - + int32_t code = 0; int64_t handle = (int64_t)pReq->info.handle; SCliThrd* pThrd = transGetWorkThrd(pTransInst, handle); if (pThrd == NULL) { transFreeMsg(pReq->pCont); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); return TSDB_CODE_RPC_BROKEN_LINK; } if (handle != 0) { @@ -2632,55 +2847,80 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran if (exh != NULL) { taosWLockLatch(&exh->latch); if (exh->handle == NULL && exh->inited != 0) { - SCliMsg* pCliMsg = transInitMsg(shandle, pEpSet, pReq, ctx); + SCliMsg* pCliMsg = NULL; + code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg); + ASSERT(code == 0); + QUEUE_PUSH(&exh->q, &pCliMsg->seqq); taosWUnLockLatch(&exh->latch); tDebug("msg refId: %" PRId64 "", handle); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); return 0; } exh->inited = 1; taosWUnLockLatch(&exh->latch); - transReleaseExHandle(transGetRefMgt(), handle); + (void)transReleaseExHandle(transGetRefMgt(), handle); } } - SCliMsg* pCliMsg = transInitMsg(shandle, pEpSet, pReq, ctx); + + SCliMsg* pCliMsg = NULL; + code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg); + if (code != 0) { + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + return code; + } STraceId* trace = &pReq->info.traceId; tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle); - if (0 != transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) { + if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) { destroyCmsg(pCliMsg); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return TSDB_CODE_RPC_BROKEN_LINK; + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); } - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); return 0; } int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp) { - STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); - STransMsg* pTransRsp = taosMemoryCalloc(1, sizeof(STransMsg)); + STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); if (pTransInst == NULL) { transFreeMsg(pReq->pCont); - taosMemoryFree(pTransRsp); return TSDB_CODE_RPC_BROKEN_LINK; } + int32_t code = 0; + + STransMsg* pTransRsp = taosMemoryCalloc(1, sizeof(STransMsg)); + if (pTransRsp == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); if (pThrd == NULL) { - transFreeMsg(pReq->pCont); - taosMemoryFree(pTransRsp); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return TSDB_CODE_RPC_BROKEN_LINK; + TAOS_CHECK_GOTO(TSDB_CODE_RPC_BROKEN_LINK, NULL, _RETURN1); } tsem_t* sem = taosMemoryCalloc(1, sizeof(tsem_t)); - tsem_init(sem, 0, 0); + if (sem == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } + + code = tsem_init(sem, 0, 0); + if (code != 0) { + taosMemoryFree(sem); + code = TAOS_SYSTEM_ERROR(errno); + TAOS_CHECK_GOTO(code, NULL, _RETURN1); + } TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + (void)tsem_destroy(sem); + taosMemoryFree(sem); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } + epsetAssign(&pCtx->epSet, pEpSet); epsetAssign(&pCtx->origEpSet, pEpSet); pCtx->ahandle = pReq->info.ahandle; @@ -2689,6 +2929,13 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs pCtx->pRsp = pTransRsp; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + (void)tsem_destroy(sem); + taosMemoryFree(sem); + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } + cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); @@ -2699,28 +2946,42 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); - if (ret != 0) { + code = transAsyncSend(pThrd->asyncPool, &cliMsg->q); + if (code != 0) { destroyCmsg(cliMsg); - ret = TSDB_CODE_RPC_BROKEN_LINK; - goto _RETURN; + TAOS_CHECK_GOTO((code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code), NULL, _RETURN); } - tsem_wait(sem); + (void)tsem_wait(sem); memcpy(pRsp, pTransRsp, sizeof(STransMsg)); _RETURN: tsem_destroy(sem); taosMemoryFree(sem); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); taosMemoryFree(pTransRsp); - return ret; + return code; +_RETURN1: + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + taosMemoryFree(pTransRsp); + taosMemoryFree(pReq->pCont); + return code; } -int64_t transCreateSyncMsg(STransMsg* pTransMsg) { +int32_t transCreateSyncMsg(STransMsg* pTransMsg, int64_t* refId) { + int32_t code = 0; tsem2_t* sem = taosMemoryCalloc(1, sizeof(tsem2_t)); - tsem2_init(sem, 0, 0); + if (sem == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + if (tsem2_init(sem, 0, 0) != 0) { + TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _EXIT); + } STransSyncMsg* pSyncMsg = taosMemoryCalloc(1, sizeof(STransSyncMsg)); + if (pSyncMsg == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _EXIT); + } taosInitRWLatch(&pSyncMsg->latch); pSyncMsg->inited = 0; @@ -2728,39 +2989,69 @@ int64_t transCreateSyncMsg(STransMsg* pTransMsg) { pSyncMsg->pSem = sem; pSyncMsg->hasEpSet = 0; - return taosAddRef(transGetSyncMsgMgt(), pSyncMsg); + int64_t id = taosAddRef(transGetSyncMsgMgt(), pSyncMsg); + if (id < 0) { + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _EXIT); + } else { + *refId = id; + } + return 0; + +_EXIT: + (void)tsem2_destroy(sem); + taosMemoryFree(sem); + taosMemoryFree(pSyncMsg); + return code; } int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp, int8_t* epUpdated, int32_t timeoutMs) { - STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); - STransMsg* pTransMsg = taosMemoryCalloc(1, sizeof(STransMsg)); + int32_t code = 0; + STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); if (pTransInst == NULL) { transFreeMsg(pReq->pCont); - taosMemoryFree(pTransMsg); return TSDB_CODE_RPC_BROKEN_LINK; } + STransMsg* pTransMsg = taosMemoryCalloc(1, sizeof(STransMsg)); + if (pTransMsg == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN2); + } + SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); if (pThrd == NULL) { - transFreeMsg(pReq->pCont); - taosMemoryFree(pTransMsg); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return TSDB_CODE_RPC_BROKEN_LINK; + TAOS_CHECK_GOTO(TSDB_CODE_RPC_BROKEN_LINK, NULL, _RETURN2); } TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN2); + } + epsetAssign(&pCtx->epSet, pEpSet); epsetAssign(&pCtx->origEpSet, pEpSet); pCtx->ahandle = pReq->info.ahandle; pCtx->msgType = pReq->msgType; - pCtx->syncMsgRef = transCreateSyncMsg(pTransMsg); + + if ((code = transCreateSyncMsg(pTransMsg, &pCtx->syncMsgRef)) != 0) { + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(code, NULL, _RETURN2); + } int64_t ref = pCtx->syncMsgRef; STransSyncMsg* pSyncMsg = taosAcquireRef(transGetSyncMsgMgt(), ref); + if (pSyncMsg == NULL) { + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _RETURN2); + } SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN2); + } + cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); @@ -2771,17 +3062,17 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); - if (ret != 0) { + code = transAsyncSend(pThrd->asyncPool, &cliMsg->q); + if (code != 0) { destroyCmsg(cliMsg); - ret = TSDB_CODE_RPC_BROKEN_LINK; + TAOS_CHECK_GOTO(code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code, NULL, _RETURN); goto _RETURN; } - ret = tsem2_timewait(pSyncMsg->pSem, timeoutMs); - if (ret < 0) { + code = tsem2_timewait(pSyncMsg->pSem, timeoutMs); + if (code < 0) { pRsp->code = TSDB_CODE_TIMEOUT_ERROR; - ret = TSDB_CODE_TIMEOUT_ERROR; + code = TSDB_CODE_TIMEOUT_ERROR; } else { memcpy(pRsp, pSyncMsg->pRsp, sizeof(STransMsg)); pSyncMsg->pRsp->pCont = NULL; @@ -2789,13 +3080,18 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr epsetAssign(pEpSet, &pSyncMsg->epSet); *epUpdated = 1; } - ret = 0; + code = 0; } _RETURN: - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - taosReleaseRef(transGetSyncMsgMgt(), ref); - taosRemoveRef(transGetSyncMsgMgt(), ref); - return ret; + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + (void)taosReleaseRef(transGetSyncMsgMgt(), ref); + (void)taosRemoveRef(transGetSyncMsgMgt(), ref); + return code; +_RETURN2: + transFreeMsg(pReq->pCont); + taosMemoryFree(pTransMsg); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + return code; } /* * @@ -2812,11 +3108,25 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { tstrncpy(cvtAddr.fqdn, fqdn, sizeof(cvtAddr.fqdn)); cvtAddr.cvt = true; } - for (int i = 0; i < pTransInst->numOfThreads; i++) { + + int32_t code = 0; + int8_t i = 0; + for (i = 0; i < pTransInst->numOfThreads; i++) { STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pCtx->cvtAddr = cvtAddr; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + taosMemoryFree(pCtx); + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + cliMsg->ctx = pCtx; cliMsg->type = Update; cliMsg->refId = (int64_t)shandle; @@ -2824,21 +3134,30 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { SCliThrd* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; tDebug("%s update epset at thread:%08" PRId64, pTransInst->label, thrd->pid); - if (transAsyncSend(thrd->asyncPool, &(cliMsg->q)) != 0) { + if ((code = transAsyncSend(thrd->asyncPool, &(cliMsg->q))) != 0) { destroyCmsg(cliMsg); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); + break; } } - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return 0; + + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + return code; } int64_t transAllocHandle() { SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); + if (exh == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } exh->refId = transAddExHandle(transGetRefMgt(), exh); + if (exh->refId < 0) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); - ASSERT(exh == self); if (exh != self) { taosMemoryFree(exh); return TSDB_CODE_REF_INVALID_ID; @@ -2847,6 +3166,5 @@ int64_t transAllocHandle() { QUEUE_INIT(&exh->q); taosInitRWLatch(&exh->latch); tDebug("pre alloc refId %" PRId64 "", exh->refId); - return exh->refId; } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index b9223e7b39..9df0ddb6f3 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -67,7 +67,11 @@ int32_t transDecompressMsg(char** msg, int32_t len) { STransCompMsg* pComp = (STransCompMsg*)pCont; int32_t oriLen = htonl(pComp->contLen); - char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead)); + char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead)); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + STransMsgHead* pNewHead = (STransMsgHead*)buf; int32_t decompLen = LZ4_decompress_safe(pCont + sizeof(STransCompMsg), (char*)pNewHead->content, len - sizeof(STransMsgHead) - sizeof(STransCompMsg), oriLen); @@ -78,7 +82,7 @@ int32_t transDecompressMsg(char** msg, int32_t len) { taosMemoryFree(pHead); *msg = buf; if (decompLen != oriLen) { - return -1; + return TSDB_CODE_INVALID_MSG; } return 0; } @@ -98,26 +102,33 @@ int transSockInfo2Str(struct sockaddr* sockname, char* dst) { sprintf(dst, "%s:%d", buf, ntohs(addr.sin_port)); return r; } -int transInitBuffer(SConnBuffer* buf) { - buf->cap = BUFFER_CAP; +int32_t transInitBuffer(SConnBuffer* buf) { buf->buf = taosMemoryCalloc(1, BUFFER_CAP); + if (buf->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + buf->cap = BUFFER_CAP; buf->left = -1; buf->len = 0; buf->total = 0; buf->invalid = 0; return 0; } -int transDestroyBuffer(SConnBuffer* p) { +int32_t transDestroyBuffer(SConnBuffer* p) { taosMemoryFree(p->buf); p->buf = NULL; return 0; } -int transClearBuffer(SConnBuffer* buf) { +int32_t transClearBuffer(SConnBuffer* buf) { SConnBuffer* p = buf; if (p->cap > BUFFER_CAP) { p->cap = BUFFER_CAP; p->buf = taosMemoryRealloc(p->buf, BUFFER_CAP); + if (p->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } p->left = -1; p->len = 0; @@ -126,27 +137,31 @@ int transClearBuffer(SConnBuffer* buf) { return 0; } -int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf) { +int32_t transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf) { static const int HEADSIZE = sizeof(STransMsgHead); - - SConnBuffer* p = connBuf; + int32_t code = 0; + SConnBuffer* p = connBuf; if (p->left != 0 || p->total <= 0) { - return -1; + return TSDB_CODE_INVALID_MSG; } int total = p->total; if (total >= HEADSIZE && !p->invalid) { *buf = taosMemoryCalloc(1, total); + if (*buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } memcpy(*buf, p->buf, total); - if (transResetBuffer(connBuf, resetBuf) < 0) { - return -1; + if ((code = transResetBuffer(connBuf, resetBuf)) < 0) { + return code; } } else { total = -1; + return TSDB_CODE_INVALID_MSG; } return total; } -int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) { +int32_t transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) { SConnBuffer* p = connBuf; if (p->total < p->len) { int left = p->len - p->total; @@ -162,15 +177,18 @@ int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) { if (resetBuf) { p->cap = BUFFER_CAP; p->buf = taosMemoryRealloc(p->buf, p->cap); + if (p->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } } } else { ASSERTS(0, "invalid read from sock buf"); - return -1; + return TSDB_CODE_INVALID_MSG; } return 0; } -int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { +int32_t transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { /* * formate of data buffer: * |<--------------------------data from socket------------------------------->| @@ -187,6 +205,9 @@ int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { } else { p->cap = p->left + p->len; p->buf = taosMemoryRealloc(p->buf, p->cap); + if (p->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } uvBuf->base = p->buf + p->len; uvBuf->len = p->left; } @@ -216,25 +237,25 @@ bool transReadComplete(SConnBuffer* connBuf) { int transSetConnOption(uv_tcp_t* stream, int keepalive) { #if defined(WINDOWS) || defined(DARWIN) #else - uv_tcp_keepalive(stream, 1, keepalive); + return uv_tcp_keepalive(stream, 1, keepalive); #endif return uv_tcp_nodelay(stream, 1); // int ret = uv_tcp_keepalive(stream, 5, 60); } -SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) { +int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAsyncPool** pPool) { SAsyncPool* pool = taosMemoryCalloc(1, sizeof(SAsyncPool)); if (pool == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; + // return NULL; } + int32_t code = 0; pool->nAsync = sz; pool->asyncs = taosMemoryCalloc(1, sizeof(uv_async_t) * pool->nAsync); if (pool->asyncs == NULL) { taosMemoryFree(pool); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; } int i = 0, err = 0; @@ -243,18 +264,18 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) SAsyncItem* item = taosMemoryCalloc(1, sizeof(SAsyncItem)); if (item == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; break; } item->pThrd = arg; QUEUE_INIT(&item->qmsg); - taosThreadMutexInit(&item->mtx, NULL); + (void)taosThreadMutexInit(&item->mtx, NULL); async->data = item; err = uv_async_init(loop, async, cb); if (err != 0) { tError("failed to init async, reason:%s", uv_err_name(err)); - terrno = TSDB_CODE_THIRDPARTY_ERROR; + code = TSDB_CODE_THIRDPARTY_ERROR; break; } } @@ -264,16 +285,20 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) pool = NULL; } - return pool; + *pPool = pool; + return 0; + // return pool; } void transAsyncPoolDestroy(SAsyncPool* pool) { + if (pool == NULL) return; + for (int i = 0; i < pool->nAsync; i++) { uv_async_t* async = &(pool->asyncs[i]); SAsyncItem* item = async->data; if (item == NULL) continue; - taosThreadMutexDestroy(&item->mtx); + (void)taosThreadMutexDestroy(&item->mtx); taosMemoryFree(item); } taosMemoryFree(pool->asyncs); @@ -289,7 +314,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool) { } int transAsyncSend(SAsyncPool* pool, queue* q) { if (atomic_load_8(&pool->stop) == 1) { - return -1; + return TSDB_CODE_RPC_ASYNC_MODULE_QUIT; } int idx = pool->index % pool->nAsync; @@ -300,10 +325,15 @@ int transAsyncSend(SAsyncPool* pool, queue* q) { uv_async_t* async = &(pool->asyncs[idx]); SAsyncItem* item = async->data; - taosThreadMutexLock(&item->mtx); + (void)taosThreadMutexLock(&item->mtx); QUEUE_PUSH(&item->qmsg, q); - taosThreadMutexUnlock(&item->mtx); - return uv_async_send(async); + (void)taosThreadMutexUnlock(&item->mtx); + int ret = uv_async_send(async); + if (ret != 0) { + tError("failed to send async,reason:%s", uv_err_name(ret)); + return TSDB_CODE_THIRDPARTY_ERROR; + } + return 0; } void transCtxInit(STransCtx* ctx) { @@ -347,7 +377,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) { // if (dVal) { // dst->freeFunc(dVal->val); // } - taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal)); + (void)taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal)); iter = taosHashIterate(src->args, iter); } taosHashCleanup(src->args); @@ -361,7 +391,7 @@ void* transCtxDumpVal(STransCtx* ctx, int32_t key) { return NULL; } void* ret = NULL; - (*cVal->clone)(cVal->val, &ret); + (void)(*cVal->clone)(cVal->val, &ret); return ret; } void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { @@ -369,7 +399,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { if (ctx->brokenVal.clone == NULL) { return ret; } - (*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret); + (void)(*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret); *msgType = ctx->brokenVal.msgType; @@ -408,15 +438,20 @@ void transReqQueueClear(queue* q) { } } -void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { +int32_t transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { queue->q = taosArrayInit(2, sizeof(void*)); queue->freeFunc = (void (*)(const void*))freeFunc; + + if (queue->q == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return 0; } bool transQueuePush(STransQueue* queue, void* arg) { if (queue->q == NULL) { return true; } - taosArrayPush(queue->q, &arg); + (void)taosArrayPush(queue->q, &arg); if (taosArrayGetSize(queue->q) > 1) { return false; } @@ -510,23 +545,47 @@ static void transDQTimeout(uv_timer_t* timer) { } } while (1); if (timeout != 0) { - uv_timer_start(queue->timer, transDQTimeout, timeout, 0); + (void)uv_timer_start(queue->timer, transDQTimeout, timeout, 0); } } -int transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { - uv_timer_t* timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); - uv_timer_init(loop, timer); +int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { + int32_t code = 0; + Heap* heap = NULL; + uv_timer_t* timer = NULL; + SDelayQueue* q = NULL; - Heap* heap = heapCreate(timeCompare); + timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); + if (timer == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } - SDelayQueue* q = taosMemoryCalloc(1, sizeof(SDelayQueue)); + heap = heapCreate(timeCompare); + if (heap == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _return1); + } + + q = taosMemoryCalloc(1, sizeof(SDelayQueue)); + if (q == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _return1); + } q->heap = heap; q->timer = timer; q->loop = loop; q->timer->data = q; + int err = uv_timer_init(loop, timer); + if (err != 0) { + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _return1); + } + *queue = q; return 0; + +_return1: + taosMemoryFree(timer); + heapDestroy(heap); + taosMemoryFree(q); + return TSDB_CODE_OUT_OF_MEMORY; } void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) { @@ -551,7 +610,7 @@ void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) { taosMemoryFree(queue); } void transDQCancel(SDelayQueue* queue, SDelayTask* task) { - uv_timer_stop(queue->timer); + (void)uv_timer_stop(queue->timer); if (heapSize(queue->heap) <= 0) { taosMemoryFree(task->arg); @@ -571,13 +630,17 @@ void transDQCancel(SDelayQueue* queue, SDelayTask* task) { SDelayTask* task = container_of(minNode, SDelayTask, node); uint64_t timeout = now > task->execTime ? now - task->execTime : 0; - uv_timer_start(queue->timer, transDQTimeout, timeout, 0); + (void)uv_timer_start(queue->timer, transDQTimeout, timeout, 0); } } SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs) { uint64_t now = taosGetTimestampMs(); SDelayTask* task = taosMemoryCalloc(1, sizeof(SDelayTask)); + if (task == NULL) { + return NULL; + } + task->func = func; task->arg = arg; task->execTime = now + timeoutMs; @@ -592,7 +655,7 @@ SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, tTrace("timer %p put task into delay queue, timeoutMs:%" PRIu64, queue->timer, timeoutMs); heapInsert(queue->heap, &task->node); - uv_timer_start(queue->timer, transDQTimeout, timeoutMs, 0); + (void)uv_timer_start(queue->timer, transDQTimeout, timeoutMs, 0); return task; } @@ -640,7 +703,7 @@ static void transInitEnv() { refMgt = transOpenRefMgt(50000, transDestroyExHandle); instMgt = taosOpenRef(50, rpcCloseImpl); transSyncMsgMgt = taosOpenRef(50, transDestroySyncMsg); - uv_os_setenv("UV_TCP_SINGLE_ACCEPT", "1"); + (void)uv_os_setenv("UV_TCP_SINGLE_ACCEPT", "1"); } static void transDestroyEnv() { transCloseRefMgt(refMgt); @@ -648,9 +711,13 @@ static void transDestroyEnv() { transCloseRefMgt(transSyncMsgMgt); } -void transInit() { +int32_t transInit() { // init env - taosThreadOnce(&transModuleInit, transInitEnv); + int32_t code = taosThreadOnce(&transModuleInit, transInitEnv); + if (code != 0) { + code = TAOS_SYSTEM_ERROR(errno); + } + return code; } int32_t transGetRefMgt() { return refMgt; } @@ -667,7 +734,7 @@ int32_t transOpenRefMgt(int size, void (*func)(void*)) { } void transCloseRefMgt(int32_t mgt) { // close ref - taosCloseRef(mgt); + (void)taosCloseRef(mgt); } int64_t transAddExHandle(int32_t refMgt, void* p) { // acquire extern handle @@ -702,36 +769,13 @@ void transDestroySyncMsg(void* msg) { if (msg == NULL) return; STransSyncMsg* pSyncMsg = msg; - tsem2_destroy(pSyncMsg->pSem); + (void)tsem2_destroy(pSyncMsg->pSem); taosMemoryFree(pSyncMsg->pSem); transFreeMsg(pSyncMsg->pRsp->pCont); taosMemoryFree(pSyncMsg->pRsp); taosMemoryFree(pSyncMsg); } -// void subnetIp2int(const char* const ip_addr, uint8_t* dst) { -// char ip_addr_cpy[20]; -// char ip[5]; - -// tstrncpy(ip_addr_cpy, ip_addr, sizeof(ip_addr_cpy)); - -// char *s_start, *s_end; -// s_start = ip_addr_cpy; -// s_end = ip_addr_cpy; - -// int32_t k = 0; - -// for (k = 0; *s_start != '\0'; s_start = s_end) { -// for (s_end = s_start; *s_end != '.' && *s_end != '\0'; s_end++) { -// } -// if (*s_end == '.') { -// *s_end = '\0'; -// s_end++; -// } -// dst[k++] = (char)atoi(s_start); -// } -// } - uint32_t subnetIpRang2Int(SIpV4Range* pRange) { uint32_t ip = pRange->ip; return ((ip & 0xFF) << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | ((ip >> 24) & 0xFF); @@ -778,7 +822,11 @@ int32_t transUtilSIpRangeToStr(SIpV4Range* pRange, char* buf) { struct in_addr addr; addr.s_addr = pRange->ip; - uv_inet_ntop(AF_INET, &addr, buf, 32); + int32_t err = uv_inet_ntop(AF_INET, &addr, buf, 32); + if (err != 0) { + tError("failed to convert ip to string, reason:%s", uv_strerror(err)); + return TSDB_CODE_THIRDPARTY_ERROR; + } len = strlen(buf); @@ -794,14 +842,23 @@ int32_t transUtilSWhiteListToStr(SIpWhiteList* pList, char** ppBuf) { *ppBuf = NULL; return 0; } + int32_t len = 0; char* pBuf = taosMemoryCalloc(1, pList->num * 36); + if (pBuf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } for (int i = 0; i < pList->num; i++) { SIpV4Range* pRange = &pList->pIpRange[i]; char tbuf[32] = {0}; int tlen = transUtilSIpRangeToStr(pRange, tbuf); + if (tlen < 0) { + taosMemoryFree(pBuf); + return tlen; + } + len += sprintf(pBuf + len, "%s,", tbuf); } if (len > 0) { diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 674bb86fb5..1e0d54eb5b 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -122,7 +122,7 @@ typedef struct SServerObj { SIpWhiteListTab* uvWhiteListCreate(); void uvWhiteListDestroy(SIpWhiteListTab* pWhite); -void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver); +int32_t uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver); void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable); bool uvWhiteListCheckConn(SIpWhiteListTab* pWhite, SSvrConn* pConn); bool uvWhiteListFilte(SIpWhiteListTab* pWhite, char* user, uint32_t ip, int64_t ver); @@ -164,7 +164,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd); static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear /*clear handle or not*/); static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn); -static int reallocConnRef(SSvrConn* conn); +static int32_t reallocConnRef(SSvrConn* conn); static void uvHandleQuit(SSvrMsg* msg, SWorkThrd* thrd); static void uvHandleRelease(SSvrMsg* msg, SWorkThrd* thrd); @@ -181,14 +181,14 @@ static void* transWorkerThread(void* arg); static void* transAcceptThread(void* arg); // add handle loop -static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName); -static bool addHandleToAcceptloop(void* arg); +static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName); +static int32_t addHandleToAcceptloop(void* arg); -#define SRV_RELEASE_UV(loop) \ - do { \ - uv_walk(loop, uvWalkCb, NULL); \ - uv_run(loop, UV_RUN_DEFAULT); \ - uv_loop_close(loop); \ +#define SRV_RELEASE_UV(loop) \ + do { \ + (void)uv_walk(loop, uvWalkCb, NULL); \ + (void)uv_run(loop, UV_RUN_DEFAULT); \ + (void)uv_loop_close(loop); \ } while (0); #define ASYNC_ERR_JRET(thrd) \ @@ -202,7 +202,11 @@ static bool addHandleToAcceptloop(void* arg); void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SSvrConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; - transAllocBuffer(pBuf, buf); + int32_t code = transAllocBuffer(pBuf, buf); + if (code < 0) { + tError("conn %p failed to alloc buffer, since %s", conn, tstrerror(code)); + // destroyConn(conn, true); + } } // refers specifically to query or insert timeout @@ -221,8 +225,16 @@ static bool uvCheckIp(SIpV4Range* pRange, int32_t ip) { } SIpWhiteListTab* uvWhiteListCreate() { SIpWhiteListTab* pWhiteList = taosMemoryCalloc(1, sizeof(SIpWhiteListTab)); + if (pWhiteList == NULL) { + return NULL; + } pWhiteList->pList = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 0, HASH_NO_LOCK); + if (pWhiteList->pList == NULL) { + taosMemoryFree(pWhiteList); + return NULL; + } + pWhiteList->ver = -1; return pWhiteList; } @@ -240,17 +252,26 @@ void uvWhiteListDestroy(SIpWhiteListTab* pWhite) { taosMemoryFree(pWhite); } -void uvWhiteListToStr(SWhiteUserList* plist, char* user, char** ppBuf) { +int32_t uvWhiteListToStr(SWhiteUserList* plist, char* user, char** ppBuf) { char* tmp = NULL; int32_t tlen = transUtilSWhiteListToStr(plist->pList, &tmp); + if (tlen < 0) { + return tlen; + } + + char* pBuf = taosMemoryCalloc(1, tlen + 64); + if (pBuf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } - char* pBuf = taosMemoryCalloc(1, tlen + 64); int32_t len = sprintf(pBuf, "user: %s, ver: %" PRId64 ", ip: {%s}", user, plist->ver, tmp); taosMemoryFree(tmp); *ppBuf = pBuf; + return len; } void uvWhiteListDebug(SIpWhiteListTab* pWrite) { + int32_t code = 0; SHashObj* pWhiteList = pWrite->pList; void* pIter = taosHashIterate(pWhiteList, NULL); while (pIter) { @@ -262,23 +283,35 @@ void uvWhiteListDebug(SIpWhiteListTab* pWrite) { SWhiteUserList* pUserList = *(SWhiteUserList**)pIter; char* buf = NULL; - uvWhiteListToStr(pUserList, user, &buf); - tDebug("ip-white-list %s", buf); + + code = uvWhiteListToStr(pUserList, user, &buf); + if (code != 0) { + tDebug("ip-white-list failed to debug to str since %s", buf); + } taosMemoryFree(buf); pIter = taosHashIterate(pWhiteList, pIter); } } -void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, int64_t ver) { +int32_t uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, int64_t ver) { + int32_t code = 0; SHashObj* pWhiteList = pWhite->pList; SWhiteUserList** ppUserList = taosHashGet(pWhiteList, user, strlen(user)); if (ppUserList == NULL || *ppUserList == NULL) { SWhiteUserList* pUserList = taosMemoryCalloc(1, sizeof(SWhiteUserList)); + if (pUserList == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pUserList->ver = ver; pUserList->pList = plist; - taosHashPut(pWhiteList, user, strlen(user), &pUserList, sizeof(void*)); + code = taosHashPut(pWhiteList, user, strlen(user), &pUserList, sizeof(void*)); + if (code != 0) { + taosMemoryFree(pUserList); + return code; + } } else { SWhiteUserList* pUserList = *ppUserList; @@ -287,6 +320,7 @@ void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, in pUserList->pList = plist; } uvWhiteListDebug(pWhite); + return 0; } void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable) { @@ -450,7 +484,7 @@ static bool uvHandleReq(SSvrConn* pConn) { pConnInfo->clientPort = pConn->port; tstrncpy(pConnInfo->user, pConn->user, sizeof(pConnInfo->user)); - transReleaseExHandle(transGetRefMgt(), pConn->refId); + (void)transReleaseExHandle(transGetRefMgt(), pConn->refId); (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); return true; @@ -544,7 +578,7 @@ void uvOnSendCb(uv_write_t* req, int status) { (pTransInst->cfp)(pTransInst->parent, &(conn->regArg.msg), NULL); memset(&conn->regArg, 0, sizeof(conn->regArg)); } - transQueuePop(&conn->srvMsgs); + (void)transQueuePop(&conn->srvMsgs); taosMemoryFree(msg); msg = (SSvrMsg*)transQueueGet(&conn->srvMsgs, 0); @@ -584,6 +618,10 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { STransMsg* pMsg = &smsg->msg; if (pMsg->pCont == 0) { pMsg->pCont = (void*)rpcMallocCont(0); + if (pMsg->pCont == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pMsg->contLen = 0; } STransMsgHead* pHead = transHeadFromCont(pMsg->pCont); @@ -596,9 +634,9 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { // handle invalid drop_task resp, TD-20098 if (pConn->inType == TDMT_SCH_DROP_TASK && pMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) { - transQueuePop(&pConn->srvMsgs); + (void)transQueuePop(&pConn->srvMsgs); destroySmsg(smsg); - return -1; + return TSDB_CODE_INVALID_MSG; } if (pConn->status == ConnNormal) { @@ -652,7 +690,7 @@ static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) { transRefSrvHandle(pConn); uv_write_t* req = transReqQueuePush(&pConn->wreqQueue); - uv_write(req, (uv_stream_t*)pConn->pTcp, &wb, 1, uvOnSendCb); + (void)uv_write(req, (uv_stream_t*)pConn->pTcp, &wb, 1, uvOnSendCb); } static void uvStartSendResp(SSvrMsg* smsg) { // impl @@ -704,9 +742,9 @@ void uvWorkerAsyncCb(uv_async_t* handle) { queue wq; // batch process to avoid to lock/unlock frequently - taosThreadMutexLock(&item->mtx); + (void)taosThreadMutexLock(&item->mtx); QUEUE_MOVE(&item->qmsg, &wq); - taosThreadMutexUnlock(&item->mtx); + (void)taosThreadMutexUnlock(&item->mtx); while (!QUEUE_IS_EMPTY(&wq)) { queue* head = QUEUE_HEAD(&wq); @@ -729,12 +767,12 @@ void uvWorkerAsyncCb(uv_async_t* handle) { SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), refId); if (exh2 == NULL || exh1 != exh2) { tTrace("handle except msg %p, ignore it", exh1); - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); destroySmsg(msg); continue; } msg->pConn = exh1->handle; - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); (*transAsyncHandle[msg->type])(msg, pThrd); } } @@ -764,11 +802,15 @@ static void uvShutDownCb(uv_shutdown_t* req, int status) { } static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) { if ((pHead)->release == 1 && (pHead->msgLen) == sizeof(*pHead)) { - reallocConnRef(pConn); + int32_t code = reallocConnRef(pConn); + if (code != 0) { + destroyConn(pConn, true); + return true; + } tTrace("conn %p received release request", pConn); STraceId traceId = pHead->traceId; - transClearBuffer(&pConn->readBuf); + (void)transClearBuffer(&pConn->readBuf); transFreeMsg(transContFromHead((char*)pHead)); if (pConn->status != ConnAcquire) { return true; @@ -804,9 +846,9 @@ static void uvPrepareCb(uv_prepare_t* handle) { SAsyncItem* item = async->data; queue wq; - taosThreadMutexLock(&item->mtx); + (void)taosThreadMutexLock(&item->mtx); QUEUE_MOVE(&item->qmsg, &wq); - taosThreadMutexUnlock(&item->mtx); + (void)taosThreadMutexUnlock(&item->mtx); while (!QUEUE_IS_EMPTY(&wq)) { queue* head = QUEUE_HEAD(&wq); @@ -829,12 +871,12 @@ static void uvPrepareCb(uv_prepare_t* handle) { SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), refId); if (exh2 == NULL || exh1 != exh2) { tTrace("handle except msg %p, ignore it", exh1); - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); destroySmsg(msg); continue; } msg->pConn = exh1->handle; - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); (*transAsyncHandle[msg->type])(msg, pThrd); } } @@ -893,7 +935,7 @@ void uvOnAcceptCb(uv_stream_t* stream, int status) { tTrace("new connection accepted by main server, dispatch to %dth worker-thread", pObj->workerIdx); - uv_write2(wr, (uv_stream_t*)&(pObj->pipe[pObj->workerIdx][0]), &buf, 1, (uv_stream_t*)cli, uvOnPipeWriteCb); + (void)uv_write2(wr, (uv_stream_t*)&(pObj->pipe[pObj->workerIdx][0]), &buf, 1, (uv_stream_t*)cli, uvOnPipeWriteCb); } else { if (!uv_is_closing((uv_handle_t*)cli)) { tError("failed to accept tcp: %s", uv_err_name(err)); @@ -935,27 +977,25 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { return; } - // uv_handle_type pending = uv_pipe_pending_type(pipe); - SSvrConn* pConn = createConn(pThrd); + if (pConn == NULL) { + uv_close((uv_handle_t*)q, NULL); + return; + } - pConn->pTransInst = pThrd->pTransInst; - /* init conn timer*/ - // uv_timer_init(pThrd->loop, &pConn->pTimer); - // pConn->pTimer.data = pConn; - - pConn->hostThrd = pThrd; - - // init client handle - pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); - uv_tcp_init(pThrd->loop, pConn->pTcp); - pConn->pTcp->data = pConn; - - // transSetConnOption((uv_tcp_t*)pConn->pTcp); + // pConn->pTransInst = pThrd->pTransInst; + // /* init conn timer*/ + // // uv_timer_init(pThrd->loop, &pConn->pTimer); + // // pConn->pTimer.data = pConn; + // pConn->hostThrd = pThrd; + // // init client handle + // pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); + // uv_tcp_init(pThrd->loop, pConn->pTcp); + // pConn->pTcp->data = pConn; if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) { uv_os_fd_t fd; - uv_fileno((const uv_handle_t*)pConn->pTcp, &fd); + (void)uv_fileno((const uv_handle_t*)pConn->pTcp, &fd); tTrace("conn %p created, fd:%d", pConn, fd); struct sockaddr peername, sockname; @@ -965,7 +1005,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { transUnrefSrvHandle(pConn); return; } - transSockInfo2Str(&peername, pConn->dst); + (void)transSockInfo2Str(&peername, pConn->dst); addrlen = sizeof(sockname); if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&sockname, &addrlen)) { @@ -973,7 +1013,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { transUnrefSrvHandle(pConn); return; } - transSockInfo2Str(&sockname, pConn->src); + (void)transSockInfo2Str(&sockname, pConn->src); struct sockaddr_in addr = *(struct sockaddr_in*)&peername; struct sockaddr_in saddr = *(struct sockaddr_in*)&sockname; @@ -982,7 +1022,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { pConn->serverIp = saddr.sin_addr.s_addr; pConn->port = ntohs(addr.sin_port); - uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb); + (void)uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb); } else { tDebug("failed to create new connection"); @@ -994,7 +1034,7 @@ void* transAcceptThread(void* arg) { // opt setThreadName("trans-accept"); SServerObj* srv = (SServerObj*)arg; - uv_run(srv->loop, UV_RUN_DEFAULT); + (void)uv_run(srv->loop, UV_RUN_DEFAULT); return NULL; } @@ -1003,19 +1043,38 @@ void uvOnPipeConnectionCb(uv_connect_t* connect, int status) { return; } SWorkThrd* pThrd = container_of(connect, SWorkThrd, connect_req); - uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); + (void)uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); } -static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { +static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { + int32_t code = 0; pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); - if (0 != uv_loop_init(pThrd->loop)) { - return false; + if (pThrd->loop == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + if ((code = uv_loop_init(pThrd->loop)) != 0) { + tError("failed to init loop since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } #if defined(WINDOWS) || defined(DARWIN) - uv_pipe_init(pThrd->loop, pThrd->pipe, 1); + code = uv_pipe_init(pThrd->loop, pThrd->pipe, 1); + if (code != 0) { + tError("failed to init pip since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } #else - uv_pipe_init(pThrd->loop, pThrd->pipe, 1); - uv_pipe_open(pThrd->pipe, pThrd->fd); + code = uv_pipe_init(pThrd->loop, pThrd->pipe, 1); + if (code != 0) { + tError("failed to init pip since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } + + code = uv_pipe_open(pThrd->pipe, pThrd->fd); + if (code != 0) { + tError("failed to open pip since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } #endif pThrd->pipe->data = pThrd; @@ -1023,88 +1082,173 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { QUEUE_INIT(&pThrd->msg); pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); - uv_prepare_init(pThrd->loop, pThrd->prepare); - uv_prepare_start(pThrd->prepare, uvPrepareCb); + if (pThrd->prepare == NULL) { + tError("failed to init prepare"); + return TSDB_CODE_OUT_OF_MEMORY; + } + + code = uv_prepare_init(pThrd->loop, pThrd->prepare); + if (code != 0) { + tError("failed to init prepare since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } + + code = uv_prepare_start(pThrd->prepare, uvPrepareCb); + if (code != 0) { + tError("failed to start prepare since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } pThrd->prepare->data = pThrd; // conn set QUEUE_INIT(&pThrd->conn); - pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 8, pThrd, uvWorkerAsyncCb); + code = transAsyncPoolCreate(pThrd->loop, 8, pThrd, uvWorkerAsyncCb, &pThrd->asyncPool); + if (code != 0) { + tError("failed to init async pool since:%s", tstrerror(code)); + return code; + } #if defined(WINDOWS) || defined(DARWIN) uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb); + #else - uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); + code = uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); + if (code != 0) { + tError("failed to start read pipe:%s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } #endif - return true; + return 0; } -static bool addHandleToAcceptloop(void* arg) { +static int32_t addHandleToAcceptloop(void* arg) { // impl later SServerObj* srv = arg; - int err = 0; - if ((err = uv_tcp_init(srv->loop, &srv->server)) != 0) { - tError("failed to init accept server:%s", uv_err_name(err)); - return false; + int code = 0; + if ((code = uv_tcp_init(srv->loop, &srv->server)) != 0) { + tError("failed to init accept server since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } // register an async here to quit server gracefully srv->pAcceptAsync = taosMemoryCalloc(1, sizeof(uv_async_t)); - uv_async_init(srv->loop, srv->pAcceptAsync, uvAcceptAsyncCb); + if (srv->pAcceptAsync == NULL) { + tError("failed to create async since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + return TSDB_CODE_OUT_OF_MEMORY; + } + + code = uv_async_init(srv->loop, srv->pAcceptAsync, uvAcceptAsyncCb); + if (code != 0) { + tError("failed to init async since:%s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } srv->pAcceptAsync->data = srv; struct sockaddr_in bind_addr; - uv_ip4_addr("0.0.0.0", srv->port, &bind_addr); - if ((err = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) { - tError("failed to bind:%s", uv_err_name(err)); - return false; + if ((code = uv_ip4_addr("0.0.0.0", srv->port, &bind_addr)) != 0) { + tError("failed to bind addr since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } - if ((err = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) { - tError("failed to listen:%s", uv_err_name(err)); - terrno = TSDB_CODE_RPC_PORT_EADDRINUSE; - return false; + + if ((code = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) { + tError("failed to bind since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } - return true; + if ((code = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) { + tError("failed to listen since %s", uv_err_name(code)); + return TSDB_CODE_RPC_PORT_EADDRINUSE; + } + return 0; } + void* transWorkerThread(void* arg) { setThreadName("trans-svr-work"); SWorkThrd* pThrd = (SWorkThrd*)arg; - uv_run(pThrd->loop, UV_RUN_DEFAULT); + (void)uv_run(pThrd->loop, UV_RUN_DEFAULT); return NULL; } static FORCE_INLINE SSvrConn* createConn(void* hThrd) { + int32_t code = 0; SWorkThrd* pThrd = hThrd; SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn)); + if (pConn == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } transReqQueueInit(&pConn->wreqQueue); QUEUE_INIT(&pConn->queue); - QUEUE_PUSH(&pThrd->conn, &pConn->queue); - transQueueInit(&pConn->srvMsgs, NULL); + if ((code = transQueueInit(&pConn->srvMsgs, NULL)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } + + if ((code = transInitBuffer(&pConn->readBuf)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } memset(&pConn->regArg, 0, sizeof(pConn->regArg)); pConn->broken = false; pConn->status = ConnNormal; - transInitBuffer(&pConn->readBuf); SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); + if (exh == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + exh->handle = pConn; exh->pThrd = pThrd; exh->refId = transAddExHandle(transGetRefMgt(), exh); + if (exh->refId < 0) { + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); + } + QUEUE_INIT(&exh->q); - transAcquireExHandle(transGetRefMgt(), exh->refId); + + SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId); + if (pSelf != exh) { + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); + } STrans* pTransInst = pThrd->pTransInst; pConn->refId = exh->refId; QUEUE_INIT(&exh->q); transRefSrvHandle(pConn); tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pTransInst), exh, pConn, pConn->refId); + + pConn->pTransInst = pThrd->pTransInst; + /* init conn timer*/ + // uv_timer_init(pThrd->loop, &pConn->pTimer); + // pConn->pTimer.data = pConn; + pConn->hostThrd = pThrd; + // init client handle + pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); + if (pConn->pTcp == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + + code = uv_tcp_init(pThrd->loop, pConn->pTcp); + if (code != 0) { + tError("%s failed to create conn since %s" PRId64, transLabel(pTransInst), uv_strerror(code)); + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end); + } + pConn->pTcp->data = pConn; + return pConn; +_end: + if (pConn) { + transQueueDestroy(&pConn->srvMsgs); + (void)transDestroyBuffer(&pConn->readBuf); + taosMemoryFree(pConn->pTcp); + taosMemoryFree(pConn); + pConn = NULL; + } + tError("%s failed to create conn since %s" PRId64, transLabel(pTransInst), tstrerror(code)); + return NULL; } static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear) { @@ -1125,16 +1269,33 @@ static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) { conn->regArg.init = 0; } } -static int reallocConnRef(SSvrConn* conn) { - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); +static int32_t reallocConnRef(SSvrConn* conn) { + if (conn->refId > 0) { + (void)transReleaseExHandle(transGetRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetRefMgt(), conn->refId); + } // avoid app continue to send msg on invalid handle SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); + if (exh == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + exh->handle = conn; exh->pThrd = conn->hostThrd; exh->refId = transAddExHandle(transGetRefMgt(), exh); + if (exh->refId < 0) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + QUEUE_INIT(&exh->q); - transAcquireExHandle(transGetRefMgt(), exh->refId); + SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId); + if (pSelf != exh) { + tError("conn %p failed to acquire handle", conn); + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + conn->refId = exh->refId; return 0; @@ -1147,8 +1308,8 @@ static void uvDestroyConn(uv_handle_t* handle) { } SWorkThrd* thrd = conn->hostThrd; - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetRefMgt(), conn->refId); STrans* pTransInst = thrd->pTransInst; tDebug("%s conn %p destroy", transLabel(pTransInst), conn); @@ -1163,7 +1324,7 @@ static void uvDestroyConn(uv_handle_t* handle) { QUEUE_REMOVE(&conn->queue); taosMemoryFree(conn->pTcp); destroyConnRegArg(conn); - transDestroyBuffer(&conn->readBuf); + (void)transDestroyBuffer(&conn->readBuf); taosMemoryFree(conn); if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) { @@ -1204,24 +1365,41 @@ static void uvPipeListenCb(uv_stream_t* handle, int status) { } void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { + int32_t code = 0; + SServerObj* srv = taosMemoryCalloc(1, sizeof(SServerObj)); - srv->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); + if (srv == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + tError("failed to init server since: %s", tstrerror(code)); + return NULL; + } + + srv->ip = ip; + srv->port = port; srv->numOfThreads = numOfThreads; srv->workerIdx = 0; srv->numOfWorkerReady = 0; + srv->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); srv->pThreadObj = (SWorkThrd**)taosMemoryCalloc(srv->numOfThreads, sizeof(SWorkThrd*)); srv->pipe = (uv_pipe_t**)taosMemoryCalloc(srv->numOfThreads, sizeof(uv_pipe_t*)); - srv->ip = ip; - srv->port = port; - uv_loop_init(srv->loop); + if (srv->loop == NULL || srv->pThreadObj == NULL || srv->pipe == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto End; + } - char pipeName[PATH_MAX]; + code = uv_loop_init(srv->loop); + if (code != 0) { + tError("failed to init server since: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } if (false == taosValidIpAndPort(srv->ip, srv->port)) { - terrno = TAOS_SYSTEM_ERROR(errno); + code = TAOS_SYSTEM_ERROR(errno); tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr()); goto End; } + char pipeName[PATH_MAX]; #if defined(WINDOWS) || defined(DARWIN) int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0); @@ -1259,7 +1437,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); thrd->pipe = &(srv->pipe[i][1]); // init read - if (false == addHandleToWorkloop(thrd, pipeName)) { + if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) { goto End; } @@ -1276,27 +1454,53 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, for (int i = 0; i < srv->numOfThreads; i++) { SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd)); + if (thrd == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto End; + } thrd->pTransInst = shandle; thrd->quit = false; thrd->pTransInst = shandle; thrd->pWhiteList = uvWhiteListCreate(); - - srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); - srv->pThreadObj[i] = thrd; - - uv_os_sock_t fds[2]; - if (uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE) != 0) { + if (thrd->pWhiteList == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; goto End; } - uv_pipe_init(srv->loop, &(srv->pipe[i][0]), 1); - uv_pipe_open(&(srv->pipe[i][0]), fds[1]); + srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); + if (srv->pipe[i] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto End; + } + + srv->pThreadObj[i] = thrd; + + uv_os_sock_t fds[2]; + if ((code = uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)) != 0) { + tError("failed to create pipe, errmsg: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } + + code = uv_pipe_init(srv->loop, &(srv->pipe[i][0]), 1); + if (code != 0) { + tError("failed to init pipe, errmsg: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } + + code = uv_pipe_open(&(srv->pipe[i][0]), fds[1]); + if (code != 0) { + tError("failed to init pipe, errmsg: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } thrd->pipe = &(srv->pipe[i][1]); // init read thrd->fd = fds[0]; - if (false == addHandleToWorkloop(thrd, pipeName)) { + if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) { goto End; } @@ -1311,15 +1515,17 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, } #endif - if (false == addHandleToAcceptloop(srv)) { + if ((code = addHandleToAcceptloop(srv)) != 0) { goto End; } - int err = taosThreadCreate(&srv->thread, NULL, transAcceptThread, (void*)srv); - if (err == 0) { + code = taosThreadCreate(&srv->thread, NULL, transAcceptThread, (void*)srv); + if (code == 0) { tDebug("success to create accept-thread"); } else { - tError("failed to create accept-thread"); + code = TAOS_SYSTEM_ERROR(errno); + tError("failed to create accept-thread since %s", tstrerror(code)); + goto End; // clear all resource later } @@ -1328,6 +1534,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, return srv; End: transCloseServer(srv); + terrno = code; return NULL; } @@ -1341,9 +1548,14 @@ void uvHandleQuit(SSvrMsg* msg, SWorkThrd* thrd) { taosMemoryFree(msg); } void uvHandleRelease(SSvrMsg* msg, SWorkThrd* thrd) { + int32_t code = 0; SSvrConn* conn = msg->pConn; if (conn->status == ConnAcquire) { - reallocConnRef(conn); + code = reallocConnRef(conn); + if (code != 0) { + destroyConn(conn, true); + return; + } if (!transQueuePush(&conn->srvMsgs, msg)) { return; } @@ -1366,7 +1578,7 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd) { if (!transQueuePush(&conn->srvMsgs, msg)) { return; } - transQueuePop(&conn->srvMsgs); + (void)transQueuePop(&conn->srvMsgs); if (conn->regArg.init) { transFreeMsg(conn->regArg.msg.pCont); @@ -1387,35 +1599,48 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd) { } void uvHandleUpdate(SSvrMsg* msg, SWorkThrd* thrd) { SUpdateIpWhite* req = msg->arg; - if (req != NULL) { - for (int i = 0; i < req->numOfUser; i++) { - SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i]; - - int32_t sz = pUser->numOfRange * sizeof(SIpV4Range); - SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList)); - pList->num = pUser->numOfRange; - - memcpy(pList->pIpRange, pUser->pIpRanges, sz); - uvWhiteListAdd(thrd->pWhiteList, pUser->user, pList, pUser->ver); - } - - thrd->pWhiteList->ver = req->ver; - thrd->enableIpWhiteList = 1; - - tFreeSUpdateIpWhiteReq(req); - taosMemoryFree(req); - } else { + if (req == NULL) { tDebug("ip-white-list disable on trans"); thrd->enableIpWhiteList = 0; + taosMemoryFree(msg); + return; } + int32_t code = 0; + for (int i = 0; i < req->numOfUser; i++) { + SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i]; + + int32_t sz = pUser->numOfRange * sizeof(SIpV4Range); + + SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList)); + if (pList == NULL) { + tError("failed to create ip-white-list since %s", tstrerror(code)); + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pList->num = pUser->numOfRange; + memcpy(pList->pIpRange, pUser->pIpRanges, sz); + code = uvWhiteListAdd(thrd->pWhiteList, pUser->user, pList, pUser->ver); + if (code != 0) { + break; + } + } + + if (code == 0) { + thrd->pWhiteList->ver = req->ver; + thrd->enableIpWhiteList = 1; + } else { + tError("failed to update ip-white-list since %s", tstrerror(code)); + } + tFreeSUpdateIpWhiteReq(req); + taosMemoryFree(req); taosMemoryFree(msg); - return; } + void destroyWorkThrd(SWorkThrd* pThrd) { if (pThrd == NULL) { return; } - taosThreadJoin(pThrd->thread, NULL); + (void)taosThreadJoin(pThrd->thread, NULL); SRV_RELEASE_UV(pThrd->loop); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SSvrMsg, destroySmsgWrapper, NULL); transAsyncPoolDestroy(pThrd->asyncPool); @@ -1430,7 +1655,7 @@ void sendQuitToWorkThrd(SWorkThrd* pThrd) { SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); msg->type = Quit; tDebug("server send quit msg to work thread"); - transAsyncSend(pThrd->asyncPool, &msg->q); + (void)transAsyncSend(pThrd->asyncPool, &msg->q); } void transCloseServer(void* arg) { @@ -1439,8 +1664,8 @@ void transCloseServer(void* arg) { if (srv->inited) { tDebug("send quit msg to accept thread"); - uv_async_send(srv->pAcceptAsync); - taosThreadJoin(srv->thread, NULL); + (void)uv_async_send(srv->pAcceptAsync); + (void)taosThreadJoin(srv->thread, NULL); SRV_RELEASE_UV(srv->loop); for (int i = 0; i < srv->numOfThreads; i++) { @@ -1448,7 +1673,7 @@ void transCloseServer(void* arg) { destroyWorkThrd(srv->pThreadObj[i]); } } else { - uv_loop_close(srv->loop); + (void)uv_loop_close(srv->loop); } taosMemoryFree(srv->pThreadObj); @@ -1483,6 +1708,7 @@ void transUnrefSrvHandle(void* handle) { } int transReleaseSrvHandle(void* handle) { + int32_t code = 0; SRpcHandleInfo* info = handle; SExHandle* exh = info->handle; int64_t refId = info->refId; @@ -1495,26 +1721,35 @@ int transReleaseSrvHandle(void* handle) { STransMsg tmsg = {.code = 0, .info.handle = exh, .info.ahandle = NULL, .info.refId = refId}; SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (m == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _return1; + } + m->msg = tmsg; m->type = Release; tDebug("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); - if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); + (void)transReleaseExHandle(transGetRefMgt(), refId); + return code; } - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); return 0; _return1: tDebug("handle %p failed to send to release handle", exh); - transReleaseExHandle(transGetRefMgt(), refId); - return -1; + (void)transReleaseExHandle(transGetRefMgt(), refId); + return code; _return2: tDebug("handle %p failed to send to release handle", exh); - return -1; + return code; } int transSendResponse(const STransMsg* msg) { + int32_t code = 0; + if (msg->info.noResp) { rpcFreeCont(msg->pCont); tTrace("no need send resp"); @@ -1536,29 +1771,38 @@ int transSendResponse(const STransMsg* msg) { ASYNC_ERR_JRET(pThrd); SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (m == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _return1; + } + m->msg = tmsg; m->type = Normal; STraceId* trace = (STraceId*)&msg->info.traceId; tGDebug("conn %p start to send resp (1/2)", exh->handle); - if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); + (void)transReleaseExHandle(transGetRefMgt(), refId); + return code; } - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); return 0; _return1: tDebug("handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); - transReleaseExHandle(transGetRefMgt(), refId); - return -1; + (void)transReleaseExHandle(transGetRefMgt(), refId); + return code; _return2: tDebug("handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); - return -1; + return code; } int transRegisterMsg(const STransMsg* msg) { + int32_t code = 0; + SExHandle* exh = msg->info.handle; int64_t refId = msg->info.refId; ASYNC_CHECK_HANDLE(exh, refId); @@ -1572,45 +1816,79 @@ int transRegisterMsg(const STransMsg* msg) { ASYNC_ERR_JRET(pThrd); SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (m == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _return1; + } + m->msg = tmsg; m->type = Register; STrans* pTransInst = pThrd->pTransInst; tDebug("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle); - if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); + (void)transReleaseExHandle(transGetRefMgt(), refId); + return code; } - transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetRefMgt(), refId); return 0; _return1: tDebug("handle %p failed to register brokenlink", exh); rpcFreeCont(msg->pCont); - transReleaseExHandle(transGetRefMgt(), refId); - return -1; + (void)transReleaseExHandle(transGetRefMgt(), refId); + return code; _return2: tDebug("handle %p failed to register brokenlink", exh); rpcFreeCont(msg->pCont); - return -1; + return code; } -void transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) { + +int32_t transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) { STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)thandle); + if (pTransInst == NULL) { + return TSDB_CODE_RPC_MODULE_QUIT; + } + + int32_t code = 0; tDebug("ip-white-list update on rpc"); SServerObj* svrObj = pTransInst->tcphandle; for (int i = 0; i < svrObj->numOfThreads; i++) { SWorkThrd* pThrd = svrObj->pThreadObj[i]; - SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); - SUpdateIpWhite* pReq = (arg != NULL ? cloneSUpdateIpWhiteReq((SUpdateIpWhite*)arg) : NULL); + SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (msg == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + + SUpdateIpWhite* pReq = NULL; + code = cloneSUpdateIpWhiteReq((SUpdateIpWhite*)arg, &pReq); + if (code != 0) { + taosMemoryFree(msg); + break; + } msg->type = Update; msg->arg = pReq; - transAsyncSend(pThrd->asyncPool, &msg->q); + if ((code = transAsyncSend(pThrd->asyncPool, &msg->q)) != 0) { + code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); + tFreeSUpdateIpWhiteReq(pReq); + taosMemoryFree(pReq); + taosMemoryFree(msg); + break; + } } - transReleaseExHandle(transGetInstMgt(), (int64_t)thandle); + (void)transReleaseExHandle(transGetInstMgt(), (int64_t)thandle); + + if (code != 0) { + tError("ip-white-list update failed since %s", tstrerror(code)); + } + return code; } int transGetConnInfo(void* thandle, STransHandleInfo* pConnInfo) { return -1; } diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 1b0deb1819..f9ae6c2157 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -941,7 +941,7 @@ int32_t taosBlockSIGPIPE() { #endif } -int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { +int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t *ip) { #ifdef WINDOWS // Initialize Winsock WSADATA wsaData; @@ -959,8 +959,8 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { hints.ai_socktype = SOCK_STREAM; struct addrinfo *result = NULL; - bool inRetry = false; - + bool inRetry = false; + while (true) { int32_t ret = getaddrinfo(fqdn, NULL, &hints, &result); if (ret) { @@ -972,7 +972,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { return terrno; } - terrno = TAOS_SYSTEM_ERROR(ret); + terrno = TAOS_SYSTEM_ERROR(errno); return terrno; } @@ -1011,7 +1011,7 @@ int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip) { #else // printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret)); #endif - + *ip = 0xFFFFFFFF; return 0xFFFFFFFF; } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 660b757bb2..e0d38df5c8 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -293,7 +293,7 @@ void taosArrayRemove(SArray* pArray, size_t index) { ASSERT(index < pArray->size); if (index == pArray->size - 1) { - taosArrayPop(pArray); + (void)taosArrayPop(pArray); return; } diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index 0d9352190b..c150ca3fbd 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -110,7 +110,7 @@ typedef struct SCacheObjTravSup { static FORCE_INLINE void __trashcan_wr_lock(SCacheObj *pCacheObj) { #if defined(LINUX) - taosThreadRwlockWrlock(&pCacheObj->lock); + (void)taosThreadRwlockWrlock(&pCacheObj->lock); #else (void)taosThreadMutexLock(&pCacheObj->lock); #endif @@ -118,7 +118,7 @@ static FORCE_INLINE void __trashcan_wr_lock(SCacheObj *pCacheObj) { static FORCE_INLINE void __trashcan_unlock(SCacheObj *pCacheObj) { #if defined(LINUX) - taosThreadRwlockUnlock(&pCacheObj->lock); + (void)taosThreadRwlockUnlock(&pCacheObj->lock); #else (void)taosThreadMutexUnlock(&pCacheObj->lock); #endif @@ -134,9 +134,9 @@ static FORCE_INLINE int32_t __trashcan_lock_init(SCacheObj *pCacheObj) { static FORCE_INLINE void __trashcan_lock_destroy(SCacheObj *pCacheObj) { #if defined(LINUX) - taosThreadRwlockDestroy(&pCacheObj->lock); + (void)taosThreadRwlockDestroy(&pCacheObj->lock); #else - taosThreadMutexDestroy(&pCacheObj->lock); + (void)taosThreadMutexDestroy(&pCacheObj->lock); #endif } @@ -155,18 +155,18 @@ static void *taosCacheTimedRefresh(void *handle); static void doInitRefreshThread(void) { pCacheArrayList = taosArrayInit(4, POINTER_BYTES); - taosThreadMutexInit(&guard, NULL); + (void)taosThreadMutexInit(&guard, NULL); TdThreadAttr thattr; - taosThreadAttrInit(&thattr); - taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thattr); + (void)taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); - taosThreadCreate(&cacheRefreshWorker, &thattr, taosCacheTimedRefresh, NULL); - taosThreadAttrDestroy(&thattr); + (void)taosThreadCreate(&cacheRefreshWorker, &thattr, taosCacheTimedRefresh, NULL); + (void)taosThreadAttrDestroy(&thattr); } TdThread doRegisterCacheObj(SCacheObj *pCacheObj) { - taosThreadOnce(&cacheThreadInit, doInitRefreshThread); + (void)taosThreadOnce(&cacheThreadInit, doInitRefreshThread); (void)taosThreadMutexLock(&guard); (void)taosArrayPush(pCacheArrayList, &pCacheObj); @@ -215,7 +215,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheNode * return; } - atomic_sub_fetch_64(&pCacheObj->sizeInBytes, pNode->size); + (void)atomic_sub_fetch_64(&pCacheObj->sizeInBytes, pNode->size); uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, total num:%d size:%" PRId64 "bytes", pCacheObj->name, pNode->key, pNode->data, pNode->size, (int)pCacheObj->numOfElems - 1, pCacheObj->sizeInBytes); @@ -388,7 +388,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInMs, bool extendLi } pCacheObj->name = taosStrdup(cacheName); - doRegisterCacheObj(pCacheObj); + (void)doRegisterCacheObj(pCacheObj); return pCacheObj; } @@ -416,8 +416,8 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v if (pNode == NULL) { pushfrontNodeInEntryList(pe, pNode1); - atomic_add_fetch_ptr(&pCacheObj->numOfElems, 1); - atomic_add_fetch_ptr(&pCacheObj->sizeInBytes, pNode1->size); + (void)atomic_add_fetch_ptr(&pCacheObj->numOfElems, 1); + (void)atomic_add_fetch_ptr(&pCacheObj->sizeInBytes, pNode1->size); uDebug("cache:%s, key:%p, %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", totalNum:%d sizeInBytes:%" PRId64 "bytes size:%" PRId64 "bytes", pCacheObj->name, key, pNode1->data, pNode1->addedTime, pNode1->expireTime, (int32_t)pCacheObj->numOfElems, @@ -431,7 +431,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v pCacheObj->freeFp(pNode->data); } - atomic_sub_fetch_64(&pCacheObj->sizeInBytes, pNode->size); + (void)atomic_sub_fetch_64(&pCacheObj->sizeInBytes, pNode->size); taosMemoryFreeClear(pNode); } else { taosAddToTrashcan(pCacheObj, pNode); @@ -439,7 +439,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v } pushfrontNodeInEntryList(pe, pNode1); - atomic_add_fetch_64(&pCacheObj->sizeInBytes, pNode1->size); + (void)atomic_add_fetch_64(&pCacheObj->sizeInBytes, pNode1->size); uDebug("cache:%s, key:%p, %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", totalNum:%d sizeInBytes:%" PRId64 "bytes size:%" PRId64 "bytes", pCacheObj->name, key, pNode1->data, pNode1->addedTime, pNode1->expireTime, (int32_t)pCacheObj->numOfElems, @@ -456,7 +456,7 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen } if (pCacheObj->numOfElems == 0) { - atomic_add_fetch_64(&pCacheObj->statistics.missCount, 1); + (void)atomic_add_fetch_64(&pCacheObj->statistics.missCount, 1); return NULL; } @@ -474,15 +474,15 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen void *pData = (pNode != NULL) ? pNode->data : NULL; if (pData != NULL) { - atomic_add_fetch_64(&pCacheObj->statistics.hitCount, 1); + (void)atomic_add_fetch_64(&pCacheObj->statistics.hitCount, 1); uDebug("cache:%s, key:%p, %p is retrieved from cache, refcnt:%d", pCacheObj->name, key, pData, T_REF_VAL_GET(pNode)); } else { - atomic_add_fetch_64(&pCacheObj->statistics.missCount, 1); + (void)atomic_add_fetch_64(&pCacheObj->statistics.missCount, 1); uDebug("cache:%s, key:%p, not in cache, retrieved failed", pCacheObj->name, key); } - atomic_add_fetch_64(&pCacheObj->statistics.totalAccess, 1); + (void)atomic_add_fetch_64(&pCacheObj->statistics.totalAccess, 1); return pData; } @@ -577,7 +577,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { ASSERT(pNode->pTNodeHeader->pData == pNode); __trashcan_wr_lock(pCacheObj); - doRemoveElemInTrashcan(pCacheObj, pNode->pTNodeHeader); + (void)doRemoveElemInTrashcan(pCacheObj, pNode->pTNodeHeader); __trashcan_unlock(pCacheObj); ref = T_REF_DEC(pNode); @@ -616,7 +616,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { if (ref > 0) { taosAddToTrashcan(pCacheObj, pNode); } else { // ref == 0 - atomic_sub_fetch_64(&pCacheObj->sizeInBytes, pNode->size); + (void)atomic_sub_fetch_64(&pCacheObj->sizeInBytes, pNode->size); int32_t size = (int32_t)pCacheObj->numOfElems; uDebug("cache:%s, key:%p, %p is destroyed from cache, size:%dbytes, totalNum:%d size:%" PRId64 "bytes", @@ -670,7 +670,7 @@ void doTraverseElems(SCacheObj *pCacheObj, bool (*fp)(void *param, SCacheNode *p pEntry->num -= 1; ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0)); - atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1); + (void)atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1); pNode = next; } } @@ -786,7 +786,7 @@ void taosTrashcanEmpty(SCacheObj *pCacheObj, bool force) { uDebug("cache:%s, key:%p, %p removed from trashcan. numOfElem in trashcan:%d", pCacheObj->name, pElem->pData->key, pElem->pData->data, pCacheObj->numOfElemsInTrash - 1); - doRemoveElemInTrashcan(pCacheObj, pElem); + (void)doRemoveElemInTrashcan(pCacheObj, pElem); doDestroyTrashcanElem(pCacheObj, pElem); pElem = pCacheObj->pTrash; } else { @@ -896,7 +896,7 @@ _end: taosArrayDestroy(pCacheArrayList); pCacheArrayList = NULL; - taosThreadMutexDestroy(&guard); + (void)taosThreadMutexDestroy(&guard); refreshWorkerNormalStopped = true; uDebug("cache refresh thread quits"); @@ -915,7 +915,7 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1) void taosStopCacheRefreshWorker(void) { stopRefreshWorker = true; TdThreadOnce tmp = PTHREAD_ONCE_INIT; - if (memcmp(&cacheThreadInit, &tmp, sizeof(TdThreadOnce)) != 0) taosThreadJoin(cacheRefreshWorker, NULL); + if (memcmp(&cacheThreadInit, &tmp, sizeof(TdThreadOnce)) != 0) (void)taosThreadJoin(cacheRefreshWorker, NULL); taosArrayDestroy(pCacheArrayList); } diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 1f7a244a53..8402d2a658 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -823,9 +823,9 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement return nelements * longBytes; } else if (input[0] == 1) { // Decompress if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) { - tsDecompressTimestampAvx512(input, nelements, output, false); + (void)tsDecompressTimestampAvx512(input, nelements, output, false); } else if (tsSIMDEnable && tsAVX2Supported) { - tsDecompressTimestampAvx2(input, nelements, output, false); + (void)tsDecompressTimestampAvx2(input, nelements, output, false); } else { int64_t *ostream = (int64_t *)output; @@ -1199,9 +1199,9 @@ int32_t tsDecompressFloatImp(const char *const input, const int32_t nelements, c } if (tsSIMDEnable && tsAVX2Supported) { - tsDecompressFloatImplAvx2(input, nelements, output); + (void)tsDecompressFloatImplAvx2(input, nelements, output); } else if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) { - tsDecompressFloatImplAvx512(input, nelements, output); + (void)tsDecompressFloatImplAvx512(input, nelements, output); } else { // alternative implementation without SIMD instructions. tsDecompressFloatHelper(input, nelements, (float *)output); } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index e68d86e232..87551e28e0 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -18,12 +18,12 @@ #include "cJSON.h" #include "taoserror.h" #include "tenv.h" +#include "tglobal.h" #include "tgrant.h" #include "tjson.h" #include "tlog.h" #include "tunit.h" #include "tutil.h" -#include "tglobal.h" #define CFG_NAME_PRINT_LEN 24 #define CFG_SRC_PRINT_LEN 12 @@ -1214,8 +1214,9 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { char *cfgLineBuf = NULL, *name, *value, *value2, *value3, *value4; + SJson *pJson = NULL; int32_t olen, vlen, vlen2, vlen3, vlen4; - int32_t code = 0; + int32_t code = 0, lino = 0; if (url == NULL || strlen(url) == 0) { uInfo("apoll url not load"); TAOS_RETURN(TSDB_CODE_SUCCESS); @@ -1228,7 +1229,6 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { } p++; - SJson *pJson = NULL; if (strncmp(url, "jsonFile", 8) == 0) { char *filepath = p; if (!taosCheckExistFile(filepath)) { @@ -1238,7 +1238,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); if (pFile == NULL) { - TAOS_RETURN(TAOS_SYSTEM_ERROR(errno)); + TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno)); } size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END); char *buf = taosMemoryMalloc(fileSize + 1); @@ -1264,7 +1264,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { uError("load json file parse error: %s", jsonParseError); } taosMemoryFreeClear(buf); - TAOS_RETURN(TSDB_CODE_INVALID_DATA_FMT); + TAOS_CHECK_EXIT(TSDB_CODE_INVALID_DATA_FMT); } taosMemoryFreeClear(buf); @@ -1273,16 +1273,19 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { cJSON *item = tjsonGetArrayItem(pJson, i); if (item == NULL) break; char *itemName = NULL, *itemValueString = NULL; - TAOS_CHECK_GOTO(tjsonGetObjectName(item, &itemName), NULL, _err_json); - TAOS_CHECK_GOTO(tjsonGetObjectValueString(item, &itemValueString), NULL, _err_json); + if (tjsonGetObjectName(item, &itemName) != 0) { + TAOS_CHECK_EXIT(TSDB_CODE_INVALID_DATA_FMT); + } + if (tjsonGetObjectValueString(item, &itemValueString) != 0) { + TAOS_CHECK_EXIT(TSDB_CODE_INVALID_DATA_FMT); + } if (itemValueString != NULL && itemName != NULL) { size_t itemNameLen = strlen(itemName); size_t itemValueStringLen = strlen(itemValueString); - void* px = taosMemoryRealloc(cfgLineBuf, itemNameLen + itemValueStringLen + 3); + void *px = taosMemoryRealloc(cfgLineBuf, itemNameLen + itemValueStringLen + 3); if (NULL == px) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err_json; + TAOS_CHECK_EXIT(TSDB_CODE_OUT_OF_MEMORY); } cfgLineBuf = px; @@ -1321,6 +1324,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { } } tjsonDelete(pJson); + pJson = NULL; // } else if (strncmp(url, "jsonUrl", 7) == 0) { // } else if (strncmp(url, "etcdUrl", 7) == 0) { @@ -1333,8 +1337,12 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { uInfo("load from apoll url not implemented yet"); TAOS_RETURN(TSDB_CODE_SUCCESS); -_err_json: +_exit: + taosMemoryFree(cfgLineBuf); tjsonDelete(pJson); + if (code != 0) { + uError("failed to load from apollo url:%s at line %d since %s", url, lino, tstrerror(code)); + } TAOS_RETURN(code); } @@ -1420,7 +1428,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl } uInfo("fail get apollo url from cmd env file"); - TAOS_RETURN(TSDB_CODE_INVALID_PARA); + TAOS_RETURN(TSDB_CODE_NOT_FOUND); } struct SConfigIter { diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 588c53537a..51b68f8f6b 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -256,7 +256,7 @@ double tdigestQuantile(TDigest *t, double q) { int64_t weight_so_far; SCentroid *a, *b, tmp; - tdigestCompress(t); + (void)tdigestCompress(t); if (t->num_centroids == 0) return NAN; if (t->num_centroids == 1) return t->centroids[0].mean; if (FLOAT_EQ(q, 0.0)) return t->min; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 1200cbfb5a..8400675ec6 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -55,8 +55,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TIMEOUT, "Conn read timeout") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED, "some vnode/qnode/mnode(s) out of service") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MAX_SESSIONS, "rpc open too many session") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_ERROR, "rpc network error") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_BUSY, "rpc network busy") -TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_MODULE_QUIT, "http-report already quit") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_BUSY, "rpc network busy") +TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_MODULE_QUIT, "http-report already quit") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MODULE_QUIT, "rpc module already quit") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ASYNC_MODULE_QUIT, "rpc async module already quit") //common & util TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized") @@ -832,7 +834,7 @@ static void tsSortError(void) { } const char* tstrerror(int32_t err) { - taosThreadOnce(&tsErrorInit, tsSortError); + (void)taosThreadOnce(&tsErrorInit, tsSortError); // this is a system errno if ((err & 0x00ff0000) == 0x00ff0000) { diff --git a/source/util/src/texception.c b/source/util/src/texception.c index 4723e34990..2c8ddf6a5f 100644 --- a/source/util/src/texception.c +++ b/source/util/src/texception.c @@ -52,7 +52,7 @@ static void cleanupWrapper_void_ptr(SCleanupAction* ca) { static void cleanupWrapper_int_int(SCleanupAction* ca) { int32_t (*func)(int32_t) = ca->func; - func(ca->arg1.Int); + (void)func(ca->arg1.Int); } static void cleanupWrapper_void(SCleanupAction* ca) { @@ -62,7 +62,7 @@ static void cleanupWrapper_void(SCleanupAction* ca) { static void cleanupWrapper_int_ptr(SCleanupAction* ca) { int32_t (*func)(void*) = ca->func; - func(ca->arg1.Ptr); + (void)func(ca->arg1.Ptr); } typedef void (*wrapper)(SCleanupAction*); diff --git a/source/util/src/thash.c b/source/util/src/thash.c index 62a73cb38c..2daedfdf32 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -188,7 +188,7 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p */ static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry *pe, SHashNode *prev, SHashNode *pNode, SHashNode *pNewNode) { - atomic_sub_fetch_16(&pNode->refCount, 1); + (void)atomic_sub_fetch_16(&pNode->refCount, 1); if (prev != NULL) { prev->next = pNewNode; ASSERT(prev->next != prev); @@ -204,7 +204,7 @@ static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry *pe, SH } else { pNewNode->next = pNode; pe->num++; - atomic_add_fetch_64(&pHashObj->size, 1); + (void)atomic_add_fetch_64(&pHashObj->size, 1); } } @@ -359,7 +359,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, const vo } pushfrontNodeInEntryList(pe, pNewNode); - atomic_add_fetch_64(&pHashObj->size, 1); + (void)atomic_add_fetch_64(&pHashObj->size, 1); } else { // not support the update operation, return error if (pHashObj->enableUpdate) { @@ -392,14 +392,14 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) { int32_t taosHashGetDup(SHashObj *pHashObj, const void *key, size_t keyLen, void *destBuf) { terrno = 0; - /*char* p = */ taosHashGetImpl(pHashObj, key, keyLen, &destBuf, 0, false); + (void)taosHashGetImpl(pHashObj, key, keyLen, &destBuf, 0, false); return terrno; } int32_t taosHashGetDup_m(SHashObj *pHashObj, const void *key, size_t keyLen, void **destBuf, int32_t *size) { terrno = 0; - /*char* p = */ taosHashGetImpl(pHashObj, key, keyLen, destBuf, size, false); + (void)taosHashGetImpl(pHashObj, key, keyLen, destBuf, size, false); return terrno; } @@ -454,7 +454,7 @@ void *taosHashGetImpl(SHashObj *pHashObj, const void *key, size_t keyLen, void * } if (addRef) { - atomic_add_fetch_16(&pNode->refCount, 1); + (void)atomic_add_fetch_16(&pNode->refCount, 1); } if (*d != NULL) { @@ -501,7 +501,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) { pNode->removed == 0) { code = 0; // it is found - atomic_sub_fetch_16(&pNode->refCount, 1); + (void)atomic_sub_fetch_16(&pNode->refCount, 1); pNode->removed = 1; if (pNode->refCount <= 0) { if (prevNode == NULL) { @@ -512,7 +512,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) { } pe->num--; - atomic_sub_fetch_64(&pHashObj->size, 1); + (void)atomic_sub_fetch_64(&pHashObj->size, 1); FREE_HASH_NODE(pHashObj->freeFp, pNode); } } else { @@ -752,7 +752,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { pNode = pNode->next; } - atomic_sub_fetch_16(&pOld->refCount, 1); + (void)atomic_sub_fetch_16(&pOld->refCount, 1); if (pOld->refCount <= 0) { if (prevNode) { prevNode->next = pOld->next; @@ -766,7 +766,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { } pe->num--; - atomic_sub_fetch_64(&pHashObj->size, 1); + (void)atomic_sub_fetch_64(&pHashObj->size, 1); FREE_HASH_NODE(pHashObj->freeFp, pOld); } } else { @@ -840,7 +840,7 @@ void taosHashCancelIterate(SHashObj *pHashObj, void *p) { taosHashRLock(pHashObj); int slot; - taosHashReleaseNode(pHashObj, p, &slot); + (void)taosHashReleaseNode(pHashObj, p, &slot); SHashEntry *pe = pHashObj->hashList[slot]; diff --git a/source/util/src/theap.c b/source/util/src/theap.c index 40fe63b004..7ee49ff56d 100644 --- a/source/util/src/theap.c +++ b/source/util/src/theap.c @@ -258,9 +258,9 @@ static PriorityQueueNode* pqHeapify(PriorityQueue* pq, size_t from, size_t last) static void pqBuildHeap(PriorityQueue* pq) { if (pqContainerSize(pq) > 1) { for (size_t i = pqContainerSize(pq) - 1; i > 0; --i) { - pqHeapify(pq, i, pqContainerSize(pq)); + (void)pqHeapify(pq, i, pqContainerSize(pq)); } - pqHeapify(pq, 0, pqContainerSize(pq)); + (void)pqHeapify(pq, 0, pqContainerSize(pq)); } } @@ -276,21 +276,21 @@ static PriorityQueueNode* pqReverseHeapify(PriorityQueue* pq, size_t i) { static void pqUpdate(PriorityQueue* pq, size_t i) { if (i == 0 || pq->fn(pqContainerGetEle(pq, i)->data, pqContainerGetEle(pq, pqParent(i))->data, pq->param)) { // if value in pos i is smaller than parent, heapify down from i to the end - pqHeapify(pq, i, pqContainerSize(pq)); + (void)pqHeapify(pq, i, pqContainerSize(pq)); } else { // if value in pos i is big than parent, heapify up from i - pqReverseHeapify(pq, i); + (void)pqReverseHeapify(pq, i); } } static void pqRemove(PriorityQueue* pq, size_t i) { if (i == pqContainerSize(pq) - 1) { - taosArrayPop(pq->container); + (void)taosArrayPop(pq->container); return; } taosArraySet(pq->container, i, taosArrayGet(pq->container, pqContainerSize(pq) - 1)); - taosArrayPop(pq->container); + (void)taosArrayPop(pq->container); pqUpdate(pq, i); } diff --git a/source/util/src/tidpool.c b/source/util/src/tidpool.c index 46e68c0818..456078c4b5 100644 --- a/source/util/src/tidpool.c +++ b/source/util/src/tidpool.c @@ -33,7 +33,7 @@ void *taosInitIdPool(int32_t maxId) { pIdPool->numOfFree = maxId; pIdPool->freeSlot = 0; - taosThreadMutexInit(&pIdPool->mutex, NULL); + (void)taosThreadMutexInit(&pIdPool->mutex, NULL); uDebug("pool:%p is setup, maxId:%d", pIdPool, pIdPool->maxId); @@ -83,7 +83,7 @@ void taosIdPoolCleanUp(id_pool_t *pIdPool) { if (pIdPool->freeList) taosMemoryFree(pIdPool->freeList); - taosThreadMutexDestroy(&pIdPool->mutex); + (void)taosThreadMutexDestroy(&pIdPool->mutex); memset(pIdPool, 0, sizeof(id_pool_t)); diff --git a/source/util/src/tlockfree.c b/source/util/src/tlockfree.c index 6f7b6f6901..1961b404b5 100644 --- a/source/util/src/tlockfree.c +++ b/source/util/src/tlockfree.c @@ -30,7 +30,7 @@ void taosWLockLatch(SRWLatch *pLatch) { if (oLatch & TD_RWLATCH_WRITE_FLAG) { nLoops++; if (nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } continue; @@ -47,7 +47,7 @@ void taosWLockLatch(SRWLatch *pLatch) { if (oLatch == TD_RWLATCH_WRITE_FLAG) break; nLoops++; if (nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -80,7 +80,7 @@ void taosRLockLatch(SRWLatch *pLatch) { if (oLatch & TD_RWLATCH_WRITE_FLAG) { nLoops++; if (nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } continue; @@ -91,4 +91,4 @@ void taosRLockLatch(SRWLatch *pLatch) { } } -void taosRUnLockLatch(SRWLatch *pLatch) { atomic_fetch_sub_32(pLatch, 1); } +void taosRUnLockLatch(SRWLatch *pLatch) { (void)atomic_fetch_sub_32(pLatch, 1); } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index fa2c2cc3ed..1946a0a274 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -136,7 +136,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxFileNum); static FORCE_INLINE void taosUpdateDaylight() { struct tm Tm, *ptm; struct timeval timeSecs; - taosGetTimeOfDay(&timeSecs); + (void)taosGetTimeOfDay(&timeSecs); time_t curTime = timeSecs.tv_sec; ptm = taosLocalTime(&curTime, &Tm, NULL); tsDaylightActive = ptm->tm_isdst; @@ -145,11 +145,11 @@ static FORCE_INLINE int32_t taosGetDaylight() { return tsDaylightActive; } static int32_t taosStartLog() { TdThreadAttr threadAttr; - taosThreadAttrInit(&threadAttr); + (void)taosThreadAttrInit(&threadAttr); if (taosThreadCreate(&(tsLogObj.logHandle->asyncThread), &threadAttr, taosAsyncOutputLog, tsLogObj.logHandle) != 0) { return terrno; } - taosThreadAttrDestroy(&threadAttr); + (void)taosThreadAttrDestroy(&threadAttr); return 0; } @@ -179,7 +179,7 @@ int32_t taosInitSlowLog() { tsLogObj.slowHandle = taosLogBuffNew(LOG_SLOW_BUF_SIZE); if (tsLogObj.slowHandle == NULL) return terrno; - taosUmaskFile(0); + (void)taosUmaskFile(0); tsLogObj.slowHandle->pFile = taosOpenFile(fullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND); if (tsLogObj.slowHandle->pFile == NULL) { printf("\nfailed to open slow log file:%s, reason:%s\n", fullName, strerror(errno)); @@ -231,13 +231,13 @@ void taosCloseLog() { taosStopLog(); if (tsLogObj.logHandle != NULL && taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) { - taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL); + (void)taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL); taosThreadClear(&tsLogObj.logHandle->asyncThread); } if (tsLogObj.slowHandle != NULL) { - taosThreadMutexDestroy(&tsLogObj.slowHandle->buffMutex); - taosCloseFile(&tsLogObj.slowHandle->pFile); + (void)taosThreadMutexDestroy(&tsLogObj.slowHandle->buffMutex); + (void)taosCloseFile(&tsLogObj.slowHandle->pFile); taosMemoryFreeClear(tsLogObj.slowHandle->buffer); taosMemoryFreeClear(tsLogObj.slowHandle); } @@ -245,10 +245,10 @@ void taosCloseLog() { if (tsLogObj.logHandle != NULL) { tsLogInited = 0; - taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex); - taosCloseFile(&tsLogObj.logHandle->pFile); + (void)taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex); + (void)taosCloseFile(&tsLogObj.logHandle->pFile); taosMemoryFreeClear(tsLogObj.logHandle->buffer); - taosThreadMutexDestroy(&tsLogObj.logMutex); + (void)taosThreadMutexDestroy(&tsLogObj.logMutex); taosMemoryFreeClear(tsLogObj.logHandle); tsLogObj.logHandle = NULL; } @@ -271,7 +271,7 @@ static void taosUnLockLogFile(TdFilePtr pFile) { if (pFile == NULL) return; if (tsLogObj.fileNum > 1) { - taosUnLockFile(pFile); + (void)taosUnLockFile(pFile); } } @@ -321,7 +321,7 @@ static OldFileKeeper *taosOpenNewFile() { char name[LOG_FILE_NAME_LEN + 20]; sprintf(name, "%s.%d", tsLogObj.logName, tsLogObj.flag); - taosUmaskFile(0); + (void)taosUmaskFile(0); TdFilePtr pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { @@ -331,7 +331,7 @@ static OldFileKeeper *taosOpenNewFile() { return NULL; } - taosLockLogFile(pFile); + (void)taosLockLogFile(pFile); (void)taosLSeekFile(pFile, 0, SEEK_SET); TdFilePtr pOldFile = tsLogObj.logHandle->pFile; @@ -370,12 +370,12 @@ static int32_t taosOpenNewLogFile() { uInfo("open new log file ......"); TdThread thread; TdThreadAttr attr; - taosThreadAttrInit(&attr); - taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED); + (void)taosThreadAttrInit(&attr); + (void)taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED); OldFileKeeper *oldFileKeeper = taosOpenNewFile(); - taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper); - taosThreadAttrDestroy(&attr); + (void)taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper); + (void)taosThreadAttrDestroy(&attr); } (void)taosThreadMutexUnlock(&tsLogObj.logMutex); @@ -388,7 +388,7 @@ void taosResetLog() { tsLogObj.lines = tsNumOfLogLines + 10; if (tsLogObj.logHandle) { - taosOpenNewLogFile(); + (void)taosOpenNewLogFile(); uInfo("=================================="); uInfo(" reset log file "); } @@ -407,10 +407,10 @@ static bool taosCheckFileIsOpen(char *logFileName) { if (taosLockLogFile(pFile)) { taosUnLockLogFile(pFile); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return false; } else { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return true; } } @@ -478,16 +478,16 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxFileNum) { char fileName[LOG_FILE_NAME_LEN + 50] = "\0"; sprintf(fileName, "%s.%d", tsLogObj.logName, tsLogObj.flag); - taosThreadMutexInit(&tsLogObj.logMutex, NULL); + (void)taosThreadMutexInit(&tsLogObj.logMutex, NULL); - taosUmaskFile(0); + (void)taosUmaskFile(0); tsLogObj.logHandle->pFile = taosOpenFile(fileName, TD_FILE_CREATE | TD_FILE_WRITE); if (tsLogObj.logHandle->pFile == NULL) { printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno)); return TAOS_SYSTEM_ERROR(errno); } - taosLockLogFile(tsLogObj.logHandle->pFile); + (void)taosLockLogFile(tsLogObj.logHandle->pFile); // only an estimate for number of lines int64_t filesize = 0; @@ -497,14 +497,14 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxFileNum) { } tsLogObj.lines = (int32_t)(filesize / 60); - taosLSeekFile(tsLogObj.logHandle->pFile, 0, SEEK_END); + (void)taosLSeekFile(tsLogObj.logHandle->pFile, 0, SEEK_END); sprintf(name, "==================================================\n"); - taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name)); + (void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name)); sprintf(name, " new log file \n"); - taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name)); + (void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name)); sprintf(name, "==================================================\n"); - taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name)); + (void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name)); return 0; } @@ -512,17 +512,17 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxFileNum) { static void taosUpdateLogNums(ELogLevel level) { switch (level) { case DEBUG_ERROR: - atomic_add_fetch_64(&tsNumOfErrorLogs, 1); + (void)atomic_add_fetch_64(&tsNumOfErrorLogs, 1); break; case DEBUG_INFO: - atomic_add_fetch_64(&tsNumOfInfoLogs, 1); + (void)atomic_add_fetch_64(&tsNumOfInfoLogs, 1); break; case DEBUG_DEBUG: - atomic_add_fetch_64(&tsNumOfDebugLogs, 1); + (void)atomic_add_fetch_64(&tsNumOfDebugLogs, 1); break; case DEBUG_DUMP: case DEBUG_TRACE: - atomic_add_fetch_64(&tsNumOfTraceLogs, 1); + (void)atomic_add_fetch_64(&tsNumOfTraceLogs, 1); break; default: break; @@ -533,7 +533,7 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) { struct tm Tm, *ptm; struct timeval timeSecs; - taosGetTimeOfDay(&timeSecs); + (void)taosGetTimeOfDay(&timeSecs); time_t curTime = timeSecs.tv_sec; ptm = taosLocalTime(&curTime, &Tm, NULL); @@ -546,15 +546,15 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile != NULL && osLogSpaceAvailable()) { taosUpdateLogNums(level); if (tsAsyncLog) { - taosPushLogBuffer(tsLogObj.logHandle, buffer, len); + (void)taosPushLogBuffer(tsLogObj.logHandle, buffer, len); } else { - taosWriteFile(tsLogObj.logHandle->pFile, buffer, len); + (void)taosWriteFile(tsLogObj.logHandle->pFile, buffer, len); } if (tsNumOfLogLines > 0) { - atomic_add_fetch_32(&tsLogObj.lines, 1); + (void)atomic_add_fetch_32(&tsLogObj.lines, 1); if ((tsLogObj.lines > tsNumOfLogLines) && (tsLogObj.openInProgress == 0)) { - taosOpenNewLogFile(); + (void)taosOpenNewLogFile(); } } } @@ -562,7 +562,7 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b if (dflag & DEBUG_SCREEN) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-result" - write(1, buffer, (uint32_t)len); + (void)write(1, buffer, (uint32_t)len); #pragma GCC diagnostic pop } } @@ -627,12 +627,12 @@ void taosPrintSlowLog(const char *format, ...) { buffer[len++] = '\n'; buffer[len] = 0; - atomic_add_fetch_64(&tsNumOfSlowLogs, 1); + (void)atomic_add_fetch_64(&tsNumOfSlowLogs, 1); if (tsAsyncLog) { - taosPushLogBuffer(tsLogObj.slowHandle, buffer, len); + (void)taosPushLogBuffer(tsLogObj.slowHandle, buffer, len); } else { - taosWriteFile(tsLogObj.slowHandle->pFile, buffer, len); + (void)taosWriteFile(tsLogObj.slowHandle->pFile, buffer, len); } taosMemoryFree(buffer); @@ -651,7 +651,7 @@ void taosDumpData(unsigned char *msg, int32_t len) { pos += 3; if (c >= 16) { temp[pos++] = '\n'; - taosWriteFile(tsLogObj.logHandle->pFile, temp, (uint32_t)pos); + (void)taosWriteFile(tsLogObj.logHandle->pFile, temp, (uint32_t)pos); c = 0; pos = 0; } @@ -659,13 +659,13 @@ void taosDumpData(unsigned char *msg, int32_t len) { temp[pos++] = '\n'; - taosWriteFile(tsLogObj.logHandle->pFile, temp, (uint32_t)pos); + (void)taosWriteFile(tsLogObj.logHandle->pFile, temp, (uint32_t)pos); } static void taosCloseLogByFd(TdFilePtr pFile) { if (pFile != NULL) { taosUnLockLogFile(pFile); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); } } @@ -786,12 +786,12 @@ static void taosWriteLog(SLogBuff *pLogBuf) { pLogBuf->lastDuration = 0; if (start < end) { - taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, pollSize); + (void)taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, pollSize); } else { int32_t tsize = LOG_BUF_SIZE(pLogBuf) - start; - taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, tsize); + (void)taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, tsize); - taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf), end); + (void)taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf), end); } dbgWN++; @@ -914,11 +914,11 @@ void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, vo goto _return; } - taosLockFile(pFile); + (void)taosLockFile(pFile); int64_t writeSize = taosWriteFile(pFile, &msgLen, sizeof(msgLen)); if (sizeof(msgLen) != writeSize) { - taosUnLockFile(pFile); + (void)taosUnLockFile(pFile); taosPrintLog(flags, level, dflag, "failed to write len to file:%s,%p wlen:%" PRId64 " tlen:%lu since %s", filepath, pFile, writeSize, sizeof(msgLen), terrstr()); goto _return; @@ -926,18 +926,18 @@ void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, vo writeSize = taosWriteFile(pFile, pMsg, msgLen); if (msgLen != writeSize) { - taosUnLockFile(pFile); + (void)taosUnLockFile(pFile); taosPrintLog(flags, level, dflag, "failed to write file:%s,%p wlen:%" PRId64 " tlen:%" PRId64 " since %s", filepath, pFile, writeSize, msgLen, terrstr()); goto _return; } - taosUnLockFile(pFile); + (void)taosUnLockFile(pFile); } _return: - if (pFile) taosCloseFile(&pFile); + if (pFile) (void)taosCloseFile(&pFile); terrno = TAOS_SYSTEM_ERROR(errno); taosPrintLog(flags, level, dflag, "crash signal is %d", signum); @@ -990,7 +990,7 @@ void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr return; } - taosLockFile(pFile); + (void)taosLockFile(pFile); } else { pFile = *pFd; } @@ -1029,10 +1029,10 @@ void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr _return: if (truncateFile) { - taosFtruncateFile(pFile, 0); + (void)taosFtruncateFile(pFile, 0); } - taosUnLockFile(pFile); - taosCloseFile(&pFile); + (void)taosUnLockFile(pFile); + (void)taosCloseFile(&pFile); taosMemoryFree(buf); *pMsg = NULL; @@ -1042,11 +1042,11 @@ _return: void taosReleaseCrashLogFile(TdFilePtr pFile, bool truncateFile) { if (truncateFile) { - taosFtruncateFile(pFile, 0); + (void)taosFtruncateFile(pFile, 0); } - taosUnLockFile(pFile); - taosCloseFile(&pFile); + (void)taosUnLockFile(pFile); + (void)taosCloseFile(&pFile); } #ifdef NDEBUG diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index e08dc009fc..5d28eeafb1 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -320,7 +320,7 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old)); taosLRUCacheShardLRURemove(shard, old); - taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + (void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); ASSERT(shard->usage >= old->totalCharge); @@ -531,7 +531,7 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { SLRUEntry *old = shard->lru.next; ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old)); taosLRUCacheShardLRURemove(shard, old); - taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + (void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); ASSERT(shard->usage >= old->totalCharge); shard->usage -= old->totalCharge; @@ -577,7 +577,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b if (shard->usage > shard->capacity || eraseIfLastRef) { ASSERT(shard->lru.next == &shard->lru || eraseIfLastRef); - taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); + (void)taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); } else { taosLRUCacheShardLRUInsert(shard, e); diff --git a/source/util/src/tqueue.c b/source/util/src/tqueue.c index c6b029ea01..87d5680aa0 100644 --- a/source/util/src/tqueue.c +++ b/source/util/src/tqueue.c @@ -102,7 +102,7 @@ void taosCloseQueue(STaosQueue *queue) { taosMemoryFree(pTemp); } - taosThreadMutexDestroy(&queue->mutex); + (void)taosThreadMutexDestroy(&queue->mutex); taosMemoryFree(queue); uDebug("queue:%p is closed", queue); @@ -165,7 +165,7 @@ int32_t taosAllocateQitem(int32_t size, EQItype itype, int64_t dataSize, void ** if (alloced > tsRpcQueueMemoryAllowed) { uError("failed to alloc qitem, size:%" PRId64 " alloc:%" PRId64 " allowed:%" PRId64, size + dataSize, alloced, tsRpcQueueMemoryAllowed); - atomic_sub_fetch_64(&tsRpcQueueMemoryUsed, size + dataSize); + (void)atomic_sub_fetch_64(&tsRpcQueueMemoryUsed, size + dataSize); taosMemoryFree(pNode); return (terrno = TSDB_CODE_OUT_OF_RPC_MEMORY_QUEUE); } @@ -224,7 +224,7 @@ int32_t taosWriteQitem(STaosQueue *queue, void *pItem) { queue->numOfItems++; queue->memOfItems += (pNode->size + pNode->dataSize); if (queue->qset) { - atomic_add_fetch_32(&queue->qset->numOfItems, 1); + (void)atomic_add_fetch_32(&queue->qset->numOfItems, 1); } uTrace("item:%p is put into queue:%p, items:%d mem:%" PRId64, pItem, queue, queue->numOfItems, queue->memOfItems); @@ -232,7 +232,7 @@ int32_t taosWriteQitem(STaosQueue *queue, void *pItem) { (void)taosThreadMutexUnlock(&queue->mutex); if (queue->qset) { - tsem_post(&queue->qset->sem); + (void)tsem_post(&queue->qset->sem); } return code; } @@ -253,7 +253,7 @@ int32_t taosReadQitem(STaosQueue *queue, void **ppItem) { queue->numOfItems--; queue->memOfItems -= (pNode->size + pNode->dataSize); if (queue->qset) { - atomic_sub_fetch_32(&queue->qset->numOfItems, 1); + (void)atomic_sub_fetch_32(&queue->qset->numOfItems, 1); } code = 1; uTrace("item:%p is read out from queue:%p, items:%d mem:%" PRId64, *ppItem, queue, queue->numOfItems, @@ -301,7 +301,7 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) { uTrace("read %d items from queue:%p, items:%d mem:%" PRId64, numOfItems, queue, queue->numOfItems, queue->memOfItems); if (queue->qset) { - atomic_sub_fetch_32(&queue->qset->numOfItems, qall->numOfItems); + (void)atomic_sub_fetch_32(&queue->qset->numOfItems, qall->numOfItems); } } @@ -344,8 +344,8 @@ int32_t taosOpenQset(STaosQset **qset) { return terrno = TSDB_CODE_OUT_OF_MEMORY; } - taosThreadMutexInit(&(*qset)->mutex, NULL); - tsem_init(&(*qset)->sem, 0, 0); + (void)taosThreadMutexInit(&(*qset)->mutex, NULL); + (void)tsem_init(&(*qset)->sem, 0, 0); uDebug("qset:%p is opened", qset); return 0; @@ -365,8 +365,8 @@ void taosCloseQset(STaosQset *qset) { } (void)taosThreadMutexUnlock(&qset->mutex); - taosThreadMutexDestroy(&qset->mutex); - tsem_destroy(&qset->sem); + (void)taosThreadMutexDestroy(&qset->mutex); + (void)tsem_destroy(&qset->sem); taosMemoryFree(qset); uDebug("qset:%p is closed", qset); } @@ -376,7 +376,7 @@ void taosCloseQset(STaosQset *qset) { // thread to exit. void taosQsetThreadResume(STaosQset *qset) { uDebug("qset:%p, it will exit", qset); - tsem_post(&qset->sem); + (void)tsem_post(&qset->sem); } int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle) { @@ -390,7 +390,7 @@ int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle) { qset->numOfQueues++; (void)taosThreadMutexLock(&queue->mutex); - atomic_add_fetch_32(&qset->numOfItems, queue->numOfItems); + (void)atomic_add_fetch_32(&qset->numOfItems, queue->numOfItems); queue->qset = qset; (void)taosThreadMutexUnlock(&queue->mutex); @@ -428,7 +428,7 @@ void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue) { qset->numOfQueues--; (void)taosThreadMutexLock(&queue->mutex); - atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems); + (void)atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems); queue->qset = NULL; queue->next = NULL; (void)taosThreadMutexUnlock(&queue->mutex); @@ -444,7 +444,7 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) STaosQnode *pNode = NULL; int32_t code = 0; - tsem_wait(&qset->sem); + (void)tsem_wait(&qset->sem); (void)taosThreadMutexLock(&qset->mutex); @@ -469,7 +469,7 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) if (queue->head == NULL) queue->tail = NULL; // queue->numOfItems--; queue->memOfItems -= (pNode->size + pNode->dataSize); - atomic_sub_fetch_32(&qset->numOfItems, 1); + (void)atomic_sub_fetch_32(&qset->numOfItems, 1); code = 1; uTrace("item:%p is read out from queue:%p, items:%d mem:%" PRId64, *ppItem, queue, queue->numOfItems - 1, queue->memOfItems); @@ -488,7 +488,7 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * STaosQueue *queue; int32_t code = 0; - tsem_wait(&qset->sem); + (void)tsem_wait(&qset->sem); (void)taosThreadMutexLock(&qset->mutex); for (int32_t i = 0; i < qset->numOfQueues; ++i) { @@ -520,9 +520,9 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * queue->memOfItems = 0; uTrace("read %d items from queue:%p, items:0 mem:%" PRId64, code, queue, queue->memOfItems); - atomic_sub_fetch_32(&qset->numOfItems, qall->numOfItems); + (void)atomic_sub_fetch_32(&qset->numOfItems, qall->numOfItems); for (int32_t j = 1; j < qall->numOfItems; ++j) { - tsem_wait(&qset->sem); + (void)tsem_wait(&qset->sem); } } diff --git a/source/util/src/trbtree.c b/source/util/src/trbtree.c index e1000f7bc1..dddc2aea4b 100644 --- a/source/util/src/trbtree.c +++ b/source/util/src/trbtree.c @@ -412,7 +412,7 @@ void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z) { pTree->max = tRBTreePredecessor(pTree, pTree->max); } - rbtree_delete(pTree, z); + (void)rbtree_delete(pTree, z); pTree->n--; } diff --git a/source/util/src/tref.c b/source/util/src/tref.c index fe55335fce..f1d9a24757 100644 --- a/source/util/src/tref.c +++ b/source/util/src/tref.c @@ -63,7 +63,7 @@ int32_t taosOpenRef(int32_t max, RefFp fp) { int64_t *lockedBy; int32_t i, rsetId; - taosThreadOnce(&tsRefModuleInit, taosInitRefModule); + (void)taosThreadOnce(&tsRefModuleInit, taosInitRefModule); nodeList = taosMemoryCalloc(sizeof(SRefNode *), (size_t)max); if (nodeList == NULL) { @@ -450,7 +450,7 @@ static void taosLockList(int64_t *lockedBy) { int32_t i = 0; while (atomic_val_compare_exchange_64(lockedBy, 0, tid) != 0) { if (++i % 100 == 0) { - sched_yield(); + (void)sched_yield(); } } } @@ -462,10 +462,10 @@ static void taosUnlockList(int64_t *lockedBy) { } } -static void taosInitRefModule(void) { taosThreadMutexInit(&tsRefMutex, NULL); } +static void taosInitRefModule(void) { (void)taosThreadMutexInit(&tsRefMutex, NULL); } static void taosIncRsetCount(SRefSet *pSet) { - atomic_add_fetch_32(&pSet->count, 1); + (void)atomic_add_fetch_32(&pSet->count, 1); // uTrace("rsetId:%d inc count:%d", pSet->rsetId, count); } diff --git a/source/util/src/tskiplist.c b/source/util/src/tskiplist.c index 27e6fd6224..e5e52e44d9 100644 --- a/source/util/src/tskiplist.c +++ b/source/util/src/tskiplist.c @@ -103,7 +103,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _ void tSkipListDestroy(SSkipList *pSkipList) { if (pSkipList == NULL) return; - tSkipListWLock(pSkipList); + (void)tSkipListWLock(pSkipList); SSkipListNode *pNode = SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, 0); @@ -113,9 +113,9 @@ void tSkipListDestroy(SSkipList *pSkipList) { tSkipListFreeNode(pTemp); } - tSkipListUnlock(pSkipList); + (void)tSkipListUnlock(pSkipList); if (pSkipList->lock != NULL) { - taosThreadRwlockDestroy(pSkipList->lock); + (void)taosThreadRwlockDestroy(pSkipList->lock); taosMemoryFreeClear(pSkipList->lock); } @@ -130,12 +130,12 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) { SSkipListNode *backward[MAX_SKIP_LIST_LEVEL] = {0}; SSkipListNode *pNode = NULL; - tSkipListWLock(pSkipList); + (void)tSkipListWLock(pSkipList); bool hasDup = tSkipListGetPosToPut(pSkipList, backward, pData); pNode = tSkipListPutImpl(pSkipList, pData, backward, false, hasDup); - tSkipListUnlock(pSkipList); + (void)tSkipListUnlock(pSkipList); return pNode; } @@ -293,11 +293,11 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList *pSkipList, const char * return iter; } - tSkipListRLock(pSkipList); + (void)tSkipListRLock(pSkipList); iter->cur = getPriorNode(pSkipList, val, order, &(iter->next)); - tSkipListUnlock(pSkipList); + (void)tSkipListUnlock(pSkipList); return iter; } @@ -307,13 +307,13 @@ bool tSkipListIterNext(SSkipListIterator *iter) { SSkipList *pSkipList = iter->pSkipList; - tSkipListRLock(pSkipList); + (void)tSkipListRLock(pSkipList); if (iter->order == TSDB_ORDER_ASC) { // no data in the skip list if (iter->cur == pSkipList->pTail || iter->next == NULL) { iter->cur = pSkipList->pTail; - tSkipListUnlock(pSkipList); + (void)tSkipListUnlock(pSkipList); return false; } @@ -329,7 +329,7 @@ bool tSkipListIterNext(SSkipListIterator *iter) { } else { if (iter->cur == pSkipList->pHead) { iter->cur = pSkipList->pHead; - tSkipListUnlock(pSkipList); + (void)tSkipListUnlock(pSkipList); return false; } @@ -344,7 +344,7 @@ bool tSkipListIterNext(SSkipListIterator *iter) { iter->step++; } - tSkipListUnlock(pSkipList); + (void)tSkipListUnlock(pSkipList); return (iter->order == TSDB_ORDER_ASC) ? (iter->cur != pSkipList->pTail) : (iter->cur != pSkipList->pHead); } diff --git a/source/util/src/tthread.c b/source/util/src/tthread.c index 17f49ea0a8..ee038f18f4 100644 --- a/source/util/src/tthread.c +++ b/source/util/src/tthread.c @@ -24,10 +24,10 @@ TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param) { } TdThreadAttr thattr; - taosThreadAttrInit(&thattr); - taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thattr); + (void)taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); int32_t ret = taosThreadCreate(pthread, &thattr, __start_routine, param); - taosThreadAttrDestroy(&thattr); + (void)taosThreadAttrDestroy(&thattr); if (ret != 0) { taosMemoryFree(pthread); @@ -40,8 +40,8 @@ TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param) { bool taosDestroyThread(TdThread* pthread) { if (pthread == NULL) return false; if (taosThreadRunning(pthread)) { - taosThreadCancel(*pthread); - taosThreadJoin(*pthread, NULL); + (void)taosThreadCancel(*pthread); + (void)taosThreadJoin(*pthread, NULL); } taosMemoryFree(pthread); diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 777eb23caa..6ade226cd8 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -138,7 +138,7 @@ static uintptr_t getNextTimerId() { return id; } -static void timerAddRef(tmr_obj_t* timer) { atomic_add_fetch_8(&timer->refCount, 1); } +static void timerAddRef(tmr_obj_t* timer) { (void)atomic_add_fetch_8(&timer->refCount, 1); } static void timerDecRef(tmr_obj_t* timer) { if (atomic_sub_fetch_8(&timer->refCount, 1) == 0) { @@ -151,7 +151,7 @@ static void lockTimerList(timer_list_t* list) { int32_t i = 0; while (atomic_val_compare_exchange_64(&(list->lockedBy), 0, tid) != 0) { if (++i % 1000 == 0) { - sched_yield(); + (void)sched_yield(); } } } @@ -314,7 +314,7 @@ static void addToExpired(tmr_obj_t* head) { schedMsg.msg = NULL; schedMsg.ahandle = head; schedMsg.thandle = NULL; - taosScheduleTask(tmrQhandle, &schedMsg); + (void)taosScheduleTask(tmrQhandle, &schedMsg); tmrDebug("timer[id=%" PRIuPTR "] has been added to queue.", id); head = next; @@ -458,7 +458,7 @@ bool taosTmrStop(tmr_h timerId) { } uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED); - doStopTimer(timer, state); + (void)doStopTimer(timer, state); timerDecRef(timer); return state == TIMER_STATE_WAITING; @@ -501,7 +501,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* han // so that we can reuse this timer safely. for (int32_t i = 1; atomic_load_8(&timer->refCount) > 1; ++i) { if (i % 1000 == 0) { - sched_yield(); + (void)sched_yield(); } } @@ -528,7 +528,7 @@ static int32_t taosTmrModuleInit(void) { (tmrCtrls + tsMaxTmrCtrl - 1)->next = NULL; unusedTmrCtrl = tmrCtrls; - taosThreadMutexInit(&tmrCtrlMutex, NULL); + (void)taosThreadMutexInit(&tmrCtrlMutex, NULL); int64_t now = taosGetMonotonicMs(); for (int32_t i = 0; i < tListLen(wheels); i++) { @@ -555,7 +555,7 @@ static int32_t taosTmrModuleInit(void) { } tmrQhandle = taosInitScheduler(10000, taosTmrThreads, "tmr", NULL); - taosInitTimer(taosTimerLoopFunc, MSECONDS_PER_TICK); + (void)taosInitTimer(taosTimerLoopFunc, MSECONDS_PER_TICK); tmrDebug("timer module is initialized, number of threads: %d", taosTmrThreads); @@ -638,11 +638,11 @@ void taosTmrCleanUp(void* handle) { for (int32_t i = 0; i < tListLen(wheels); i++) { time_wheel_t* wheel = wheels + i; - taosThreadMutexDestroy(&wheel->mutex); + (void)taosThreadMutexDestroy(&wheel->mutex); taosMemoryFree(wheel->slots); } - taosThreadMutexDestroy(&tmrCtrlMutex); + (void)taosThreadMutexDestroy(&tmrCtrlMutex); for (size_t i = 0; i < timerMap.size; i++) { timer_list_t* list = timerMap.slots + i; diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index a14ea1a3cd..94f514e208 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -320,7 +320,7 @@ char *strbetween(char *string, char *begin, char *end) { int32_t size = (int32_t)(_end - _begin); if (_end != NULL && size > 0) { result = (char *)taosMemoryCalloc(1, size); - if (result) { + if (!result) { return NULL; } memcpy(result, _begin + strlen(begin), size - +strlen(begin)); diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index 885813f527..d66628d46d 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -58,15 +58,15 @@ void tQWorkerCleanup(SQWorkerPool *pool) { SQueueWorker *worker = pool->workers + i; if (taosCheckPthreadValid(worker->thread)) { uInfo("worker:%s:%d is stopping", pool->name, worker->id); - taosThreadJoin(worker->thread, NULL); - taosThreadClear(&worker->thread); + (void)taosThreadJoin(worker->thread, NULL); + (void)taosThreadClear(&worker->thread); uInfo("worker:%s:%d is stopped", pool->name, worker->id); } } taosMemoryFreeClear(pool->workers); taosCloseQset(pool->qset); - taosThreadMutexDestroy(&pool->mutex); + (void)taosThreadMutexDestroy(&pool->mutex); uInfo("worker:%s is closed", pool->name); } @@ -77,7 +77,7 @@ static void *tQWorkerThreadFp(SQueueWorker *worker) { void *msg = NULL; int32_t code = 0; - taosBlockSIGPIPE(); + (void)taosBlockSIGPIPE(); setThreadName(pool->name); worker->pid = taosGetSelfPthreadId(); uInfo("worker:%s:%d is running, thread:%08" PRId64, pool->name, worker->id, worker->pid); @@ -122,7 +122,7 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) { (void)taosThreadMutexLock(&pool->mutex); taosSetQueueFp(queue, fp, NULL); - taosAddIntoQset(pool->qset, queue, ahandle); + (void)taosAddIntoQset(pool->qset, queue, ahandle); // spawn a thread to process queue if (pool->num < pool->max) { @@ -130,8 +130,8 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) { SQueueWorker *worker = pool->workers + pool->num; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&worker->thread, &thAttr, (ThreadFp)tQWorkerThreadFp, worker) != 0) { taosCloseQueue(queue); @@ -140,7 +140,7 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) { break; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); pool->num++; uInfo("worker:%s:%d is launched, total:%d", pool->name, worker->id, pool->num); } while (pool->num < pool->min); @@ -190,8 +190,8 @@ void tAutoQWorkerCleanup(SAutoQWorkerPool *pool) { SQueueWorker *worker = taosArrayGetP(pool->workers, i); if (taosCheckPthreadValid(worker->thread)) { uInfo("worker:%s:%d is stopping", pool->name, worker->id); - taosThreadJoin(worker->thread, NULL); - taosThreadClear(&worker->thread); + (void)taosThreadJoin(worker->thread, NULL); + (void)taosThreadClear(&worker->thread); uInfo("worker:%s:%d is stopped", pool->name, worker->id); } taosMemoryFree(worker); @@ -199,7 +199,7 @@ void tAutoQWorkerCleanup(SAutoQWorkerPool *pool) { taosArrayDestroy(pool->workers); taosCloseQset(pool->qset); - taosThreadMutexDestroy(&pool->mutex); + (void)taosThreadMutexDestroy(&pool->mutex); uInfo("worker:%s is closed", pool->name); } @@ -210,7 +210,7 @@ static void *tAutoQWorkerThreadFp(SQueueWorker *worker) { void *msg = NULL; int32_t code = 0; - taosBlockSIGPIPE(); + (void)taosBlockSIGPIPE(); setThreadName(pool->name); worker->pid = taosGetSelfPthreadId(); uInfo("worker:%s:%d is running, thread:%08" PRId64, pool->name, worker->id, worker->pid); @@ -253,7 +253,7 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem (void)taosThreadMutexLock(&pool->mutex); taosSetQueueFp(queue, fp, NULL); - taosAddIntoQset(pool->qset, queue, ahandle); + (void)taosAddIntoQset(pool->qset, queue, ahandle); int32_t queueNum = taosGetQueueNumber(pool->qset); int32_t curWorkerNum = taosArrayGetSize(pool->workers); @@ -275,8 +275,8 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem worker->pool = pool; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&worker->thread, &thAttr, (ThreadFp)tAutoQWorkerThreadFp, worker) != 0) { uError("worker:%s:%d failed to create thread, total:%d", pool->name, worker->id, curWorkerNum); @@ -287,7 +287,7 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem return NULL; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); int32_t numOfThreads = taosArrayGetSize(pool->workers); uInfo("worker:%s:%d is launched, total:%d, expect:%d", pool->name, worker->id, numOfThreads, dstWorkerNum); @@ -340,8 +340,8 @@ void tWWorkerCleanup(SWWorkerPool *pool) { SWWorker *worker = pool->workers + i; if (taosCheckPthreadValid(worker->thread)) { uInfo("worker:%s:%d is stopping", pool->name, worker->id); - taosThreadJoin(worker->thread, NULL); - taosThreadClear(&worker->thread); + (void)taosThreadJoin(worker->thread, NULL); + (void)taosThreadClear(&worker->thread); taosFreeQall(worker->qall); taosCloseQset(worker->qset); uInfo("worker:%s:%d is stopped", pool->name, worker->id); @@ -349,7 +349,7 @@ void tWWorkerCleanup(SWWorkerPool *pool) { } taosMemoryFreeClear(pool->workers); - taosThreadMutexDestroy(&pool->mutex); + (void)taosThreadMutexDestroy(&pool->mutex); uInfo("worker:%s is closed", pool->name); } @@ -361,7 +361,7 @@ static void *tWWorkerThreadFp(SWWorker *worker) { int32_t code = 0; int32_t numOfMsgs = 0; - taosBlockSIGPIPE(); + (void)taosBlockSIGPIPE(); setThreadName(pool->name); worker->pid = taosGetSelfPthreadId(); uInfo("worker:%s:%d is running, thread:%08" PRId64, pool->name, worker->id, worker->pid); @@ -406,23 +406,23 @@ STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) { code = taosOpenQset(&worker->qset); if (code) goto _OVER; - taosAddIntoQset(worker->qset, queue, ahandle); + (void)taosAddIntoQset(worker->qset, queue, ahandle); code = taosAllocateQall(&worker->qall); if (code) goto _OVER; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&worker->thread, &thAttr, (ThreadFp)tWWorkerThreadFp, worker) != 0) goto _OVER; uInfo("worker:%s:%d is launched, max:%d", pool->name, worker->id, pool->max); pool->nextId = (pool->nextId + 1) % pool->max; - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); pool->num++; if (pool->num > pool->max) pool->num = pool->max; } else { - taosAddIntoQset(worker->qset, queue, ahandle); + (void)taosAddIntoQset(worker->qset, queue, ahandle); pool->nextId = (pool->nextId + 1) % pool->max; } @@ -628,7 +628,7 @@ static void *tQueryAutoQWorkerThreadFp(SQueryAutoQWorker *worker) { void *msg = NULL; int32_t code = 0; - taosBlockSIGPIPE(); + (void)taosBlockSIGPIPE(); setThreadName(pool->name); worker->pid = taosGetSelfPthreadId(); uDebug("worker:%s:%d is running, thread:%08" PRId64, pool->name, worker->id, worker->pid); @@ -647,7 +647,7 @@ static void *tQueryAutoQWorkerThreadFp(SQueryAutoQWorker *worker) { } } - tQueryAutoQWorkerWaitingCheck(pool); + (void)tQueryAutoQWorkerWaitingCheck(pool); if (qinfo.fp != NULL) { qinfo.workerId = worker->id; @@ -676,7 +676,7 @@ static bool tQueryAutoQWorkerTrySignalWaitingAfterBlock(void *p) { int32_t waitingNew = atomic_val_compare_exchange_32(&pPool->waitingAfterBlockN, waiting, waiting - 1); if (waitingNew == waiting) { (void)taosThreadMutexLock(&pPool->waitingAfterBlockLock); - taosThreadCondSignal(&pPool->waitingAfterBlockCond); + (void)taosThreadCondSignal(&pPool->waitingAfterBlockCond); (void)taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); ret = true; break; @@ -694,7 +694,7 @@ static bool tQueryAutoQWorkerTrySignalWaitingBeforeProcess(void *p) { int32_t waitingNew = atomic_val_compare_exchange_32(&pPool->waitingBeforeProcessMsgN, waiting, waiting - 1); if (waitingNew == waiting) { (void)taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); - taosThreadCondSignal(&pPool->waitingBeforeProcessMsgCond); + (void)taosThreadCondSignal(&pPool->waitingBeforeProcessMsgCond); (void)taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); ret = true; break; @@ -713,7 +713,7 @@ static bool tQueryAutoQWorkerTryDecActive(void *p, int32_t minActive) { if (atomicCompareExchangeActiveAndRunning(&pPool->activeRunningN, &active, active - 1, &running, running - 1)) return true; } - atomicFetchSubRunning(&pPool->activeRunningN, 1); + (void)atomicFetchSubRunning(&pPool->activeRunningN, 1); return false; } @@ -732,8 +732,8 @@ static int32_t tQueryAutoQWorkerWaitingCheck(SQueryAutoQWorkerPool *pPool) { } // to wait for process (void)taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); - atomic_fetch_add_32(&pPool->waitingBeforeProcessMsgN, 1); - if (!pPool->exit) taosThreadCondWait(&pPool->waitingBeforeProcessMsgCond, &pPool->waitingBeforeProcessMsgLock); + (void)atomic_fetch_add_32(&pPool->waitingBeforeProcessMsgN, 1); + if (!pPool->exit) (void)taosThreadCondWait(&pPool->waitingBeforeProcessMsgCond, &pPool->waitingBeforeProcessMsgLock); // recovered from waiting (void)taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); return TSDB_CODE_SUCCESS; @@ -744,15 +744,15 @@ bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQ tQueryAutoQWorkerTryDecActive(pPool, pPool->num)) { (void)taosThreadMutexLock(&pPool->poolLock); SListNode *pNode = listNode(pWorker); - tdListPopNode(pPool->workers, pNode); + (void)tdListPopNode(pPool->workers, pNode); // reclaim some workers if (pWorker->id >= pPool->maxInUse) { while (listNEles(pPool->exitedWorkers) > pPool->maxInUse - pPool->num) { SListNode *head = tdListPopHead(pPool->exitedWorkers); SQueryAutoQWorker *pWorker = (SQueryAutoQWorker *)head->data; if (pWorker && taosCheckPthreadValid(pWorker->thread)) { - taosThreadJoin(pWorker->thread, NULL); - taosThreadClear(&pWorker->thread); + (void)taosThreadJoin(pWorker->thread, NULL); + (void)taosThreadClear(&pWorker->thread); } taosMemoryFree(head); } @@ -767,8 +767,8 @@ bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQ // start to wait at backup cond (void)taosThreadMutexLock(&pPool->backupLock); - atomic_fetch_add_32(&pPool->backupNum, 1); - if (!pPool->exit) taosThreadCondWait(&pPool->backupCond, &pPool->backupLock); + (void)atomic_fetch_add_32(&pPool->backupNum, 1); + if (!pPool->exit) (void)taosThreadCondWait(&pPool->backupCond, &pPool->backupLock); (void)taosThreadMutexUnlock(&pPool->backupLock); // recovered from backup @@ -777,7 +777,7 @@ bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQ (void)taosThreadMutexUnlock(&pPool->poolLock); return false; } - tdListPopNode(pPool->backupWorkers, pNode); + (void)tdListPopNode(pPool->backupWorkers, pNode); tdListAppendNode(pPool->workers, pNode); (void)taosThreadMutexUnlock(&pPool->poolLock); @@ -832,15 +832,15 @@ void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { (void)taosThreadMutexUnlock(&pPool->poolLock); (void)taosThreadMutexLock(&pPool->backupLock); - taosThreadCondBroadcast(&pPool->backupCond); + (void)taosThreadCondBroadcast(&pPool->backupCond); (void)taosThreadMutexUnlock(&pPool->backupLock); (void)taosThreadMutexLock(&pPool->waitingAfterBlockLock); - taosThreadCondBroadcast(&pPool->waitingAfterBlockCond); + (void)taosThreadCondBroadcast(&pPool->waitingAfterBlockCond); (void)taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); (void)taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); - taosThreadCondBroadcast(&pPool->waitingBeforeProcessMsgCond); + (void)taosThreadCondBroadcast(&pPool->waitingBeforeProcessMsgCond); (void)taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); int32_t idx = 0; @@ -855,8 +855,8 @@ void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { worker = (SQueryAutoQWorker *)pNode->data; (void)taosThreadMutexUnlock(&pPool->poolLock); if (worker && taosCheckPthreadValid(worker->thread)) { - taosThreadJoin(worker->thread, NULL); - taosThreadClear(&worker->thread); + (void)taosThreadJoin(worker->thread, NULL); + (void)taosThreadClear(&worker->thread); } taosMemoryFree(pNode); } @@ -865,8 +865,8 @@ void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { SListNode *pNode = tdListPopHead(pPool->backupWorkers); worker = (SQueryAutoQWorker *)pNode->data; if (worker && taosCheckPthreadValid(worker->thread)) { - taosThreadJoin(worker->thread, NULL); - taosThreadClear(&worker->thread); + (void)taosThreadJoin(worker->thread, NULL); + (void)taosThreadClear(&worker->thread); } taosMemoryFree(pNode); } @@ -875,25 +875,25 @@ void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { SListNode *pNode = tdListPopHead(pPool->exitedWorkers); worker = (SQueryAutoQWorker *)pNode->data; if (worker && taosCheckPthreadValid(worker->thread)) { - taosThreadJoin(worker->thread, NULL); - taosThreadClear(&worker->thread); + (void)taosThreadJoin(worker->thread, NULL); + (void)taosThreadClear(&worker->thread); } taosMemoryFree(pNode); } - tdListFree(pPool->workers); - tdListFree(pPool->backupWorkers); - tdListFree(pPool->exitedWorkers); + (void)tdListFree(pPool->workers); + (void)tdListFree(pPool->backupWorkers); + (void)tdListFree(pPool->exitedWorkers); taosMemoryFree(pPool->pCb); - taosThreadMutexDestroy(&pPool->poolLock); - taosThreadMutexDestroy(&pPool->backupLock); - taosThreadMutexDestroy(&pPool->waitingAfterBlockLock); - taosThreadMutexDestroy(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexDestroy(&pPool->poolLock); + (void)taosThreadMutexDestroy(&pPool->backupLock); + (void)taosThreadMutexDestroy(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexDestroy(&pPool->waitingBeforeProcessMsgLock); - taosThreadCondDestroy(&pPool->backupCond); - taosThreadCondDestroy(&pPool->waitingAfterBlockCond); - taosThreadCondDestroy(&pPool->waitingBeforeProcessMsgCond); + (void)taosThreadCondDestroy(&pPool->backupCond); + (void)taosThreadCondDestroy(&pPool->waitingAfterBlockCond); + (void)taosThreadCondDestroy(&pPool->waitingBeforeProcessMsgCond); taosCloseQset(pPool->qset); } @@ -907,7 +907,7 @@ STaosQueue *tQueryAutoQWorkerAllocQueue(SQueryAutoQWorkerPool *pool, void *ahand (void)taosThreadMutexLock(&pool->poolLock); taosSetQueueFp(queue, fp, NULL); - taosAddIntoQset(pool->qset, queue, ahandle); + (void)taosAddIntoQset(pool->qset, queue, ahandle); SQueryAutoQWorker worker = {0}; SQueryAutoQWorker *pWorker = NULL; @@ -927,8 +927,8 @@ STaosQueue *tQueryAutoQWorkerAllocQueue(SQueryAutoQWorkerPool *pool, void *ahand pWorker = (SQueryAutoQWorker *)pNode->data; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pWorker->thread, &thAttr, (ThreadFp)tQueryAutoQWorkerThreadFp, pWorker) != 0) { taosCloseQueue(queue); @@ -937,9 +937,9 @@ STaosQueue *tQueryAutoQWorkerAllocQueue(SQueryAutoQWorkerPool *pool, void *ahand break; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); pool->num++; - atomicFetchAddActive(&pool->activeRunningN, 1); + (void)atomicFetchAddActive(&pool->activeRunningN, 1); uInfo("worker:%s:%d is launched, total:%d", pool->name, pWorker->id, pool->num); } while (pool->num < pool->min); } @@ -958,7 +958,7 @@ static int32_t tQueryAutoQWorkerAddWorker(SQueryAutoQWorkerPool *pool) { while (backup > 0) { int32_t backupNew = atomic_val_compare_exchange_32(&pool->backupNum, backup, backup - 1); if (backupNew == backup) { - taosThreadCondSignal(&pool->backupCond); + (void)taosThreadCondSignal(&pool->backupCond); return TSDB_CODE_SUCCESS; } backup = backupNew; @@ -980,14 +980,14 @@ static int32_t tQueryAutoQWorkerAddWorker(SQueryAutoQWorkerPool *pool) { pWorker = (SQueryAutoQWorker *)pNode->data; TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + (void)taosThreadAttrInit(&thAttr); + (void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); if (taosThreadCreate(&pWorker->thread, &thAttr, (ThreadFp)tQueryAutoQWorkerThreadFp, pWorker) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); return TSDB_CODE_SUCCESS; } @@ -1016,8 +1016,8 @@ static int32_t tQueryAutoQWorkerRecoverFromBlocking(void *p) { } } (void)taosThreadMutexLock(&pPool->waitingAfterBlockLock); - atomic_fetch_add_32(&pPool->waitingAfterBlockN, 1); - if (!pPool->exit) taosThreadCondWait(&pPool->waitingAfterBlockCond, &pPool->waitingAfterBlockLock); + (void)atomic_fetch_add_32(&pPool->waitingAfterBlockN, 1); + if (!pPool->exit) (void)taosThreadCondWait(&pPool->waitingAfterBlockCond, &pPool->waitingAfterBlockLock); (void)taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); if (pPool->exit) return TSDB_CODE_QRY_QWORKER_QUIT; return TSDB_CODE_SUCCESS; diff --git a/tests/script/tsim/stream/session0.sim b/tests/script/tsim/stream/session0.sim index 38adae4261..0d92070d10 100644 --- a/tests/script/tsim/stream/session0.sim +++ b/tests/script/tsim/stream/session0.sim @@ -189,11 +189,11 @@ run tsim/stream/checkTaskStatus.sim sql insert into t2 values(1648791213001,1,1,3,1.0,1); sql insert into t2 values(1648791213002,2,2,6,3.4,2); sql insert into t2 values(1648791213003,4,9,3,4.8,3); -sql insert into t2 values(1648791233003,3,4,3,2.1,4); -sql insert into t2 values(1648791233004,3,5,3,3.4,5); -sql insert into t2 values(1648791233005,3,6,3,7.6,6); -# +sql insert into t2 values(1648791233003,3,4,3,2.1,4) (1648791233004,3,5,3,3.4,5) (1648791233005,3,6,3,7.6,6); + +sleep 1000 + sql insert into t2 values(1648791223003,20,7,3,10.1,7); $loop_count = 0 diff --git a/tests/system-test/2-query/tsma2.py b/tests/system-test/2-query/tsma2.py index ded30412a5..5af75b6fb9 100644 --- a/tests/system-test/2-query/tsma2.py +++ b/tests/system-test/2-query/tsma2.py @@ -615,6 +615,8 @@ class TDTestCase: self.replicaVar = int(replicaVar) tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), False) + tdSql.execute('alter local "debugFlag" "143"') + tdSql.execute('alter dnode 1 "debugFlag" "143"') self.tsma_tester: TSMATester = TSMATester(tdSql) self.tsma_sql_generator: TSMATestSQLGenerator = TSMATestSQLGenerator() diff --git a/tests/system-test/8-stream/snode_restart_with_checkpoint.py b/tests/system-test/8-stream/snode_restart_with_checkpoint.py index 9eb8c09ca3..28875df035 100644 --- a/tests/system-test/8-stream/snode_restart_with_checkpoint.py +++ b/tests/system-test/8-stream/snode_restart_with_checkpoint.py @@ -51,7 +51,9 @@ class TDTestCase: for i in range(rowCnt): results.append(tdSql.getData(i,1)) - tdSql.query("select * from st1 order by groupid,_wstart") + sql = "select * from st1 order by groupid,_wstart" + tdSql.check_rows_loop(rowCnt, sql, loopCount=100, waitTime=0.5) + tdSql.checkRows(rowCnt) for i in range(rowCnt): data1 = tdSql.getData(i,1)