other: merge 3.0

This commit is contained in:
Haojun Liao 2024-07-31 15:01:13 +08:00
commit 91dcf63933
59 changed files with 1442 additions and 726 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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 {

View File

@ -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

View File

@ -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);

View File

@ -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.

File diff suppressed because it is too large Load Diff

View File

@ -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) {

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -246,7 +246,7 @@ _OVER:
if (pWrapper != NULL) {
dmSendRsp(&rsp);
} else {
rpcSendResponse(&rsp);
(void)rpcSendResponse(&rsp);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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) {

View File

@ -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; }

View File

@ -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");

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -932,7 +932,7 @@ void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, vo
goto _return;
}
taosUnLockFile(pFile);
(void)taosUnLockFile(pFile);
}
_return:

View File

@ -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;
}

View File

@ -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));

View File

@ -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

View File

@ -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)

View File

@ -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())

View File

@ -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()

View File

@ -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)

View File

@ -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

View File

@ -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

View 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