diff --git a/deps/arm/dm_static/libdmodule.a b/deps/arm/dm_static/libdmodule.a index 989676d14d..06d509b51b 100644 Binary files a/deps/arm/dm_static/libdmodule.a and b/deps/arm/dm_static/libdmodule.a differ diff --git a/deps/mips/dm_static/libdmodule.a b/deps/mips/dm_static/libdmodule.a index 167b932121..b60727d440 100644 Binary files a/deps/mips/dm_static/libdmodule.a and b/deps/mips/dm_static/libdmodule.a differ diff --git a/deps/x86/dm_static/libdmodule.a b/deps/x86/dm_static/libdmodule.a index 9f17b4c118..f2d3f600ce 100644 Binary files a/deps/x86/dm_static/libdmodule.a and b/deps/x86/dm_static/libdmodule.a differ diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 4476eee447..b06adf3f2d 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1763,6 +1763,14 @@ int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq); int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq); void tFreeSStatusReq(SStatusReq* pReq); +typedef struct { + int32_t dnodeId; + char machineId[TSDB_MACHINE_ID_LEN + 1]; +} SDnodeInfoReq; + +int32_t tSerializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq); +int32_t tDeserializeSDnodeInfoReq(void* buf, int32_t bufLen, SDnodeInfoReq* pReq); + typedef enum { MONITOR_TYPE_COUNTER = 0, MONITOR_TYPE_SLOW_LOG = 1, @@ -3647,7 +3655,7 @@ int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal); int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal); 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 tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight); void tOffsetDestroy(void* pVal); typedef struct { diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index b73a15ebcc..572e26bc62 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -253,7 +253,7 @@ TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CONSEN_TIMER, "stream-consen-tmr", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_STREAM_DROP_ORPHANTASKS, "stream-drop-orphan-tasks", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_STREAM_TASK_RESET, "stream-reset-tasks", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_UPDATE_DNODE_INFO, "update-dnode-info", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG) TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8 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/tdatablock.c b/source/common/src/tdatablock.c index bda2de3a1c..82bd1b24f6 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -87,7 +87,7 @@ int32_t getJsonValueLen(const char* data) { } int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull) { - if (isNull) { + if (isNull || pData == NULL) { // There is a placehold for each NULL value of binary or nchar type. if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { pColumnInfoData->varmeta.offset[rowIndex] = -1; // it is a null value of VAR type. diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index ebaf1041c9..46219fe34c 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -319,9 +319,15 @@ int32_t tsMaxTsmaNum = 3; int32_t tsMaxTsmaCalcDelay = 600; int64_t tsmaDataDeleteMark = 1000 * 60 * 60 * 24; // in ms, default to 1d +#define TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, pName) \ + if ((pItem = cfgGetItem(pCfg, pName)) == NULL) { \ + TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); \ + } + #ifndef _STORAGE int32_t taosSetTfsCfg(SConfig *pCfg) { - SConfigItem *pItem = cfgGetItem(pCfg, "dataDir"); + SConfigItem *pItem = NULL; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "dataDir"); (void)memset(tsDataDir, 0, PATH_MAX); int32_t size = taosArrayGetSize(pItem->array); @@ -343,7 +349,10 @@ int32_t taosSetTfsCfg(SConfig *pCfg); #endif int32_t taosSetS3Cfg(SConfig *pCfg) { - tstrncpy(tsS3AccessKey, cfgGetItem(pCfg, "s3Accesskey")->str, TSDB_FQDN_LEN); + SConfigItem *pItem = NULL; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3Accesskey"); + tstrncpy(tsS3AccessKey, pItem->str, TSDB_FQDN_LEN); if (tsS3AccessKey[0] == '<') { TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -355,8 +364,10 @@ int32_t taosSetS3Cfg(SConfig *pCfg) { *colon = '\0'; tstrncpy(tsS3AccessKeyId, tsS3AccessKey, TSDB_FQDN_LEN); tstrncpy(tsS3AccessKeySecret, colon + 1, TSDB_FQDN_LEN); - tstrncpy(tsS3Endpoint, cfgGetItem(pCfg, "s3Endpoint")->str, TSDB_FQDN_LEN); - tstrncpy(tsS3BucketName, cfgGetItem(pCfg, "s3BucketName")->str, TSDB_FQDN_LEN); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3Endpoint"); + tstrncpy(tsS3Endpoint, pItem->str, TSDB_FQDN_LEN); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3BucketName"); + tstrncpy(tsS3BucketName, pItem->str, TSDB_FQDN_LEN); char *proto = strstr(tsS3Endpoint, "https://"); if (!proto) { tsS3Https = false; @@ -785,7 +796,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { int32_t numOfCores; int64_t totalMemoryKB; - pItem = cfgGetItem(tsCfg, "numOfCores"); + pItem = cfgGetItem(pCfg, "numOfCores"); if (pItem == NULL) { TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); } else { @@ -793,7 +804,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { numOfCores = pItem->fval; } - pItem = cfgGetItem(tsCfg, "supportVnodes"); + pItem = cfgGetItem(pCfg, "supportVnodes"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfSupportVnodes = numOfCores * 2 + 5; tsNumOfSupportVnodes = TMAX(tsNumOfSupportVnodes, 2); @@ -801,7 +812,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfRpcThreads"); + pItem = cfgGetItem(pCfg, "numOfRpcThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfRpcThreads = numOfCores / 2; tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 2, TSDB_MAX_RPC_THREADS); @@ -809,21 +820,21 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfRpcSessions"); + pItem = cfgGetItem(pCfg, "numOfRpcSessions"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfRpcSessions = TRANGE(tsNumOfRpcSessions, 100, 10000); pItem->i32 = tsNumOfRpcSessions; pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "timeToGetAvailableConn"); + pItem = cfgGetItem(pCfg, "timeToGetAvailableConn"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsTimeToGetAvailableConn = TRANGE(tsTimeToGetAvailableConn, 20, 1000000); pItem->i32 = tsTimeToGetAvailableConn; pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfCommitThreads"); + pItem = cfgGetItem(pCfg, "numOfCommitThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfCommitThreads = numOfCores / 2; tsNumOfCommitThreads = TRANGE(tsNumOfCommitThreads, 2, 4); @@ -831,7 +842,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfMnodeReadThreads"); + pItem = cfgGetItem(pCfg, "numOfMnodeReadThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfMnodeReadThreads = numOfCores / 8; tsNumOfMnodeReadThreads = TRANGE(tsNumOfMnodeReadThreads, 1, 4); @@ -839,7 +850,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfVnodeQueryThreads"); + pItem = cfgGetItem(pCfg, "numOfVnodeQueryThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfVnodeQueryThreads = numOfCores * 2; tsNumOfVnodeQueryThreads = TMAX(tsNumOfVnodeQueryThreads, 16); @@ -847,13 +858,13 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "ratioOfVnodeStreamThreads"); + pItem = cfgGetItem(pCfg, "ratioOfVnodeStreamThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { pItem->fval = tsRatioOfVnodeStreamThreads; pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfVnodeFetchThreads"); + pItem = cfgGetItem(pCfg, "numOfVnodeFetchThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfVnodeFetchThreads = numOfCores / 4; tsNumOfVnodeFetchThreads = TMAX(tsNumOfVnodeFetchThreads, 4); @@ -861,7 +872,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfVnodeRsmaThreads"); + pItem = cfgGetItem(pCfg, "numOfVnodeRsmaThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfVnodeRsmaThreads = numOfCores; tsNumOfVnodeRsmaThreads = TMAX(tsNumOfVnodeRsmaThreads, 4); @@ -869,7 +880,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfQnodeQueryThreads"); + pItem = cfgGetItem(pCfg, "numOfQnodeQueryThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfQnodeQueryThreads = numOfCores * 2; tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 16); @@ -877,17 +888,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - /* - pItem = cfgGetItem(tsCfg, "numOfQnodeFetchThreads"); - if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { - tsNumOfQnodeFetchThreads = numOfCores / 2; - tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4); - pItem->i32 = tsNumOfQnodeFetchThreads; - pItem->stype = stype; - } - */ - - pItem = cfgGetItem(tsCfg, "numOfSnodeSharedThreads"); + pItem = cfgGetItem(pCfg, "numOfSnodeSharedThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfSnodeStreamThreads = numOfCores / 4; tsNumOfSnodeStreamThreads = TRANGE(tsNumOfSnodeStreamThreads, 2, 4); @@ -895,7 +896,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "numOfSnodeUniqueThreads"); + pItem = cfgGetItem(pCfg, "numOfSnodeUniqueThreads"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsNumOfSnodeWriteThreads = numOfCores / 4; tsNumOfSnodeWriteThreads = TRANGE(tsNumOfSnodeWriteThreads, 2, 4); @@ -903,7 +904,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { pItem->stype = stype; } - pItem = cfgGetItem(tsCfg, "totalMemoryKB"); + pItem = cfgGetItem(pCfg, "totalMemoryKB"); if (pItem == NULL) { TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); } else { @@ -911,7 +912,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { totalMemoryKB = pItem->i64; } - pItem = cfgGetItem(tsCfg, "rpcQueueMemoryAllowed"); + pItem = cfgGetItem(pCfg, "rpcQueueMemoryAllowed"); if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) { tsRpcQueueMemoryAllowed = totalMemoryKB * 1024 * 0.1; tsRpcQueueMemoryAllowed = TRANGE(tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10LL, TSDB_MAX_MSG_SIZE * 10000LL); @@ -922,39 +923,97 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) { TAOS_RETURN(TSDB_CODE_SUCCESS); } -static void taosSetClientLogCfg(SConfig *pCfg) { - SConfigItem *pItem = cfgGetItem(pCfg, "logDir"); - tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX); - taosExpandDir(tsLogDir, tsLogDir, PATH_MAX); - tsLogSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalLogDirGB")->fval) * 1024 * 1024 * 1024); - tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32; - tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval; - tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32; - tmrDebugFlag = cfgGetItem(pCfg, "tmrDebugFlag")->i32; - uDebugFlag = cfgGetItem(pCfg, "uDebugFlag")->i32; - jniDebugFlag = cfgGetItem(pCfg, "jniDebugFlag")->i32; - rpcDebugFlag = cfgGetItem(pCfg, "rpcDebugFlag")->i32; - qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32; - cDebugFlag = cfgGetItem(pCfg, "cDebugFlag")->i32; - simDebugFlag = cfgGetItem(pCfg, "simDebugFlag")->i32; +static int32_t taosSetClientLogCfg(SConfig *pCfg) { + SConfigItem *pItem = NULL; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "logDir"); + tstrncpy(tsLogDir, pItem->str, PATH_MAX); + TAOS_CHECK_RETURN(taosExpandDir(tsLogDir, tsLogDir, PATH_MAX)); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minimalLogDirGB"); + tsLogSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfLogLines"); + tsNumOfLogLines = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "asyncLog"); + tsAsyncLog = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "logKeepDays"); + tsLogKeepDays = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tmrDebugFlag"); + tmrDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "uDebugFlag"); + uDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "jniDebugFlag"); + jniDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rpcDebugFlag"); + rpcDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "qDebugFlag"); + qDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "cDebugFlag"); + cDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "simDebugFlag"); + simDebugFlag = pItem->i32; + + TAOS_RETURN(TSDB_CODE_SUCCESS); } -static void taosSetServerLogCfg(SConfig *pCfg) { - dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32; - vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32; - mDebugFlag = cfgGetItem(pCfg, "mDebugFlag")->i32; - wDebugFlag = cfgGetItem(pCfg, "wDebugFlag")->i32; - sDebugFlag = cfgGetItem(pCfg, "sDebugFlag")->i32; - tsdbDebugFlag = cfgGetItem(pCfg, "tsdbDebugFlag")->i32; - tqDebugFlag = cfgGetItem(pCfg, "tqDebugFlag")->i32; - fsDebugFlag = cfgGetItem(pCfg, "fsDebugFlag")->i32; - udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32; - smaDebugFlag = cfgGetItem(pCfg, "smaDebugFlag")->i32; - idxDebugFlag = cfgGetItem(pCfg, "idxDebugFlag")->i32; - tdbDebugFlag = cfgGetItem(pCfg, "tdbDebugFlag")->i32; - metaDebugFlag = cfgGetItem(pCfg, "metaDebugFlag")->i32; - stDebugFlag = cfgGetItem(pCfg, "stDebugFlag")->i32; - sndDebugFlag = cfgGetItem(pCfg, "sndDebugFlag")->i32; +static int32_t taosSetServerLogCfg(SConfig *pCfg) { + SConfigItem *pItem = NULL; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "dDebugFlag"); + dDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "vDebugFlag"); + vDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "mDebugFlag"); + mDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "wDebugFlag"); + wDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "sDebugFlag"); + sDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tsdbDebugFlag"); + tsdbDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tqDebugFlag"); + tqDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "fsDebugFlag"); + fsDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "udfDebugFlag"); + udfDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "smaDebugFlag"); + smaDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "idxDebugFlag"); + idxDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tdbDebugFlag"); + tdbDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "metaDebugFlag"); + metaDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "stDebugFlag"); + stDebugFlag = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "sndDebugFlag"); + sndDebugFlag = pItem->i32; + + TAOS_RETURN(TSDB_CODE_SUCCESS); } int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope) { @@ -1008,105 +1067,159 @@ int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope) { // for common configs static int32_t taosSetClientCfg(SConfig *pCfg) { - tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN); - tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; + SConfigItem *pItem = NULL; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "fqdn"); + tstrncpy(tsLocalFqdn, pItem->str, TSDB_FQDN_LEN); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "serverPort"); + tsServerPort = (uint16_t)pItem->i32; (void)snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort); char defaultFirstEp[TSDB_EP_LEN] = {0}; (void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort); - SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp"); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "firstEp"); SEp firstEp = {0}; - TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp)); + TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pItem->str) == 0 ? defaultFirstEp : pItem->str, &firstEp)); (void)snprintf(tsFirst, sizeof(tsFirst), "%s:%u", firstEp.fqdn, firstEp.port); - TAOS_CHECK_RETURN(cfgSetItem(pCfg, "firstEp", tsFirst, pFirstEpItem->stype, true)); + TAOS_CHECK_RETURN(cfgSetItem(pCfg, "firstEp", tsFirst, pItem->stype, true)); - SConfigItem *pSecondpItem = cfgGetItem(pCfg, "secondEp"); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "secondEp"); SEp secondEp = {0}; - TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pSecondpItem->str) == 0 ? defaultFirstEp : pSecondpItem->str, &secondEp)); + TAOS_CHECK_RETURN(taosGetFqdnPortFromEp(strlen(pItem->str) == 0 ? defaultFirstEp : pItem->str, &secondEp)); (void)snprintf(tsSecond, sizeof(tsSecond), "%s:%u", secondEp.fqdn, secondEp.port); - TAOS_CHECK_RETURN(cfgSetItem(pCfg, "secondEp", tsSecond, pSecondpItem->stype, true)); + TAOS_CHECK_RETURN(cfgSetItem(pCfg, "secondEp", tsSecond, pItem->stype, true)); - tstrncpy(tsTempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tempDir"); + tstrncpy(tsTempDir, pItem->str, PATH_MAX); TAOS_CHECK_RETURN(taosExpandDir(tsTempDir, tsTempDir, PATH_MAX)); - tsTempSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalTmpDirGB")->fval) * 1024 * 1024 * 1024); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minimalTmpDirGB"); + tsTempSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); if (taosMulMkDir(tsTempDir) != 0) { int32_t code = TAOS_SYSTEM_ERROR(errno); uError("failed to create tempDir:%s since %s", tsTempDir, tstrerror(code)); TAOS_RETURN(code); } - tstrncpy(tsSmlAutoChildTableNameDelimiter, cfgGetItem(pCfg, "smlAutoChildTableNameDelimiter")->str, - TSDB_TABLE_NAME_LEN); - tstrncpy(tsSmlChildTableName, cfgGetItem(pCfg, "smlChildTableName")->str, TSDB_TABLE_NAME_LEN); - tstrncpy(tsSmlTagName, cfgGetItem(pCfg, "smlTagName")->str, TSDB_COL_NAME_LEN); - tstrncpy(tsSmlTsDefaultName, cfgGetItem(pCfg, "smlTsDefaultName")->str, TSDB_COL_NAME_LEN); - tsSmlDot2Underline = cfgGetItem(pCfg, "smlDot2Underline")->bval; - // tsSmlDataFormat = cfgGetItem(pCfg, "smlDataFormat")->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "smlAutoChildTableNameDelimiter"); + tstrncpy(tsSmlAutoChildTableNameDelimiter, pItem->str, TSDB_TABLE_NAME_LEN); - // tsSmlBatchSize = cfgGetItem(pCfg, "smlBatchSize")->i32; - tsMaxInsertBatchRows = cfgGetItem(pCfg, "maxInsertBatchRows")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "smlChildTableName"); + tstrncpy(tsSmlChildTableName, pItem->str, TSDB_TABLE_NAME_LEN); - tsShellActivityTimer = cfgGetItem(pCfg, "shellActivityTimer")->i32; - tsCompressMsgSize = cfgGetItem(pCfg, "compressMsgSize")->i32; - tsNumOfTaskQueueThreads = cfgGetItem(pCfg, "numOfTaskQueueThreads")->i32; - tsQueryPolicy = cfgGetItem(pCfg, "queryPolicy")->i32; - tsEnableQueryHb = cfgGetItem(pCfg, "enableQueryHb")->bval; - tsEnableScience = cfgGetItem(pCfg, "enableScience")->bval; - tsQuerySmaOptimize = cfgGetItem(pCfg, "querySmaOptimize")->i32; - tsQueryPlannerTrace = cfgGetItem(pCfg, "queryPlannerTrace")->bval; - tsQueryNodeChunkSize = cfgGetItem(pCfg, "queryNodeChunkSize")->i32; - tsQueryUseNodeAllocator = cfgGetItem(pCfg, "queryUseNodeAllocator")->bval; - tsKeepColumnName = cfgGetItem(pCfg, "keepColumnName")->bval; - tsUseAdapter = cfgGetItem(pCfg, "useAdapter")->bval; - tsEnableCrashReport = cfgGetItem(pCfg, "crashReporting")->bval; - tsQueryMaxConcurrentTables = cfgGetItem(pCfg, "queryMaxConcurrentTables")->i64; - tsMetaCacheMaxSize = cfgGetItem(pCfg, "metaCacheMaxSize")->i32; - tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "smlTagName"); + tstrncpy(tsSmlTagName, pItem->str, TSDB_COL_NAME_LEN); - tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "smlTsDefaultName"); + tstrncpy(tsSmlTsDefaultName, pItem->str, TSDB_COL_NAME_LEN); - tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; - tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "smlDot2Underline"); + tsSmlDot2Underline = pItem->bval; - tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxInsertBatchRows"); + tsMaxInsertBatchRows = pItem->i32; - tsKeepAliveIdle = cfgGetItem(pCfg, "keepAliveIdle")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "shellActivityTimer"); + tsShellActivityTimer = pItem->i32; - tsExperimental = cfgGetItem(pCfg, "experimental")->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "compressMsgSize"); + tsCompressMsgSize = pItem->i32; - tsMultiResultFunctionStarReturnTags = cfgGetItem(pCfg, "multiResultFunctionStarReturnTags")->bval; - tsMaxTsmaCalcDelay = cfgGetItem(pCfg, "maxTsmaCalcDelay")->i32; - tsmaDataDeleteMark = cfgGetItem(pCfg, "tsmaDataDeleteMark")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfTaskQueueThreads"); + tsNumOfTaskQueueThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryPolicy"); + tsQueryPolicy = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableQueryHb"); + tsEnableQueryHb = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableScience"); + tsEnableScience = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "querySmaOptimize"); + tsQuerySmaOptimize = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryPlannerTrace"); + tsQueryPlannerTrace = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryNodeChunkSize"); + tsQueryNodeChunkSize = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryUseNodeAllocator"); + tsQueryUseNodeAllocator = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "keepColumnName"); + tsKeepColumnName = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "useAdapter"); + tsUseAdapter = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "crashReporting"); + tsEnableCrashReport = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryMaxConcurrentTables"); + tsQueryMaxConcurrentTables = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "metaCacheMaxSize"); + tsMetaCacheMaxSize = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "countAlwaysReturnValue"); + tsCountAlwaysReturnValue = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxRetryWaitTime"); + tsMaxRetryWaitTime = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcThreads"); + tsNumOfRpcThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcSessions"); + tsNumOfRpcSessions = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeToGetAvailableConn"); + tsTimeToGetAvailableConn = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "keepAliveIdle"); + tsKeepAliveIdle = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental"); + tsExperimental = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "multiResultFunctionStarReturnTags"); + tsMultiResultFunctionStarReturnTags = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxTsmaCalcDelay"); + tsMaxTsmaCalcDelay = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tsmaDataDeleteMark"); + tsmaDataDeleteMark = pItem->i32; TAOS_RETURN(TSDB_CODE_SUCCESS); } static int32_t taosSetSystemCfg(SConfig *pCfg) { - SConfigItem *pItem = cfgGetItem(pCfg, "timezone"); - if (NULL == pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + SConfigItem *pItem = NULL; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timezone"); TAOS_CHECK_RETURN(osSetTimezone(pItem->str)); uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr); TAOS_CHECK_RETURN(cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype, true)); - pItem = cfgGetItem(pCfg, "locale"); - if (NULL == pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "locale"); const char *locale = pItem->str; - pItem = cfgGetItem(pCfg, "charset"); - if (NULL == pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "charset"); const char *charset = pItem->str; - taosSetSystemLocale(locale, charset); + (void)taosSetSystemLocale(locale, charset); // ignore this error temporarily osSetSystemLocale(locale, charset); - pItem = cfgGetItem(pCfg, "enableCoreFile"); - if (NULL == pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableCoreFile"); bool enableCore = pItem->bval; taosSetCoreDump(enableCore); - pItem = cfgGetItem(pCfg, "assert"); - if (NULL == pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "assert"); tsAssert = pItem->bval; // todo @@ -1117,136 +1230,312 @@ static int32_t taosSetSystemCfg(SConfig *pCfg) { // for server configs static int32_t taosSetServerCfg(SConfig *pCfg) { - tsDataSpace.reserved = (int64_t)(((double)cfgGetItem(pCfg, "minimalDataDirGB")->fval) * 1024 * 1024 * 1024); - tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32; - tsMaxShellConns = cfgGetItem(pCfg, "maxShellConns")->i32; - tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32; - tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32; - tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32; - tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; - tstrncpy(tsEncryptAlgorithm, cfgGetItem(pCfg, "encryptAlgorithm")->str, 16); - tstrncpy(tsEncryptScope, cfgGetItem(pCfg, "encryptScope")->str, 100); - // tstrncpy(tsAuthCode, cfgGetItem(pCfg, "authCode")->str, 100); + SConfigItem *pItem = NULL; - tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; - tsNumOfRpcSessions = cfgGetItem(pCfg, "numOfRpcSessions")->i32; - tsTimeToGetAvailableConn = cfgGetItem(pCfg, "timeToGetAvailableConn")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minimalDataDirGB"); + tsDataSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); - tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32; - tsRetentionSpeedLimitMB = cfgGetItem(pCfg, "retentionSpeedLimitMB")->i32; - tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32; - tsNumOfVnodeQueryThreads = cfgGetItem(pCfg, "numOfVnodeQueryThreads")->i32; - tsRatioOfVnodeStreamThreads = cfgGetItem(pCfg, "ratioOfVnodeStreamThreads")->fval; - tsNumOfVnodeFetchThreads = cfgGetItem(pCfg, "numOfVnodeFetchThreads")->i32; - tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32; - tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32; - // tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchTereads")->i32; - tsNumOfSnodeStreamThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32; - tsNumOfSnodeWriteThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32; - tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "supportVnodes"); + tsNumOfSupportVnodes = pItem->i32; - tsSIMDEnable = (bool)cfgGetItem(pCfg, "simdEnable")->bval; - tsTagFilterCache = (bool)cfgGetItem(pCfg, "tagFilterCache")->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxShellConns"); + tsMaxShellConns = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "statusInterval"); + tsStatusInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minSlidingTime"); + tsMinSlidingTime = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minIntervalTime"); + tsMinIntervalTime = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryBufferSize"); + tsQueryBufferSize = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "encryptAlgorithm"); + tstrncpy(tsEncryptAlgorithm, pItem->str, 16); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "encryptScope"); + tstrncpy(tsEncryptScope, pItem->str, 100); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcThreads"); + tsNumOfRpcThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfRpcSessions"); + tsNumOfRpcSessions = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeToGetAvailableConn"); + tsTimeToGetAvailableConn = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfCommitThreads"); + tsNumOfCommitThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "retentionSpeedLimitMB"); + tsRetentionSpeedLimitMB = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfMnodeReadThreads"); + tsNumOfMnodeReadThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfVnodeQueryThreads"); + tsNumOfVnodeQueryThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ratioOfVnodeStreamThreads"); + tsRatioOfVnodeStreamThreads = pItem->fval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfVnodeFetchThreads"); + tsNumOfVnodeFetchThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfVnodeRsmaThreads"); + tsNumOfVnodeRsmaThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfQnodeQueryThreads"); + tsNumOfQnodeQueryThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfSnodeSharedThreads"); + tsNumOfSnodeStreamThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "numOfSnodeUniqueThreads"); + tsNumOfSnodeWriteThreads = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rpcQueueMemoryAllowed"); + tsRpcQueueMemoryAllowed = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "simdEnable"); + tsSIMDEnable = (bool)pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tagFilterCache"); + tsTagFilterCache = (bool)pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "slowLogExceptDb"); + tstrncpy(tsSlowLogExceptDb, pItem->str, TSDB_DB_NAME_LEN); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "slowLogThresholdTest"); + tsSlowLogThresholdTest = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "slowLogThreshold"); + tsSlowLogThreshold = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "slowLogMaxLen"); + tsSlowLogMaxLen = pItem->i32; - tstrncpy(tsSlowLogExceptDb, cfgGetItem(pCfg, "slowLogExceptDb")->str, TSDB_DB_NAME_LEN); - tsSlowLogThresholdTest = cfgGetItem(pCfg, "slowLogThresholdTest")->i32; - tsSlowLogThreshold = cfgGetItem(pCfg, "slowLogThreshold")->i32; - tsSlowLogMaxLen = cfgGetItem(pCfg, "slowLogMaxLen")->i32; int32_t scope = 0; - TAOS_CHECK_RETURN(taosSetSlowLogScope(cfgGetItem(pCfg, "slowLogScope")->str, &scope)); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "slowLogScope"); + TAOS_CHECK_RETURN(taosSetSlowLogScope(pItem->str, &scope)); tsSlowLogScope = scope; - tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; - tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32; - tstrncpy(tsMonitorFqdn, cfgGetItem(pCfg, "monitorFqdn")->str, TSDB_FQDN_LEN); - tsMonitorPort = (uint16_t)cfgGetItem(pCfg, "monitorPort")->i32; - tsMonitorMaxLogs = cfgGetItem(pCfg, "monitorMaxLogs")->i32; - tsMonitorComp = cfgGetItem(pCfg, "monitorComp")->bval; - tsQueryRspPolicy = cfgGetItem(pCfg, "queryRspPolicy")->i32; - tsMonitorLogProtocol = cfgGetItem(pCfg, "monitorLogProtocol")->bval; - tsMonitorForceV2 = cfgGetItem(pCfg, "monitorForceV2")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitor"); + tsEnableMonitor = pItem->bval; - tsEnableAudit = cfgGetItem(pCfg, "audit")->bval; - tsEnableAuditCreateTable = cfgGetItem(pCfg, "auditCreateTable")->bval; - tsAuditInterval = cfgGetItem(pCfg, "auditInterval")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorInterval"); + tsMonitorInterval = pItem->i32; - tsEnableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; - tsEnableCrashReport = cfgGetItem(pCfg, "crashReporting")->bval; - tsTtlChangeOnWrite = cfgGetItem(pCfg, "ttlChangeOnWrite")->bval; - tsTtlFlushThreshold = cfgGetItem(pCfg, "ttlFlushThreshold")->i32; - tsTelemInterval = cfgGetItem(pCfg, "telemetryInterval")->i32; - tsRsyncPort = cfgGetItem(pCfg, "rsyncPort")->i32; - tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN); - tstrncpy(tsSnodeAddress, cfgGetItem(pCfg, "snodeAddress")->str, TSDB_FQDN_LEN); - tstrncpy(tsCheckpointBackupDir, cfgGetItem(pCfg, "checkpointBackupDir")->str, PATH_MAX); - tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorFqdn"); + tstrncpy(tsMonitorFqdn, pItem->str, TSDB_FQDN_LEN); - tmqMaxTopicNum = cfgGetItem(pCfg, "tmqMaxTopicNum")->i32; - tmqRowSize = cfgGetItem(pCfg, "tmqRowSize")->i32; - tsMaxTsmaNum = cfgGetItem(pCfg, "maxTsmaNum")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorPort"); + tsMonitorPort = (uint16_t)pItem->i32; - tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32; - tsCompactPullupInterval = cfgGetItem(pCfg, "compactPullupInterval")->i32; - tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32; - tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32; - tsTtlPushIntervalSec = cfgGetItem(pCfg, "ttlPushInterval")->i32; - tsTtlBatchDropNum = cfgGetItem(pCfg, "ttlBatchDropNum")->i32; - tsTrimVDbIntervalSec = cfgGetItem(pCfg, "trimVDbIntervalSec")->i32; - tsUptimeInterval = cfgGetItem(pCfg, "uptimeInterval")->i32; - tsQueryRsmaTolerance = cfgGetItem(pCfg, "queryRsmaTolerance")->i32; - tsTimeSeriesThreshold = cfgGetItem(pCfg, "timeseriesThreshold")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorMaxLogs"); + tsMonitorMaxLogs = pItem->i32; - tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorComp"); + tsMonitorComp = pItem->bval; - tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32; - tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32; - tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32; - tsSnapReplMaxWaitN = cfgGetItem(pCfg, "syncSnapReplMaxWaitN")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryRspPolicy"); + tsQueryRspPolicy = pItem->i32; - tsArbHeartBeatIntervalSec = cfgGetItem(pCfg, "arbHeartBeatIntervalSec")->i32; - tsArbCheckSyncIntervalSec = cfgGetItem(pCfg, "arbCheckSyncIntervalSec")->i32; - tsArbSetAssignedTimeoutSec = cfgGetItem(pCfg, "arbSetAssignedTimeoutSec")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorLogProtocol"); + tsMonitorLogProtocol = pItem->bval; - tsMndSdbWriteDelta = cfgGetItem(pCfg, "mndSdbWriteDelta")->i64; - tsMndLogRetention = cfgGetItem(pCfg, "mndLogRetention")->i64; - tsMndSkipGrant = cfgGetItem(pCfg, "skipGrant")->bval; - tsEnableWhiteList = cfgGetItem(pCfg, "enableWhiteList")->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "monitorForceV2"); + tsMonitorForceV2 = pItem->i32; - tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; - tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs)); - tstrncpy(tsUdfdLdLibPath, cfgGetItem(pCfg, "udfdLdLibPath")->str, sizeof(tsUdfdLdLibPath)); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "audit"); + tsEnableAudit = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "auditCreateTable"); + tsEnableAuditCreateTable = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "auditInterval"); + tsAuditInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryReporting"); + tsEnableTelem = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "crashReporting"); + tsEnableCrashReport = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlChangeOnWrite"); + tsTtlChangeOnWrite = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlFlushThreshold"); + tsTtlFlushThreshold = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryInterval"); + tsTelemInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "rsyncPort"); + tsRsyncPort = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryServer"); + tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "snodeAddress"); + tstrncpy(tsSnodeAddress, pItem->str, TSDB_FQDN_LEN); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "checkpointBackupDir"); + tstrncpy(tsCheckpointBackupDir, pItem->str, PATH_MAX); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "telemetryPort"); + tsTelemPort = (uint16_t)pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tmqMaxTopicNum"); + tmqMaxTopicNum = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "tmqRowSize"); + tmqRowSize = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxTsmaNum"); + tsMaxTsmaNum = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "transPullupInterval"); + tsTransPullupInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "compactPullupInterval"); + tsCompactPullupInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "mqRebalanceInterval"); + tsMqRebalanceInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlUnit"); + tsTtlUnit = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlPushInterval"); + tsTtlPushIntervalSec = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlBatchDropNum"); + tsTtlBatchDropNum = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "trimVDbIntervalSec"); + tsTrimVDbIntervalSec = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "uptimeInterval"); + tsUptimeInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryRsmaTolerance"); + tsQueryRsmaTolerance = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timeseriesThreshold"); + tsTimeSeriesThreshold = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "walFsyncDataSizeLimit"); + tsWalFsyncDataSizeLimit = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "syncElectInterval"); + tsElectInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "syncHeartbeatInterval"); + tsHeartbeatInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "syncHeartbeatTimeout"); + tsHeartbeatTimeout = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "syncSnapReplMaxWaitN"); + tsSnapReplMaxWaitN = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "arbHeartBeatIntervalSec"); + tsArbHeartBeatIntervalSec = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "arbCheckSyncIntervalSec"); + tsArbCheckSyncIntervalSec = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "arbSetAssignedTimeoutSec"); + tsArbSetAssignedTimeoutSec = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "mndSdbWriteDelta"); + tsMndSdbWriteDelta = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "mndLogRetention"); + tsMndLogRetention = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "skipGrant"); + tsMndSkipGrant = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableWhiteList"); + tsEnableWhiteList = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "udf"); + tsStartUdfd = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "udfdResFuncs"); + tstrncpy(tsUdfdResFuncs, pItem->str, sizeof(tsUdfdResFuncs)); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "udfdLdLibPath"); + tstrncpy(tsUdfdLdLibPath, pItem->str, sizeof(tsUdfdLdLibPath)); if (tsQueryBufferSize >= 0) { tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; } - tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "cacheLazyLoadThreshold"); + tsCacheLazyLoadThreshold = pItem->i32; - tsFPrecision = cfgGetItem(pCfg, "fPrecision")->fval; - tsDPrecision = cfgGetItem(pCfg, "dPrecision")->fval; - tsMaxRange = cfgGetItem(pCfg, "maxRange")->i32; - tsCurRange = cfgGetItem(pCfg, "curRange")->i32; - tsIfAdtFse = cfgGetItem(pCfg, "ifAdtFse")->bval; - tstrncpy(tsCompressor, cfgGetItem(pCfg, "compressor")->str, sizeof(tsCompressor)); + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "fPrecision"); + tsFPrecision = pItem->fval; - tsDisableStream = cfgGetItem(pCfg, "disableStream")->bval; - tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64; - tsStreamAggCnt = cfgGetItem(pCfg, "streamAggCnt")->i32; - tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64; - tsStreamCheckpointInterval = cfgGetItem(pCfg, "checkpointInterval")->i32; - tsSinkDataRate = cfgGetItem(pCfg, "streamSinkDataRate")->fval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "dPrecision"); + tsDPrecision = pItem->fval; - tsFilterScalarMode = cfgGetItem(pCfg, "filterScalarMode")->bval; - tsMaxStreamBackendCache = cfgGetItem(pCfg, "maxStreamBackendCache")->i32; - tsPQSortMemThreshold = cfgGetItem(pCfg, "pqSortMemThreshold")->i32; - tsResolveFQDNRetryTime = cfgGetItem(pCfg, "resolveFQDNRetryTime")->i32; - tsMinDiskFreeSize = cfgGetItem(pCfg, "minDiskFreeSize")->i64; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxRange"); + tsMaxRange = pItem->i32; - // tsS3BlockSize = cfgGetItem(pCfg, "s3BlockSize")->i32; - // tsS3BlockCacheSize = cfgGetItem(pCfg, "s3BlockCacheSize")->i32; - tsS3PageCacheSize = cfgGetItem(pCfg, "s3PageCacheSize")->i32; - tsS3UploadDelaySec = cfgGetItem(pCfg, "s3UploadDelaySec")->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "curRange"); + tsCurRange = pItem->i32; - tsExperimental = cfgGetItem(pCfg, "experimental")->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ifAdtFse"); + tsIfAdtFse = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "compressor"); + tstrncpy(tsCompressor, pItem->str, sizeof(tsCompressor)); + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "disableStream"); + tsDisableStream = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamBufferSize"); + tsStreamBufferSize = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamAggCnt"); + tsStreamAggCnt = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "checkpointInterval"); + tsStreamCheckpointInterval = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "streamSinkDataRate"); + tsSinkDataRate = pItem->fval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "filterScalarMode"); + tsFilterScalarMode = pItem->bval; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "maxStreamBackendCache"); + tsMaxStreamBackendCache = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "pqSortMemThreshold"); + tsPQSortMemThreshold = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "resolveFQDNRetryTime"); + tsResolveFQDNRetryTime = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "minDiskFreeSize"); + tsMinDiskFreeSize = pItem->i64; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3PageCacheSize"); + tsS3PageCacheSize = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "s3UploadDelaySec"); + tsS3UploadDelaySec = pItem->i32; + + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "experimental"); + tsExperimental = pItem->bval; // GRANT_CFG_GET; TAOS_RETURN(TSDB_CODE_SUCCESS); @@ -1263,6 +1552,7 @@ static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag); int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) { int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; if (tsCfg == NULL) { TAOS_CHECK_RETURN(osDefaultInit()); @@ -1273,11 +1563,11 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi if (tsc) { tsLogEmbedded = 0; - TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), NULL, _exit); + TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit); } else { tsLogEmbedded = 1; - TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), NULL, _exit); - TAOS_CHECK_GOTO(taosAddServerLogCfg(pCfg), NULL, _exit); + TAOS_CHECK_GOTO(taosAddClientLogCfg(pCfg), &lino, _exit); + TAOS_CHECK_GOTO(taosAddServerLogCfg(pCfg), &lino, _exit); } if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != TSDB_CODE_SUCCESS) { @@ -1291,15 +1581,14 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi } if (tsc) { - taosSetClientLogCfg(pCfg); + TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit); } else { - taosSetClientLogCfg(pCfg); - taosSetServerLogCfg(pCfg); + TAOS_CHECK_GOTO(taosSetClientLogCfg(pCfg), &lino, _exit); + TAOS_CHECK_GOTO(taosSetServerLogCfg(pCfg), &lino, _exit); } - SConfigItem *pDebugItem = cfgGetItem(pCfg, "debugFlag"); - if (NULL == pDebugItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); - + SConfigItem *pDebugItem = NULL; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pDebugItem, "debugFlag"); TAOS_CHECK_RETURN(taosSetAllDebugFlag(pCfg, pDebugItem->i32)); if ((code = taosMulModeMkDir(tsLogDir, 0777, true)) != TSDB_CODE_SUCCESS) { @@ -1313,6 +1602,10 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi } _exit: + if (TSDB_CODE_SUCCESS != code) { + printf("failed to create log at %d since %s:", lino, tstrerror(code)); + } + cfgCleanup(pCfg); TAOS_RETURN(code); } @@ -1326,8 +1619,8 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char * SConfig *pCfg = NULL; TAOS_CHECK_RETURN(cfgInit(&pCfg)); - if (cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; - if (cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1; + TAOS_CHECK_GOTO(cfgAddDir(pCfg, "dataDir", tsDataDir, CFG_SCOPE_SERVER, CFG_DYN_NONE), NULL, _exit); + TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) ,NULL, _exit); if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) { printf("failed to load cfg since %s\n", tstrerror(code)); @@ -1340,7 +1633,14 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char * } TAOS_CHECK_GOTO(taosSetTfsCfg(pCfg), NULL, _exit); - dDebugFlag = cfgGetItem(pCfg, "dDebugFlag")->i32; + + SConfigItem *pItem = NULL; + if ((pItem = cfgGetItem(pCfg, "dDebugFlag")) == NULL) { + code = TSDB_CODE_CFG_NOT_FOUND; + goto _exit; + } + + dDebugFlag = pItem->i32; _exit: cfgCleanup(pCfg); @@ -1694,7 +1994,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) { const char *locale = pLocaleItem->str; const char *charset = pCharsetItem->str; - taosSetSystemLocale(locale, charset); + TAOS_CHECK_GOTO(taosSetSystemLocale(locale, charset), &lino, _out); osSetSystemLocale(locale, charset); uInfo("locale set to '%s', charset set to '%s'", locale, charset); matched = true; @@ -1747,20 +2047,22 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) { tstrncpy(tsSmlTsDefaultName, pItem->str, TSDB_COL_NAME_LEN); matched = true; } else if (strcasecmp("serverPort", name) == 0) { - tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN); - tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32; + SConfigItem *pFqdnItem = cfgGetItem(pCfg, "fqdn"); + SConfigItem *pServerPortItem = cfgGetItem(pCfg, "serverPort"); + SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp"); + if (pFqdnItem == NULL || pServerPortItem == NULL || pFirstEpItem == NULL) { + uError("failed to get fqdn or serverPort or firstEp from cfg"); + code = TSDB_CODE_CFG_NOT_FOUND; + goto _out; + } + + tstrncpy(tsLocalFqdn, pFqdnItem->str, TSDB_FQDN_LEN); + tsServerPort = (uint16_t)pServerPortItem->i32; (void)snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort); char defaultFirstEp[TSDB_EP_LEN] = {0}; (void)snprintf(defaultFirstEp, TSDB_EP_LEN, "%s:%u", tsLocalFqdn, tsServerPort); - SConfigItem *pFirstEpItem = cfgGetItem(pCfg, "firstEp"); - if (pFirstEpItem == NULL) { - uError("failed to get firstEp from cfg"); - code = TSDB_CODE_CFG_NOT_FOUND; - goto _out; - } - SEp firstEp = {0}; TAOS_CHECK_GOTO( taosGetFqdnPortFromEp(strlen(pFirstEpItem->str) == 0 ? defaultFirstEp : pFirstEpItem->str, &firstEp), &lino, @@ -1859,9 +2161,8 @@ int32_t taosCfgDynamicOptions(SConfig *pCfg, const char *name, bool forServer) { } int32_t taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal) { - SConfigItem *pItem = cfgGetItem(tsCfg, flagName); - if (!pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); - + SConfigItem *pItem = NULL; + TAOS_CHECK_GET_CFG_ITEM(tsCfg, pItem, flagName); pItem->i32 = flagVal; if (pFlagPtr != NULL) { *pFlagPtr = flagVal; @@ -1890,8 +2191,8 @@ static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag) { if (flag == 0) TAOS_RETURN(TSDB_CODE_SUCCESS); // just ignore SArray *noNeedToSetVars = NULL; - SConfigItem *pItem = cfgGetItem(pCfg, "debugFlag"); - if (NULL == pItem) TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + SConfigItem *pItem = NULL; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "debugFlag"); pItem->i32 = flag; noNeedToSetVars = pItem->array; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 23356ca7c1..32915ba884 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1457,6 +1457,39 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { void tFreeSStatusReq(SStatusReq *pReq) { taosArrayDestroy(pReq->pVloads); } +int32_t tSerializeSDnodeInfoReq(void *buf, int32_t bufLen, SDnodeInfoReq *pReq) { + int32_t code = 0, lino = 0; + int32_t tlen = 0; + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->dnodeId)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->machineId)); + + tEndEncode(&encoder); + + tlen = encoder.pos; +_exit: + tEncoderClear(&encoder); + return code < 0 ? code : tlen; +} + +int32_t tDeserializeSDnodeInfoReq(void *buf, int32_t bufLen, SDnodeInfoReq *pReq) { + int32_t code = 0, lino = 0; + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->dnodeId)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->machineId)); + +_exit: + tEndDecode(&decoder); + tDecoderClear(&decoder); + return code; +} + int32_t tSerializeSStatusRsp(void *buf, int32_t bufLen, SStatusRsp *pRsp) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -9265,18 +9298,17 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) { return false; } -int32_t tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { +void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { tOffsetDestroy(pLeft); *pLeft = *pRight; if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) { pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData); if (pLeft->primaryKey.pData == NULL) { uError("failed to allocate memory for offset"); - return terrno; + return; } (void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData); } - return 0; } void tOffsetDestroy(void *param) { diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index d3c325c262..374bb1a673 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -41,7 +41,7 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t 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); + (void)rpcSetIpWhite(pMgmt->msgCb.serverRpc, NULL); } return; } @@ -86,7 +86,7 @@ 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"); (void)raise(SIGINT); } @@ -167,8 +167,9 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { dError("failed to serialize status req since %s", tstrerror(contLen)); return; } + void *pHead = rpcMallocCont(contLen); - tSerializeSStatusReq(pHead, contLen, &req); + contLen = tSerializeSStatusReq(pHead, contLen, &req); if (contLen < 0) { rpcFreeCont(pHead); dError("failed to serialize status req since %s", tstrerror(contLen)); @@ -213,8 +214,17 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) { int32_t contLen = tSerializeSNotifyReq(NULL, 0, pReq); - void *pHead = rpcMallocCont(contLen); - tSerializeSNotifyReq(pHead, contLen, pReq); + if (contLen < 0) { + dError("failed to serialize notify req since %s", tstrerror(contLen)); + return; + } + void *pHead = rpcMallocCont(contLen); + contLen = tSerializeSNotifyReq(pHead, contLen, pReq); + if (contLen < 0) { + rpcFreeCont(pHead); + dError("failed to serialize notify req since %s", tstrerror(contLen)); + return; + } SRpcMsg rpcMsg = {.pCont = pHead, .contLen = contLen, @@ -226,7 +236,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_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 7605df8e7c..43c40c65c3 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -173,6 +173,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_UPDATE_DNODE_INFO, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index d626ff449c..fe438c4396 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -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; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 197a1fd129..fdce9fd4c9 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -361,7 +361,7 @@ 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; } } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index b88feb83e2..3d758e1fd3 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -246,7 +246,7 @@ _OVER: if (pWrapper != NULL) { dmSendRsp(&rsp); } else { - rpcSendResponse(&rsp); + (void)rpcSendResponse(&rsp); } } 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 3e70bb20cd..974beeccb6 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -86,6 +86,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq); static int32_t mndProcessNotifyReq(SRpcMsg *pReq); static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq); static int32_t mndProcessStatisReq(SRpcMsg *pReq); +static int32_t mndProcessUpdateDnodeInfoReq(SRpcMsg *pReq); static int32_t mndProcessCreateEncryptKeyReq(SRpcMsg *pRsp); static int32_t mndProcessCreateEncryptKeyRsp(SRpcMsg *pRsp); @@ -126,6 +127,7 @@ int32_t mndInitDnode(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq); mndSetMsgHandle(pMnode, TDMT_MND_CREATE_ENCRYPT_KEY, mndProcessCreateEncryptKeyReq); mndSetMsgHandle(pMnode, TDMT_DND_CREATE_ENCRYPT_KEY_RSP, mndProcessCreateEncryptKeyRsp); + mndSetMsgHandle(pMnode, TDMT_MND_UPDATE_DNODE_INFO, mndProcessUpdateDnodeInfoReq); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndRetrieveConfigs); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_CONFIGS, mndCancelGetNextConfig); @@ -601,37 +603,78 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) { } static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) { - int32_t code = 0; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj"); + int32_t code = 0, lino = 0; + SDnodeInfoReq infoReq = {0}; + int32_t contLen = 0; + void *pReq = NULL; + + infoReq.dnodeId = pDnode->id; + tstrncpy(infoReq.machineId, pDnode->machineId, TSDB_MACHINE_ID_LEN + 1); + + if ((contLen = tSerializeSDnodeInfoReq(NULL, 0, &infoReq)) <= 0) { + TAOS_RETURN(contLen ? contLen : TSDB_CODE_OUT_OF_MEMORY); + } + pReq = rpcMallocCont(contLen); + if (pReq == NULL) { + TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); + } + + (void)tSerializeSDnodeInfoReq(pReq, contLen, &infoReq); + + SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPDATE_DNODE_INFO, .pCont = pReq, .contLen = contLen}; + TAOS_CHECK_EXIT(tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg)); +_exit: + if (code < 0) { + mError("dnode:%d, failed to update dnode info since %s", pDnode->id, tstrerror(code)); + } + TAOS_RETURN(code); +} + +static int32_t mndProcessUpdateDnodeInfoReq(SRpcMsg *pReq) { + int32_t code = 0, lino = 0; + SMnode *pMnode = pReq->info.node; + SDnodeInfoReq infoReq = {0}; + SDnodeObj *pDnode = NULL; + STrans *pTrans = NULL; + SSdbRaw *pCommitRaw = NULL; + + TAOS_CHECK_EXIT(tDeserializeSDnodeInfoReq(pReq->pCont, pReq->contLen, &infoReq)); + + pDnode = mndAcquireDnode(pMnode, infoReq.dnodeId); + if (pDnode == NULL) { + TAOS_CHECK_EXIT(terrno); + } + + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj"); if (pTrans == NULL) { - code = TSDB_CODE_MND_RETURN_VALUE_NULL; - if (terrno != 0) code = terrno; - goto _exit; + TAOS_CHECK_EXIT(terrno); } pDnode->updateTime = taosGetTimestampMs(); - SSdbRaw *pCommitRaw = mndDnodeActionEncode(pDnode); - if (pCommitRaw == NULL) { - code = TSDB_CODE_MND_RETURN_VALUE_NULL; - if (terrno != 0) code = terrno; - goto _exit; + if ((pCommitRaw = mndDnodeActionEncode(pDnode)) == NULL) { + TAOS_CHECK_EXIT(terrno); } if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) { mError("trans:%d, failed to append commit log since %s", pTrans->id, tstrerror(code)); - code = terrno; - goto _exit; + TAOS_CHECK_EXIT(code); } (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); + pCommitRaw = NULL; if ((code = mndTransPrepare(pMnode, pTrans)) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, tstrerror(code)); - goto _exit; + TAOS_CHECK_EXIT(code); } _exit: + mndReleaseDnode(pMnode, pDnode); + if (code != 0) { + mError("dnode:%d, failed to update dnode info at line %d since %s", infoReq.dnodeId, lino, tstrerror(code)); + } mndTransDrop(pTrans); - return code; + sdbFreeRaw(pCommitRaw); + TAOS_RETURN(code); } static int32_t mndProcessStatusReq(SRpcMsg *pReq) { diff --git a/source/dnode/mnode/impl/src/mndGrant.c b/source/dnode/mnode/impl/src/mndGrant.c index af60bc9e4b..c294e0defe 100644 --- a/source/dnode/mnode/impl/src/mndGrant.c +++ b/source/dnode/mnode/impl/src/mndGrant.c @@ -89,7 +89,7 @@ void grantRestore(EGrantType grant, uint64_t value) {} int64_t grantRemain(EGrantType grant) { return 0; } int32_t tGetMachineId(char **result) { *result = NULL; - return TSDB_CODE_APP_ERROR; + return 0; } int32_t dmProcessGrantReq(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; } int32_t dmProcessGrantNotify(void *pInfo, SRpcMsg *pMsg) { return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 4f195227a2..7e072b8fe5 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -716,9 +716,9 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { void mndPreClose(SMnode *pMnode) { if (pMnode != NULL) { // TODO check return value - syncLeaderTransfer(pMnode->syncMgmt.sync); + (void)syncLeaderTransfer(pMnode->syncMgmt.sync); syncPreStop(pMnode->syncMgmt.sync); - sdbWriteFile(pMnode->pSdb, 0); + (void)sdbWriteFile(pMnode->pSdb, 0); } } @@ -1106,12 +1106,12 @@ int64_t mndGetRoleTimeMs(SMnode *pMnode) { void mndSetRestored(SMnode *pMnode, bool restored) { if (restored) { - taosThreadRwlockWrlock(&pMnode->lock); + (void)taosThreadRwlockWrlock(&pMnode->lock); pMnode->restored = true; (void)taosThreadRwlockUnlock(&pMnode->lock); mInfo("mnode set restored:%d", restored); } else { - taosThreadRwlockWrlock(&pMnode->lock); + (void)taosThreadRwlockWrlock(&pMnode->lock); pMnode->restored = false; (void)taosThreadRwlockUnlock(&pMnode->lock); mInfo("mnode set restored:%d", restored); @@ -1125,7 +1125,7 @@ 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; (void)taosThreadRwlockUnlock(&pMnode->lock); mInfo("mnode set stopped"); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index ad3ed2e62f..875ad562d2 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -575,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); } @@ -703,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); } } 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/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 3204c70db5..a76dfa1b51 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -2629,7 +2629,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) { SName name = {0}; // TODO check return value - tNameFromString(&name, alterReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (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); diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 297b747ea0..b7ab76984a 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -848,7 +848,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { _OVER: if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) { - mError("stream:%s, failed to create since %s", createReq.name, terrstr(code)); + mError("stream:%s, failed to create since %s", createReq.name, terrstr()); } else { mDebug("stream:%s create stream completed", createReq.name); } diff --git a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c index c7beee6e8a..c89ad807c7 100644 --- a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c +++ b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c @@ -50,10 +50,10 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa } 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; @@ -79,7 +79,7 @@ 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)); - streamTaskSnapReaderClose(pReader); + (void)streamTaskSnapReaderClose(pReader); *ppReader = NULL; return code; } @@ -90,7 +90,7 @@ int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) { 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; } @@ -126,17 +126,17 @@ NextTbl: 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; } @@ -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; diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 198a010a77..e943ef2442 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -301,8 +301,10 @@ static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray, SSttBlockLoadInfo *pBlockLoadInfo, uint64_t suid) { + void *px = NULL; + int32_t code = TSDB_CODE_SUCCESS; if (TARRAY2_SIZE(pArray) <= 0) { - return TSDB_CODE_SUCCESS; + return code; } SSttBlk *pStart = &pArray->data[0]; @@ -316,10 +318,17 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray return TSDB_CODE_SUCCESS; } else { // all blocks are qualified taosArrayClear(pBlockLoadInfo->aSttBlk); - taosArrayAddBatch(pBlockLoadInfo->aSttBlk, pArray->data, pArray->size); + px = taosArrayAddBatch(pBlockLoadInfo->aSttBlk, pArray->data, pArray->size); + if (px == NULL){ + return terrno; + } } } else { SArray *pTmp = taosArrayInit(TARRAY2_SIZE(pArray), sizeof(SSttBlk)); + if (pTmp == NULL) { + return terrno; + } + for (int32_t i = 0; i < TARRAY2_SIZE(pArray); ++i) { SSttBlk *p = &pArray->data[i]; if (p->suid < suid) { @@ -327,7 +336,11 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray } if (p->suid == suid) { - taosArrayPush(pTmp, p); + void* px = taosArrayPush(pTmp, p); + if (px == NULL) { + code = terrno; + break; + } } else if (p->suid > suid) { break; } @@ -337,7 +350,7 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray pBlockLoadInfo->aSttBlk = pTmp; } - return TSDB_CODE_SUCCESS; + return code; } static int32_t tValueDupPayload(SValue *pVal) { @@ -357,9 +370,11 @@ static int32_t tValueDupPayload(SValue *pVal) { static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBlockLoadInfo *pBlockLoadInfo, TStatisBlkArray *pStatisBlkArray, uint64_t suid, const char *id) { + int32_t code = TSDB_CODE_SUCCESS; + void* px = NULL; int32_t numOfBlocks = TARRAY2_SIZE(pStatisBlkArray); if (numOfBlocks <= 0) { - return 0; + return code; } int32_t startIndex = 0; @@ -385,7 +400,10 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl int64_t st = taosGetTimestampUs(); for (int32_t k = startIndex; k < endIndex; ++k) { - tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block); + code = tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block); + if (code) { + return code; + } int32_t i = 0; int32_t rows = block.numOfRecords; @@ -409,21 +427,43 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl int32_t size = rows - i; int32_t offset = i * sizeof(int64_t); - taosArrayAddBatch(pBlockLoadInfo->info.pUid, tBufferGetDataAt(&block.uids, offset), size); - taosArrayAddBatch(pBlockLoadInfo->info.pFirstTs, tBufferGetDataAt(&block.firstKeyTimestamps, offset), size); - taosArrayAddBatch(pBlockLoadInfo->info.pLastTs, tBufferGetDataAt(&block.lastKeyTimestamps, offset), size); - taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, offset), size); + px = taosArrayAddBatch(pBlockLoadInfo->info.pUid, tBufferGetDataAt(&block.uids, offset), size); + if (px == NULL) { + return terrno; + } + + px = taosArrayAddBatch(pBlockLoadInfo->info.pFirstTs, tBufferGetDataAt(&block.firstKeyTimestamps, offset), size); + if (px == NULL){ + return terrno; + } + + px = taosArrayAddBatch(pBlockLoadInfo->info.pLastTs, tBufferGetDataAt(&block.lastKeyTimestamps, offset), size); + if (px == NULL){ + return terrno; + } + + px = taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, offset), size); + if (px == NULL){ + return terrno; + } if (block.numOfPKs > 0) { SValue vFirst = {0}, vLast = {0}; for (int32_t f = i; f < rows; ++f) { - int32_t code = tValueColumnGet(&block.firstKeyPKs[0], f, &vFirst); + code = tValueColumnGet(&block.firstKeyPKs[0], f, &vFirst); if (code) { break; } - tValueDupPayload(&vFirst); - taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst); + code = tValueDupPayload(&vFirst); + if (code) { + break; + } + + px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst); + if (px == NULL) { + return terrno; + } // todo add api to clone the original data code = tValueColumnGet(&block.lastKeyPKs[0], f, &vLast); @@ -431,14 +471,28 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl break; } - tValueDupPayload(&vLast); - taosArrayPush(pBlockLoadInfo->info.pLastKey, &vLast); + code = tValueDupPayload(&vLast); + if (code) { + break; + } + + px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &vLast); + if (px == NULL) { + return terrno; + } } } else { SValue vFirst = {0}; for (int32_t j = 0; j < size; ++j) { - taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst); - taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst); + px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst); + if (px == NULL) { + return terrno; + } + + px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst); + if (px == NULL) { + return terrno; + } } } } else { @@ -450,24 +504,59 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl break; } - taosArrayPush(pBlockLoadInfo->info.pUid, &record.uid); - taosArrayPush(pBlockLoadInfo->info.pCount, &record.count); + px = taosArrayPush(pBlockLoadInfo->info.pUid, &record.uid); + if (px == NULL) { + return terrno; + } - taosArrayPush(pBlockLoadInfo->info.pFirstTs, &record.firstKey.ts); - taosArrayPush(pBlockLoadInfo->info.pLastTs, &record.lastKey.ts); + px = taosArrayPush(pBlockLoadInfo->info.pCount, &record.count); + if (px == NULL) { + return terrno; + } + + px = taosArrayPush(pBlockLoadInfo->info.pFirstTs, &record.firstKey.ts); + if (px == NULL) { + return terrno; + } + + px = taosArrayPush(pBlockLoadInfo->info.pLastTs, &record.lastKey.ts); + if (px == NULL) { + return terrno; + } if (record.firstKey.numOfPKs > 0) { SValue s = record.firstKey.pks[0]; - tValueDupPayload(&s); - taosArrayPush(pBlockLoadInfo->info.pFirstKey, &s); + code = tValueDupPayload(&s); + if (code) { + return code; + } + + px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &s); + if (px == NULL) { + return terrno; + } s = record.lastKey.pks[0]; - tValueDupPayload(&s); - taosArrayPush(pBlockLoadInfo->info.pLastKey, &s); + code = tValueDupPayload(&s); + if (code) { + return code; + } + + px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &s); + if (px == NULL) { + return terrno; + } } else { SValue v = {0}; - taosArrayPush(pBlockLoadInfo->info.pFirstKey, &v); - taosArrayPush(pBlockLoadInfo->info.pLastKey, &v); + px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &v); + if (px == NULL) { + return terrno; + } + + px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &v); + if (px == NULL) { + return terrno; + } } i += 1; @@ -482,7 +571,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl pBlockLoadInfo->cost.statisElapsedTime += el; tsdbDebug("%s load %d statis blocks into buf, elapsed time:%.2fms", id, num, el); - return TSDB_CODE_SUCCESS; + return code; } static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter *pIter, int64_t suid, @@ -617,7 +706,7 @@ int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32 } void tLDataIterClose2(SLDataIter *pIter) { - tsdbSttFileReaderClose(&pIter->pReader); + (void) tsdbSttFileReaderClose(&pIter->pReader); // always return 0 pIter->pReader = NULL; } @@ -890,7 +979,10 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF goto _end; } - adjustSttDataIters(pConf->pSttFileBlockIterArray, pConf->pCurrentFileset); + code = adjustSttDataIters(pConf->pSttFileBlockIterArray, pConf->pCurrentFileset); + if (code) { + goto _end; + } for (int32_t j = 0; j < numOfLevels; ++j) { SSttLvl *pSttLevel = ((STFileSet *)pConf->pCurrentFileset)->lvlArr->data[j]; @@ -940,7 +1032,10 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF // let's record the time window for current table of uid in the stt files if (pSttDataInfo != NULL && numOfRows > 0) { - taosArrayPush(pSttDataInfo->pKeyRangeList, &range); + void* px = taosArrayPush(pSttDataInfo->pKeyRangeList, &range); + if (px == NULL) { + return terrno; + } pSttDataInfo->numOfRows += numOfRows; } } else { @@ -958,7 +1053,7 @@ _end: return code; } -void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); } +void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { (void) tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); } bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree) { return pMTree->ignoreEarlierTs; } @@ -1035,7 +1130,7 @@ bool tMergeTreeNext(SMergeTree *pMTree) { if (pMTree->pIter && pIter) { int32_t c = pMTree->rbt.cmprFn(&pMTree->pIter->node, &pIter->node); if (c > 0) { - tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter); + (void) tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter); pMTree->pIter = NULL; } else { ASSERT(c); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 4fedb68a78..5d25c0dc9d 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -3293,23 +3293,10 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { if ((!hasDataInSttBlock(pScanInfo)) || (asc && pBlockInfo->lastKey < keyInStt) || (!asc && pBlockInfo->firstKey > keyInStt)) { - if (pScanInfo->cleanSttBlocks && hasDataInSttBlock(pScanInfo)) { - if (asc) { // file block is located before the stt block - ASSERT(pScanInfo->sttRange.skey.ts > pBlockInfo->lastKey); - } else { // stt block is before the file block - ASSERT(pScanInfo->sttRange.ekey.ts < pBlockInfo->firstKey); - } - } - + // the stt blocks may located in the gap of different data block, but the whole sttRange may overlap with the + // data block, so the overlap check is invalid actually. buildCleanBlockFromDataFiles(pReader, pScanInfo, pBlockInfo, pBlockIter->index); } else { // clean stt block - if (asc) { - ASSERT(pScanInfo->sttRange.ekey.ts < pBlockInfo->firstKey); - } else { - ASSERT(pScanInfo->sttRange.skey.ts > pBlockInfo->lastKey); - } - - // return the stt file block ASSERT(pReader->info.execMode == READER_EXEC_ROWS && pSttBlockReader->mergeTree.pIter == NULL); code = buildCleanBlockFromSttFiles(pReader, pScanInfo); return code; diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 88b13310d8..cfaf155276 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -256,7 +256,9 @@ int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) { _exit: if (code) { - vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code)); + if (pFile) { + vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code)); + } } taosMemoryFree(pData); (void)taosCloseFile(&pFile); 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/src/executil.c b/source/libs/executor/src/executil.c index 596487f0de..d810cf2428 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 75c335a6a8..3ee08d8fb0 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -1437,7 +1437,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT } end: - (void) tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset); + tOffsetCopy(&pTaskInfo->streamInfo.currentOffset, pOffset); return 0; } diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 5dca0ebb73..5f4bbd66ce 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -2369,11 +2369,12 @@ static FORCE_INLINE int optSysBinarySearch(SArray* arr, int s, int e, uint64_t k int32_t optSysIntersection(SArray* in, SArray* out) { int32_t code = TSDB_CODE_SUCCESS; int32_t lino = 0; + MergeIndex* mi = NULL; int32_t sz = (int32_t)taosArrayGetSize(in); if (sz <= 0) { goto _end; } - MergeIndex* mi = taosMemoryCalloc(sz, sizeof(MergeIndex)); + mi = taosMemoryCalloc(sz, sizeof(MergeIndex)); QUERY_CHECK_NULL(mi, code, lino, _end, terrno); for (int i = 0; i < sz; i++) { SArray* t = taosArrayGetP(in, i); diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 480a2ff59f..986693ab00 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -258,7 +258,7 @@ int32_t indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* re (void)idxTermSearch(index, qterm, &trslt); (void)taosArrayPush(iRslts, (void*)&trslt); } - idxMergeFinalResults(iRslts, opera, result); + (void)idxMergeFinalResults(iRslts, opera, result); idxInterRsltDestroy(iRslts); return 0; } diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index 56d2c865f3..adf555edd2 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -390,10 +390,10 @@ void idxCacheDebug(IndexCache* cache) { } { - 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); @@ -438,7 +438,7 @@ void idxCacheDestroyImm(IndexCache* cache) { return; } MemTable* tbl = NULL; - taosThreadMutexLock(&cache->mtx); + (void)taosThreadMutexLock(&cache->mtx); tbl = cache->imm; cache->imm = NULL; // or throw int bg thread @@ -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); } } } diff --git a/source/libs/index/src/indexFst.c b/source/libs/index/src/indexFst.c index 34eac0761a..54d28f4784 100644 --- a/source/libs/index/src/indexFst.c +++ b/source/libs/index/src/indexFst.c @@ -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 @@ -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); } diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 678f2c6086..69fee8d29d 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -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/indexTfile.c b/source/libs/index/src/indexTfile.c index 6aab70dcb0..99c7b6bc76 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -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; } 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/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index b3aec983f7..cfe1fa4eb3 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3439,7 +3439,7 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { bool partionByTbname = hasTbnameFunction(pSelect->pPartitionByList); FOREACH(pPartKey, pSelect->pPartitionByList) { if (nodesEqualNode(pPartKey, *pNode)) { - return rewriteExprToGroupKeyFunc(pCxt, pNode); + return pCxt->currClause == SQL_CLAUSE_HAVING ? DEAL_RES_IGNORE_CHILD : rewriteExprToGroupKeyFunc(pCxt, pNode); } if ((partionByTbname) && QUERY_NODE_COLUMN == nodeType(*pNode) && ((SColumnNode*)*pNode)->colType == COLUMN_TYPE_TAG) { @@ -3658,6 +3658,7 @@ static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) return code; } if (NULL != pSelect->pHaving) { + pCxt->currClause = SQL_CLAUSE_HAVING; code = checkExprForGroupBy(pCxt, &pSelect->pHaving); } /* @@ -12977,7 +12978,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/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 5e9c61eac6..d08f358ce0 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1176,27 +1176,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) { } } - if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) { - SNodeListNode *listNode = (SNodeListNode *)node->pRight; - SNode *tnode = NULL; - WHERE_EACH(tnode, listNode->pNodeList) { - if (SCL_IS_NULL_VALUE_NODE(tnode)) { - if (node->opType == OP_TYPE_IN) { - ERASE_NODE(listNode->pNodeList); - continue; - } else { // OP_TYPE_NOT_IN - return sclRewriteNullInOptr(pNode, ctx, node->opType); - } - } - - WHERE_NEXT; - } - - if (listNode->pNodeList->length <= 0) { - return sclRewriteNullInOptr(pNode, ctx, node->opType); - } - } - return DEAL_RES_CONTINUE; } @@ -1334,6 +1313,27 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) { return DEAL_RES_ERROR; } + if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) { + SNodeListNode *listNode = (SNodeListNode *)node->pRight; + SNode *tnode = NULL; + WHERE_EACH(tnode, listNode->pNodeList) { + if (SCL_IS_NULL_VALUE_NODE(tnode)) { + if (node->opType == OP_TYPE_IN) { + ERASE_NODE(listNode->pNodeList); + continue; + } else { // OP_TYPE_NOT_IN + return sclRewriteNullInOptr(pNode, ctx, node->opType); + } + } + + WHERE_NEXT; + } + + if (listNode->pNodeList->length <= 0) { + return sclRewriteNullInOptr(pNode, ctx, node->opType); + } + } + if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) { return sclRewriteNonConstOperator(pNode, ctx); } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index cbc671a73a..376a8a11d8 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -793,7 +793,7 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, return vectorConvertFromVarData(&cCtx, overflow); } - if (overflow) { + if (overflow && TSDB_DATA_TYPE_NULL != cCtx.inType) { if (1 != pIn->numOfRows) { sclError("invalid numOfRows %d", pIn->numOfRows); return TSDB_CODE_APP_ERROR; diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 09f6573052..7396c6b7c6 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,17 +1116,17 @@ 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); pBackend->chkpSaved = chkpDup; - taosThreadRwlockUnlock(&pBackend->chkpDirLock); + (void)taosThreadRwlockUnlock(&pBackend->chkpDirLock); for (int i = 0; i < taosArrayGetSize(chkpDel); i++) { int64_t id = *(int64_t*)taosArrayGet(chkpDel, i); @@ -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); @@ -1430,7 +1438,7 @@ int32_t taskDbBuildSnap(void* arg, SArray* pSnap) { code = TSDB_CODE_OUT_OF_MEMORY; break; } - taosArrayPush(pSnap, &snap); + (void)taosArrayPush(pSnap, &snap); pIter = taosHashIterate(pMeta->pTaskDbUnique, pIter); } @@ -1497,7 +1505,7 @@ void* taskAcquireDb(int64_t refId) { } void taskReleaseDb(int64_t refId) { // release - taosReleaseRef(taskDbWrapperId, refId); + (void)taosReleaseRef(taskDbWrapperId, refId); } int64_t taskGetDBRef(void* arg) { @@ -1558,7 +1566,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId) code = 0; _EXIT: taosMemoryFree(pDst); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return code; } int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) { @@ -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); @@ -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; } @@ -2906,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; } @@ -3146,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; \ @@ -3180,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; \ @@ -3223,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; \ @@ -3264,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}; @@ -3280,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); @@ -3298,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) { @@ -3335,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; } @@ -3351,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; } @@ -3404,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; } @@ -3426,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); } @@ -3476,7 +3493,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; @@ -3624,7 +3641,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); @@ -3661,7 +3678,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); @@ -3701,7 +3718,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); @@ -3741,7 +3758,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); @@ -3764,7 +3781,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; @@ -3843,7 +3860,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; } @@ -3863,7 +3880,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); @@ -3904,7 +3921,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; } @@ -3941,7 +3958,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; } @@ -4024,11 +4041,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) { @@ -4076,7 +4094,7 @@ void streamStateSessionClear_rocksdb(SStreamState* pState) { if (code == 0 && size > 0) { memset(buf, 0, size); // refactor later - streamStateSessionPut_rocksdb(pState, &delKey, buf, size); + (void)streamStateSessionPut_rocksdb(pState, &delKey, buf, size); } else { taosMemoryFreeClear(buf); break; @@ -4214,7 +4232,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; @@ -4286,7 +4304,7 @@ void streamStateDestroyBatch(void* pBatch) { rocksdb_writebatch_destroy((rock int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb_writebatch_t* pBatch, void* key, void* val, int32_t vlen, int64_t ttl) { STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; - atomic_add_fetch_64(&wrapper->dataWritten, 1); + (void)atomic_add_fetch_64(&wrapper->dataWritten, 1); int i = streamStateGetCfIdx(pState, cfKeyName); if (i < 0) { @@ -4306,7 +4324,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; @@ -4321,7 +4339,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); @@ -4332,7 +4350,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb { char tbuf[256] = {0}; - ginitDict[cfIdx].toStrFunc((void*)key, tbuf); + (void)(ginitDict[cfIdx].toStrFunc((void*)key, tbuf)); stTrace("streamState str: %s succ to write to %s_%s", tbuf, wrapper->idstr, ginitDict[cfIdx].key); } return 0; @@ -4340,7 +4358,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch) { char* err = NULL; STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; - atomic_add_fetch_64(&wrapper->dataWritten, 1); + (void)atomic_add_fetch_64(&wrapper->dataWritten, 1); rocksdb_write(wrapper->db, wrapper->writeOpt, (rocksdb_writebatch_t*)pBatch, &err); if (err != NULL) { stError("streamState failed to write batch, err:%s", err); @@ -4429,8 +4447,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); } @@ -4506,7 +4524,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; @@ -4524,7 +4542,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; } @@ -4534,7 +4552,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); } @@ -4570,9 +4588,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; } @@ -4584,12 +4602,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); } @@ -4621,7 +4639,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { p->idx = 1 - p->idx; - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return code; } @@ -4679,7 +4697,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { } p->update = 0; - taosThreadRwlockInit(&p->rwLock, NULL); + (void)taosThreadRwlockInit(&p->rwLock, NULL); SArray* list = NULL; code = dbChkpGetDelta(p, initChkpId, list); @@ -4720,7 +4738,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { static char* chkpMeta = "META"; int32_t code = 0; - taosThreadRwlockRdlock(&p->rwLock); + (void)taosThreadRwlockRdlock(&p->rwLock); int32_t cap = p->len + 128; @@ -4793,7 +4811,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 @@ -4859,7 +4877,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; } @@ -4867,10 +4885,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); @@ -4879,7 +4897,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) { _ERROR: taosMemoryFree(buffer); - taosThreadRwlockUnlock(&p->rwLock); + (void)taosThreadRwlockUnlock(&p->rwLock); return code; } @@ -4925,7 +4943,7 @@ void bkdMgtDestroy(SBkdMgt* bm) { pIter = taosHashIterate(bm->pDbChkpTbl, pIter); } - taosThreadRwlockDestroy(&bm->rwLock); + (void)taosThreadRwlockDestroy(&bm->rwLock); taosMemoryFree(bm->path); taosHashCleanup(bm->pDbChkpTbl); @@ -4933,7 +4951,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; @@ -4941,14 +4959,14 @@ 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; } @@ -4957,20 +4975,20 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, code = dbChkpCreate(path, chkpId, &p); if (code != 0) { taosMemoryFree(path); - taosThreadRwlockUnlock(&bm->rwLock); + (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); @@ -4979,7 +4997,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, } } - taosThreadRwlockUnlock(&bm->rwLock); + (void)taosThreadRwlockUnlock(&bm->rwLock); return code; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 67eb09418c..171b73eba7 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -181,7 +181,7 @@ 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) { diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 4669972904..2e61f19af8 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -646,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)); @@ -903,7 +903,7 @@ 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; } @@ -1010,7 +1010,7 @@ _failed: if (conn) { taosMemoryFree(conn->stream); transReqQueueClear(&conn->wreqQueue); - transDestroyBuffer(&conn->readBuf); + (void)transDestroyBuffer(&conn->readBuf); transQueueDestroy(&conn->cliMsgs); } taosMemoryFree(conn); @@ -1390,7 +1390,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) { 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; } @@ -1481,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; } @@ -1609,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; }; @@ -1759,14 +1759,14 @@ 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 { code = cliCreateConn(pThrd, &conn); if (code != 0) { tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code)); STransMsg resp = {.code = code}; - cliBuildExceptResp(pMsg, &resp); + (void)cliBuildExceptResp(pMsg, &resp); resp.info.cliVer = pTransInst->compatibilityVer; if (pMsg->type != Release) { @@ -1827,7 +1827,7 @@ 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; (void)taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; @@ -1923,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)); @@ -2099,10 +2099,10 @@ static void* cliWorkThread(void* arg) { SCliThrd* pThrd = (SCliThrd*)arg; pThrd->pid = taosGetSelfPthreadId(); - strtolower(threadName, pThrd->pTransInst->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; @@ -2198,7 +2198,7 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) { } QUEUE_INIT(&pThrd->msg); - taosThreadMutexInit(&pThrd->msgMtx, NULL); + (void)taosThreadMutexInit(&pThrd->msgMtx, NULL); pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); if (pThrd->loop == NULL) { @@ -2291,7 +2291,7 @@ _end: (void)uv_loop_close(pThrd->loop); taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd->prepare); - taosThreadMutexDestroy(&pThrd->msgMtx); + (void)taosThreadMutexDestroy(&pThrd->msgMtx); transAsyncPoolDestroy(pThrd->asyncPool); for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) { uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i); @@ -2916,7 +2916,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); if (pCtx == NULL) { - tsem_destroy(sem); + (void)tsem_destroy(sem); taosMemoryFree(sem); TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); } @@ -2930,7 +2930,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); if (cliMsg == NULL) { - tsem_destroy(sem); + (void)tsem_destroy(sem); taosMemoryFree(sem); taosMemoryFree(pCtx); TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); @@ -2951,7 +2951,7 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs destroyCmsg(cliMsg); 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)); @@ -3085,7 +3085,7 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr _RETURN: (void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); (void)taosReleaseRef(transGetSyncMsgMgt(), ref); - taosRemoveRef(transGetSyncMsgMgt(), ref); + (void)taosRemoveRef(transGetSyncMsgMgt(), ref); return code; _RETURN2: transFreeMsg(pReq->pCont); diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index ee747b8a39..9df0ddb6f3 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -377,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); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index e94e6f5355..1e0d54eb5b 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -1673,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); 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/tlog.c b/source/util/src/tlog.c index 7f67c11f0a..1946a0a274 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -932,7 +932,7 @@ void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, vo goto _return; } - taosUnLockFile(pFile); + (void)taosUnLockFile(pFile); } _return: diff --git a/source/util/src/tpcre2.c b/source/util/src/tpcre2.c index 5f5e4ffde6..52991c58b8 100644 --- a/source/util/src/tpcre2.c +++ b/source/util/src/tpcre2.c @@ -8,7 +8,7 @@ int32_t doRegComp(pcre2_code** ppRegex, pcre2_match_data** ppMatchData, const ch *ppRegex = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL); if (*ppRegex == NULL) { PCRE2_UCHAR buffer[256]; - pcre2_get_error_message(errorcode, buffer, sizeof(buffer)); + (void)pcre2_get_error_message(errorcode, buffer, sizeof(buffer)); return 1; } @@ -22,7 +22,7 @@ int32_t doRegExec(const char* pString, pcre2_code* pRegex, pcre2_match_data* pMa ret = pcre2_match(pRegex, (PCRE2_SPTR)pString, PCRE2_ZERO_TERMINATED, 0, 0, pMatchData, NULL); if (ret < 0) { PCRE2_UCHAR buffer[256]; - pcre2_get_error_message(ret, buffer, sizeof(buffer)); + (void)pcre2_get_error_message(ret, buffer, sizeof(buffer)); return 1; } 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/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index c0f1d6e443..e3f5e54698 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -560,6 +560,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Now.py @@ -739,6 +741,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2 @@ -837,6 +840,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3 @@ -934,6 +938,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4 diff --git a/tests/system-test/2-query/group_partition.py b/tests/system-test/2-query/group_partition.py index c63b8af9df..593f51acaf 100644 --- a/tests/system-test/2-query/group_partition.py +++ b/tests/system-test/2-query/group_partition.py @@ -80,6 +80,12 @@ class TDTestCase: if nonempty_tb_num > 0: num = self.row_nums tdSql.checkRows(num) + + tdSql.query(f"select c1, count(*), count(1), count(c1) from {self.dbname}.{self.stable} {keyword} by c1 having c1 >= 0") + num = 0 + if nonempty_tb_num > 0: + num = self.row_nums + tdSql.checkRows(num) tdSql.query(f"select ts, count(*) from {self.dbname}.{self.stable} {keyword} by ts ") tdSql.checkRows(nonempty_tb_num * self.row_nums) diff --git a/tests/system-test/2-query/normal.py b/tests/system-test/2-query/normal.py new file mode 100644 index 0000000000..db210f02e3 --- /dev/null +++ b/tests/system-test/2-query/normal.py @@ -0,0 +1,143 @@ +from wsgiref.headers import tspecials +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np + + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + self.dbname = "db" + self.rowNum = 10 + self.ts = 1537146000000 + + def inAndNotinTest(self): + dbname = self.dbname + + tdSql.query(f"select 1 in (1, 2)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query(f"select 1 in (2, 3)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) + + tdSql.query(f"select 1 not in (2, 3)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query(f"select 1 not in (1)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) + + tdSql.query(f"select 1 in (1, null)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, True) + + tdSql.query(f"select 1 in (2, null)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) # 1 not in (2, null) is NULL? + + tdSql.query(f"select 1 not in (1, null)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) + + tdSql.query(f"select 1 not in (2, null)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) # 1 not in (2, null) is NULL? + + tdSql.query(f"select 1 not in (null)") + tdSql.checkRows(1) + tdSql.checkData(0, 0, False) # 1 not in (null) is NULL? + + tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 int, col2 nchar(20)) tags(loc nchar(20))''') + tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')") + tdSql.execute(f"create table {dbname}.stb_2 using {dbname}.stb tags('shanghai')") + + for i in range(self.rowNum): + tdSql.execute(f"insert into {dbname}.stb_1 values({self.ts + i + 1}, {i+1}, 'taosdata_{i+1}')" ) + for i in range(self.rowNum): + tdSql.execute(f"insert into {dbname}.stb_2 values({self.ts + i + 1}, {i+1}, 'taosdata_{i+1}')" ) + + tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 2) order by ts") + tdSql.checkRows(2) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 2) + + tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3) order by ts") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 3) + tdSql.checkData(2, 1, 9) + + tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3, 'xy') order by ts") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 3) + tdSql.checkData(2, 1, 9) + + tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, '9', 3) order by ts") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 3) + tdSql.checkData(2, 1, 9) + + tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3, null) order by ts") + tdSql.checkRows(3) + tdSql.checkData(0, 1, 1) + tdSql.checkData(1, 1, 3) + tdSql.checkData(2, 1, 9) + + tdSql.query(f"select * from {dbname}.stb_1 where col2 in (1, 'taosdata_1', 3, null) order by ts") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query(f"select * from {dbname}.stb_1 where col2 not in (1, 'taosdata_1', 3, null) order by ts") + tdSql.checkRows(0) + + tdSql.execute(f"insert into {dbname}.stb_1 values({self.ts + self.rowNum + 1}, {self.rowNum+1}, null)" ) + tdSql.execute(f"insert into {dbname}.stb_2 values({self.ts + self.rowNum + 1}, {self.rowNum+1}, null)" ) + + tdSql.query(f"select * from {dbname}.stb_1 where col2 in (1, 'taosdata_1', 3, null) order by ts") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 1) + + tdSql.query(f"select * from {dbname}.stb_1 where col2 not in (1, 'taosdata_1', 3, null) order by ts") + tdSql.checkRows(0) + + tdSql.query(f"select * from {dbname}.stb where loc in ('beijing', null)") + tdSql.checkRows(11) + + tdSql.query(f"select * from {dbname}.stb where loc in ('shanghai', null)") + tdSql.checkRows(11) + + tdSql.query(f"select * from {dbname}.stb where loc in ('shanghai', 'shanghai', null)") + tdSql.checkRows(11) + + tdSql.query(f"select * from {dbname}.stb where loc in ('beijing', 'shanghai', null)") + tdSql.checkRows(22) + + tdSql.query(f"select * from {dbname}.stb where loc not in ('beijing', null)") + tdSql.checkRows(0) + + tdSql.query(f"select * from {dbname}.stb where loc not in ('shanghai', 'shanghai', null)") + tdSql.checkRows(0) + + + def run(self): + dbname = "db" + tdSql.prepare() + + self.inAndNotinTest() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) 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) diff --git a/tests/system-test/runAllOne.sh b/tests/system-test/runAllOne.sh index 79fc2cd363..3bb128ea28 100644 --- a/tests/system-test/runAllOne.sh +++ b/tests/system-test/runAllOne.sh @@ -243,6 +243,8 @@ python3 ./test.py -f 2-query/max.py -P python3 ./test.py -f 2-query/max.py -P -R python3 ./test.py -f 2-query/min.py -P python3 ./test.py -f 2-query/min.py -P -R +python3 ./test.py -f 2-query/normal.py -P +python3 ./test.py -f 2-query/normal.py -P -R python3 ./test.py -f 2-query/mode.py -P python3 ./test.py -f 2-query/mode.py -P -R python3 ./test.py -f 2-query/Now.py -P @@ -424,6 +426,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 2 python3 ./test.py -f 2-query/Today.py -P -Q 2 python3 ./test.py -f 2-query/max.py -P -Q 2 python3 ./test.py -f 2-query/min.py -P -Q 2 +python3 ./test.py -f 2-query/normal.py -P -Q 2 python3 ./test.py -f 2-query/mode.py -P -Q 2 python3 ./test.py -f 2-query/count.py -P -Q 2 python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 2 @@ -522,6 +525,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 3 python3 ./test.py -f 2-query/Today.py -P -Q 3 python3 ./test.py -f 2-query/max.py -P -Q 3 python3 ./test.py -f 2-query/min.py -P -Q 3 +python3 ./test.py -f 2-query/normal.py -P -Q 3 python3 ./test.py -f 2-query/mode.py -P -Q 3 python3 ./test.py -f 2-query/count.py -P -Q 3 python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 3 @@ -619,6 +623,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 4 python3 ./test.py -f 2-query/Today.py -P -Q 4 python3 ./test.py -f 2-query/max.py -P -Q 4 python3 ./test.py -f 2-query/min.py -P -Q 4 +python3 ./test.py -f 2-query/normal.py -P -Q 4 python3 ./test.py -f 2-query/mode.py -P -Q 4 python3 ./test.py -f 2-query/count.py -P -Q 4 python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 4 diff --git a/tests/system-test/simpletest.bat b/tests/system-test/simpletest.bat index 31b76cad4a..a1f7273ad4 100644 --- a/tests/system-test/simpletest.bat +++ b/tests/system-test/simpletest.bat @@ -46,6 +46,7 @@ python3 .\test.py -f 2-query\between.py @REM python3 .\test.py -f 2-query\Today.py @REM python3 .\test.py -f 2-query\max.py @REM python3 .\test.py -f 2-query\min.py +@REM python3 .\test.py -f 2-query\normal.py @REM python3 .\test.py -f 2-query\count.py @REM python3 .\test.py -f 2-query\last.py @REM python3 .\test.py -f 2-query\first.py diff --git a/tests/system-test/win-test-file b/tests/system-test/win-test-file index cdc4e27f20..69688e7450 100644 --- a/tests/system-test/win-test-file +++ b/tests/system-test/win-test-file @@ -382,6 +382,8 @@ python3 ./test.py -f 2-query/max.py python3 ./test.py -f 2-query/max.py -R python3 ./test.py -f 2-query/min.py python3 ./test.py -f 2-query/min.py -R +python3 ./test.py -f 2-query/normal.py +python3 ./test.py -f 2-query/normal.py -R python3 ./test.py -f 2-query/mode.py python3 ./test.py -f 2-query/mode.py -R python3 ./test.py -f 2-query/Now.py @@ -550,6 +552,7 @@ python3 ./test.py -f 2-query/Now.py -Q 2 python3 ./test.py -f 2-query/Today.py -Q 2 python3 ./test.py -f 2-query/max.py -Q 2 python3 ./test.py -f 2-query/min.py -Q 2 +python3 ./test.py -f 2-query/normal.py -Q 2 python3 ./test.py -f 2-query/mode.py -Q 2 python3 ./test.py -f 2-query/count.py -Q 2 python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2 @@ -646,6 +649,7 @@ python3 ./test.py -f 2-query/Now.py -Q 3 python3 ./test.py -f 2-query/Today.py -Q 3 python3 ./test.py -f 2-query/max.py -Q 3 python3 ./test.py -f 2-query/min.py -Q 3 +python3 ./test.py -f 2-query/normal.py -Q 3 python3 ./test.py -f 2-query/mode.py -Q 3 python3 ./test.py -f 2-query/count.py -Q 3 python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3 @@ -742,6 +746,7 @@ python3 ./test.py -f 2-query/Now.py -Q 4 python3 ./test.py -f 2-query/Today.py -Q 4 python3 ./test.py -f 2-query/max.py -Q 4 python3 ./test.py -f 2-query/min.py -Q 4 +python3 ./test.py -f 2-query/normal.py -Q 4 python3 ./test.py -f 2-query/mode.py -Q 4 python3 ./test.py -f 2-query/count.py -Q 4 python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4