From 3b0968d7f91567466c9bcb3a185e2a0c98239485 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 18 Oct 2022 20:42:42 +0800 Subject: [PATCH 01/25] enh: enable the -Wformat=2 compiler option --- cmake/cmake.define | 4 +- source/client/src/clientImpl.c | 12 +- source/client/src/clientRawBlockWrite.c | 4 +- source/client/src/clientTmq.c | 8 +- source/common/src/tdatablock.c | 8 +- source/dnode/mgmt/node_mgmt/src/dmProc.c | 8 +- source/dnode/mnode/impl/src/mndConsumer.c | 8 +- source/dnode/mnode/impl/src/mndSubscribe.c | 4 +- source/dnode/vnode/src/sma/smaEnv.c | 4 +- source/dnode/vnode/src/sma/smaOpen.c | 5 +- source/dnode/vnode/src/sma/smaRollup.c | 10 +- source/dnode/vnode/src/tq/tq.c | 19 +-- source/dnode/vnode/src/tq/tqMeta.c | 4 +- source/dnode/vnode/src/tq/tqPush.c | 6 +- source/dnode/vnode/src/tq/tqSink.c | 8 +- source/dnode/vnode/src/tsdb/tsdbRead.c | 12 +- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 2 +- source/dnode/vnode/src/vnd/vnodeSvr.c | 2 +- source/libs/catalog/src/ctgAsync.c | 10 +- source/libs/executor/src/dataDeleter.c | 2 +- source/libs/executor/src/executil.c | 4 +- source/libs/executor/src/executor.c | 4 +- source/libs/executor/src/executorimpl.c | 2 +- source/libs/executor/src/scanoperator.c | 8 +- source/libs/executor/src/tsimplehash.c | 6 +- source/libs/function/src/builtinsimpl.c | 12 +- source/libs/function/src/tudf.c | 2 +- source/libs/qworker/src/qworker.c | 4 +- source/libs/sync/src/syncAppendEntries.c | 5 +- source/libs/sync/src/syncCommit.c | 4 +- source/libs/sync/src/syncIndexMgr.c | 8 +- source/libs/sync/src/syncMain.c | 38 +++--- source/libs/sync/src/syncMessage.c | 136 ++++++++++---------- source/libs/sync/src/syncRaftCfg.c | 26 ++-- source/libs/sync/src/syncRaftEntry.c | 18 +-- source/libs/sync/src/syncRaftLog.c | 18 +-- source/libs/sync/src/syncRaftStore.c | 8 +- source/libs/sync/src/syncRequestVoteReply.c | 4 +- source/libs/sync/src/syncRespMgr.c | 2 +- source/libs/sync/src/syncTimeout.c | 8 +- source/libs/sync/src/syncVoteMgr.c | 16 +-- source/libs/tdb/src/db/tdbDb.c | 9 +- source/libs/tdb/src/db/tdbPCache.c | 4 +- source/libs/tdb/src/db/tdbPager.c | 8 +- source/libs/transport/src/trans.c | 4 +- source/libs/transport/test/svrBench.c | 2 +- source/libs/wal/src/walMeta.c | 14 +- source/libs/wal/src/walRead.c | 4 +- source/libs/wal/src/walWrite.c | 12 +- source/util/src/tcache.c | 2 +- utils/test/c/tmqSim.c | 2 +- utils/tsim/src/simExe.c | 4 +- 52 files changed, 275 insertions(+), 263 deletions(-) diff --git a/cmake/cmake.define b/cmake/cmake.define index 5d64815a9a..4a32be84c3 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -117,8 +117,8 @@ ELSE () SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") MESSAGE(STATUS "Will compile with Address Sanitizer!") ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation") ENDIF () MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index df717bda23..08db93c472 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -186,8 +186,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, STscObj* pTscObj = (*pRequest)->pTscObj; if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self, sizeof((*pRequest)->self))) { - tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s", (*pRequest)->self, - (*pRequest)->requestId, pTscObj->id, sql); + tscError("%" PRId64 " failed to add to request container, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s", + (*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql); taosMemoryFree(param); destroyRequest(*pRequest); @@ -199,8 +199,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) { if (TSDB_CODE_SUCCESS != nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) { - tscError("%d failed to create node allocator, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self, - (*pRequest)->requestId, pTscObj->id, sql); + tscError("%" PRId64 " failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s", + (*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql); destroyRequest(*pRequest); *pRequest = NULL; @@ -370,8 +370,8 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) { if (pNodeList) { pInfo->pQnodeList = taosArrayDup(pNodeList); taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad); - tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%d", pInfo->clusterId, - (int)taosArrayGetSize(pInfo->pQnodeList)); + tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%ld", pInfo->clusterId, + taosArrayGetSize(pInfo->pQnodeList)); } taosThreadMutexUnlock(&pInfo->qnodeMutex); diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index 1dc319be94..dfcd8c4a79 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -1071,8 +1071,8 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { // getTbName(req.tableFName); char sql[256] = {0}; - sprintf(sql, "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName, req.tsColName, - req.skey, req.tsColName, req.ekey); + snprintf(sql, sizeof(sql), "delete from `%s` where `%s` >= %" PRId64 " and `%s` <= %" PRId64, req.tableFName, + req.tsColName, req.skey, req.tsColName, req.ekey); printf("delete sql:%s\n", sql); TAOS_RES* res = taos_query(taos, sql); diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 838b851d6d..78c84779e6 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -637,7 +637,7 @@ int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t pVg->vgId); if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { - tscDebug("consumer: %ld, vg:%d, current %ld, committed %ld", tmq->consumerId, pVg->vgId, + tscDebug("consumer: %" PRId64 ", vg:%d, current %" PRId64 ", committed %" PRId64 "", tmq->consumerId, pVg->vgId, pVg->currentOffset.version, pVg->committedOffset.version); if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) { continue; @@ -977,7 +977,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { SCMSubscribeReq req = {0}; int32_t code = -1; - tscDebug("call tmq subscribe, consumer: %ld, topic num %d", tmq->consumerId, sz); + tscDebug("call tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz); req.consumerId = tmq->consumerId; tstrncpy(req.clientId, tmq->clientId, 256); @@ -985,6 +985,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { req.topicNames = taosArrayInit(sz, sizeof(void*)); if (req.topicNames == NULL) goto FAIL; + tscDebug("call tmq subscribe, consumer: %" PRId64 ", topic num %d", tmq->consumerId, sz); + for (int32_t i = 0; i < sz; i++) { char* topic = taosArrayGetP(container, i); @@ -1615,7 +1617,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { return NULL; } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; - tscDebug("consumer %ld actual process poll rsp", tmq->consumerId); + tscDebug("consumer %" PRId64 " actual process poll rsp", tmq->consumerId); /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ int32_t consumerEpoch = atomic_load_32(&tmq->epoch); if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 1028a899b6..df114f5e8e 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1836,10 +1836,10 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { printf(" %15u |", *(uint32_t*)var); break; case TSDB_DATA_TYPE_BIGINT: - printf(" %15ld |", *(int64_t*)var); + printf(" %15" PRId64 " |", *(int64_t*)var); break; case TSDB_DATA_TYPE_UBIGINT: - printf(" %15lu |", *(uint64_t*)var); + printf(" %15" PRIu64 " |", *(uint64_t*)var); break; case TSDB_DATA_TYPE_FLOAT: printf(" %15f |", *(float*)var); @@ -1914,11 +1914,11 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) if (len >= size - 1) return dumpBuf; break; case TSDB_DATA_TYPE_BIGINT: - len += snprintf(dumpBuf + len, size - len, " %15ld |", *(int64_t*)var); + len += snprintf(dumpBuf + len, size - len, " %15" PRId64 " |", *(int64_t*)var); if (len >= size - 1) return dumpBuf; break; case TSDB_DATA_TYPE_UBIGINT: - len += snprintf(dumpBuf + len, size - len, " %15lu |", *(uint64_t*)var); + len += snprintf(dumpBuf + len, size - len, " %15" PRIu64 " |", *(uint64_t*)var); if (len >= size - 1) return dumpBuf; break; case TSDB_DATA_TYPE_FLOAT: diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c index dc07455e6b..0bd88a9f28 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmProc.c +++ b/source/dnode/mgmt/node_mgmt/src/dmProc.c @@ -380,7 +380,7 @@ int32_t dmRunProc(SProc *proc) { dError("node:%s, failed to create pthread since %s", proc->name, terrstr()); return -1; } - dDebug("node:%s, thread:%" PRId64 " is created to consume pqueue", proc->name, proc->pthread); + dDebug("node:%s, thread:%p is created to consume pqueue", proc->name, (void *)proc->pthread); } if (proc->ptype & DND_PROC_CHILD) { @@ -389,7 +389,7 @@ int32_t dmRunProc(SProc *proc) { dError("node:%s, failed to create cthread since %s", proc->name, terrstr()); return -1; } - dDebug("node:%s, thread:%" PRId64 " is created to consume cqueue", proc->name, proc->cthread); + dDebug("node:%s, thread:%p is created to consume cqueue", proc->name, (void *)proc->cthread); } taosThreadAttrDestroy(&thAttr); @@ -399,14 +399,14 @@ int32_t dmRunProc(SProc *proc) { void dmStopProc(SProc *proc) { proc->stop = true; if (taosCheckPthreadValid(proc->pthread)) { - dDebug("node:%s, start to join pthread:%" PRId64, proc->name, proc->pthread); + dDebug("node:%s, start to join pthread:%p", proc->name, (void *)proc->pthread); tsem_post(&proc->pqueue->sem); taosThreadJoin(proc->pthread, NULL); taosThreadClear(&proc->pthread); } if (taosCheckPthreadValid(proc->cthread)) { - dDebug("node:%s, start to join cthread:%" PRId64, proc->name, proc->cthread); + dDebug("node:%s, start to join cthread:%p", proc->name, (void *)proc->cthread); tsem_post(&proc->cqueue->sem); taosThreadJoin(proc->cthread, NULL); taosThreadClear(&proc->cthread); diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 46aaa7ffe1..77f91b6d29 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -278,7 +278,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { - mError("consumer %ld not exist", consumerId); + mError("consumer %" PRId64 " not exist", consumerId); terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; return -1; } @@ -288,7 +288,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { int32_t status = atomic_load_32(&pConsumer->status); if (status == MQ_CONSUMER_STATUS__LOST_REBD) { - mInfo("try to recover consumer %ld", consumerId); + mInfo("try to recover consumer %" PRId64 "", consumerId); SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); pRecoverMsg->consumerId = consumerId; @@ -327,7 +327,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { #if 1 if (status == MQ_CONSUMER_STATUS__LOST_REBD) { - mInfo("try to recover consumer %ld", consumerId); + mInfo("try to recover consumer %" PRId64 "", consumerId); SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); pRecoverMsg->consumerId = consumerId; @@ -341,7 +341,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { #endif if (status != MQ_CONSUMER_STATUS__READY) { - mInfo("consumer %ld not ready, status: %s", consumerId, mndConsumerStatusName(status)); + mInfo("consumer %" PRId64 " not ready, status: %s", consumerId, mndConsumerStatusName(status)); terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; return -1; } diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index b797bfb4b2..739b8bbf01 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -426,10 +426,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("mq rebalance: final cfg: consumer %ld has %d vg", pConsumerEp->consumerId, sz); + mInfo("mq rebalance: final cfg: consumer %" PRId64 " has %d vg", pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("mq rebalance: final cfg: vg %d to consumer %ld", pVgEp->vgId, pConsumerEp->consumerId); + mInfo("mq rebalance: final cfg: vg %d to consumer %" PRId64 "", pVgEp->vgId, pConsumerEp->consumerId); } } } diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 64e5e49d0b..46b0a8ac1d 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -455,7 +455,7 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) { for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) { if (taosCheckPthreadValid(pthread[i])) { - smaDebug("vgId:%d, start to join pthread for rsma:%" PRId64, SMA_VID(pSma), pthread[i]); + smaDebug("vgId:%d, start to join pthread for rsma:%p", SMA_VID(pSma), (void *)pthread[i]); taosThreadJoin(pthread[i], NULL); } } @@ -463,4 +463,4 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) { smaInfo("vgId:%d, rsma executor stopped, number:%d", SMA_VID(pSma), tsNumOfVnodeRsmaThreads); } return 0; -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index ef0d51f0eb..9da5557dda 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -92,8 +92,7 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p days = freqDuration; } end: - smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days, - duration); + smaInfo("vgId:%d, evaluated duration for level %d is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); return days; } @@ -186,4 +185,4 @@ int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer) { ASSERT(VND_IS_RSMA(pSma->pVnode)); return tdRSmaProcessRestoreImpl(pSma, type, committedVer); -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 77c5955098..c56b32514a 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -342,7 +342,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat smaInfo("vgId:%d, item:%p table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64 ", finally maxdelay:%" PRIi32, - TD_VID(pVnode), pItem, pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], + TD_VID(pVnode), pItem, pRSmaInfo->suid, (int8_t)(idx + 1), param->maxdelay[idx], param->watermark[idx], pItem->maxDelay); } return TSDB_CODE_SUCCESS; @@ -1387,7 +1387,7 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) { } if ((++pItem->nScanned * pItem->maxDelay) > RSMA_FETCH_DELAY_MAX) { - smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 " maxDelay:%d, fetch executed", + smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi16 " maxDelay:%d, fetch executed", SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay); } else { int64_t curMs = taosGetTimestampMs(); @@ -1411,10 +1411,10 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) { goto _err; } - smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 " maxDelay:%d, fetch finished", + smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi16 " maxDelay:%d, fetch finished", SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay); } else { - smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 + smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi16 " maxDelay:%d, fetch not executed as fetch level is %" PRIi8, SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay, pItem->fetchLevel); } @@ -1513,7 +1513,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { int32_t qallItemSize = taosQallItemSize(pInfo->qall); if (qallItemSize > 0) { tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type); - smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi8, SMA_VID(pSma), qallItemSize, type); + smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi32, SMA_VID(pSma), qallItemSize, type); } if (RSMA_INFO_ITEM(pInfo, 0)->fetchLevel || RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) { diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 5e1cc15063..76de2d53e3 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -564,7 +564,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { pPushEntry->dataRsp.head.epoch = reqEpoch; pPushEntry->dataRsp.head.mqMsgType = TMQ_MSG_TYPE__POLL_RSP; taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey) + 1, &pPushEntry, sizeof(void*)); - tqDebug("tmq poll: consumer %ld, subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey, + tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d save handle to push mgr", consumerId, pHandle->subKey, TD_VID(pTq->pVnode)); // unlock taosWUnLockLatch(&pTq->pushLock); @@ -578,7 +578,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { code = -1; } - tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid:%ld, version:%ld", + tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, send data blockNum:%d, offset type:%d, uid:%" PRId64 + ", version:%" PRId64 "", consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type, dataRsp.rspOffset.uid, dataRsp.rspOffset.version); @@ -601,8 +602,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) { code = -1; } - tqDebug("tmq poll: consumer %ld, subkey %s, vg %d, send meta offset type:%d,uid:%ld,version:%ld", consumerId, - pHandle->subKey, TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid, + tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, send meta offset type:%d,uid:%" PRId64 + ",version:%" PRId64 "", + consumerId, pHandle->subKey, TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid, metaRsp.rspOffset.version); taosMemoryFree(metaRsp.metaRsp); tDeleteSTaosxRsp(&taosxRsp); @@ -619,7 +621,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { fetchOffsetNew = taosxRsp.rspOffset; } - tqDebug("taosx poll: consumer %ld, subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%ld,version:%ld", + tqDebug("taosx poll: consumer %" PRId64 ", subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%" PRId64 + ",version:%" PRId64 "", consumerId, pHandle->subKey, TD_VID(pTq->pVnode), taosxRsp.blockNum, taosxRsp.rspOffset.type, taosxRsp.rspOffset.uid, taosxRsp.rspOffset.version); } @@ -769,11 +772,11 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey)); if (pHandle == NULL) { if (req.oldConsumerId != -1) { - tqError("vgId:%d, build new consumer handle %s for consumer %ld, but old consumerId is %ld", req.vgId, req.subKey, - req.newConsumerId, req.oldConsumerId); + tqError("vgId:%d, build new consumer handle %s for consumer %" PRId64 ", but old consumerId is %" PRId64 "", + req.vgId, req.subKey, req.newConsumerId, req.oldConsumerId); } if (req.newConsumerId == -1) { - tqError("vgId:%d, tq invalid rebalance request, new consumerId %ld", req.vgId, req.newConsumerId); + tqError("vgId:%d, tq invalid rebalance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId); return 0; } STqHandle tqHandle = {0}; diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 8e4bc34e0c..298149bffc 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -193,8 +193,8 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) { tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code); ASSERT(code == 0); - tqDebug("tq save %s(%d) consumer %ld vgId:%d", pHandle->subKey, (int32_t)strlen(pHandle->subKey), pHandle->consumerId, - TD_VID(pTq->pVnode)); + tqDebug("tq save %s(%d) consumer %" PRId64 " vgId:%d", pHandle->subKey, (int32_t)strlen(pHandle->subKey), + pHandle->consumerId, TD_VID(pTq->pVnode)); void* buf = taosMemoryCalloc(1, vlen); if (buf == NULL) { diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 4083a1a0ae..5ffbc41eb5 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -213,7 +213,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ #endif int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { - tqDebug("vgId:%d tq push msg ver %ld, type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType)); + tqDebug("vgId:%d tq push msg ver %" PRId64 ", type: %s", pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType)); if (msgType == TDMT_VND_SUBMIT) { // lock push mgr to avoid potential msg lost @@ -246,8 +246,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) continue; } if (pPushEntry->dataRsp.reqOffset.version >= ver) { - tqDebug("vgId:%d push entry req version %ld, while push version %ld, skip", pTq->pVnode->config.vgId, - pPushEntry->dataRsp.reqOffset.version, ver); + tqDebug("vgId:%d push entry req version %" PRId64 ", while push version %" PRId64 ", skip", + pTq->pVnode->config.vgId, pPushEntry->dataRsp.reqOffset.version, ver); continue; } STqExecHandle* pExec = &pHandle->execHandle; diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index ab195b1eb3..efc2953400 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -36,7 +36,7 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl } else { name = buildCtbNameByGroupId(stbFullName, groupId); } - tqDebug("stream delete msg: groupId :%ld, name: %s", groupId, name); + tqDebug("stream delete msg: groupId :%" PRId64 ", name: %s", groupId, name); SMetaReader mr = {0}; metaReaderInit(&mr, pVnode->pMeta, 0); if (metaGetTableEntryByName(&mr, name) < 0) { @@ -435,7 +435,8 @@ void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { continue; } if (mr.me.ctbEntry.suid != suid) { - tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid: %ld, actual suid %ld", + tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid: %" PRId64 + ", actual suid %" PRId64 "", TD_VID(pVnode), ctbName, suid, mr.me.ctbEntry.suid); metaReaderClear(&mr); taosMemoryFree(ctbName); @@ -446,7 +447,8 @@ void tqTableSink1(SStreamTask* pTask, void* vnode, int64_t ver, void* data) { uid = mr.me.uid; metaReaderClear(&mr); - tqDebug("vgId:%d, stream write, table %s, uid %ld already exist, skip create", TD_VID(pVnode), ctbName, uid); + tqDebug("vgId:%d, stream write, table %s, uid %" PRId64 " already exist, skip create", TD_VID(pVnode), ctbName, + uid); taosMemoryFreeClear(ctbName); } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 3f88d478e2..9cce02f9ec 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -340,7 +340,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb pIter->pLastBlockReader = taosMemoryCalloc(1, sizeof(struct SLastBlockReader)); if (pIter->pLastBlockReader == NULL) { int32_t code = TSDB_CODE_OUT_OF_MEMORY; - tsdbError("failed to prepare the last block iterator, code:%s %s", tstrerror(code), pReader->idStr); + tsdbError("failed to prepare the last block iterator, since:%s %s", tstrerror(code), pReader->idStr); return code; } } @@ -645,11 +645,11 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN int32_t total = pBlockNum->numOfLastFiles + pBlockNum->numOfBlocks; double el = (taosGetTimestampUs() - st) / 1000.0; - tsdbDebug("load block of %" PRIzu - " tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed " - "time:%.2f ms %s", - numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el, - pReader->idStr); + tsdbDebug( + "load block of %ld tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed " + "time:%.2f ms %s", + numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el, + pReader->idStr); pReader->cost.numOfBlocks += total; pReader->cost.headFileLoadTime += el; diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 74c704598d..b08da24ff8 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -517,7 +517,7 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type _exit: if (code) { - tsdbError("vgId:%d %s failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), lino, tstrerror(code), + tsdbError("vgId:%d failed at line %d since %s, TSDB path: %s", TD_VID(pTsdb->pVnode), lino, tstrerror(code), pTsdb->path); *ppReader = NULL; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d0a00a8b6d..6f839ee8b4 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -1087,7 +1087,7 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void if (pVnode->config.szBuf != req.buffer * 1024LL * 1024LL) { vInfo("vgId:%d vnode buffer is changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pVnode->config.szBuf, - req.buffer * 1024LL * 1024LL); + (uint64_t)(req.buffer * 1024LL * 1024LL)); pVnode->config.szBuf = req.buffer * 1024LL * 1024LL; } diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 1d2e3640a1..63ddd45a4f 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -70,8 +70,8 @@ int32_t ctgInitGetTbMetasTask(SCtgJob* pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", pJob->queryId, taskIdx, - ctgTaskTypeStr(task.type), (int32_t)taosArrayGetSize(ctx->pNames), pJob->tbMetaNum); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%lu, tbNum:%d", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbMetaNum); return TSDB_CODE_SUCCESS; } @@ -201,8 +201,8 @@ int32_t ctgInitGetTbHashsTask(SCtgJob* pJob, int32_t taskIdx, void* param) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%d, tbNum:%d", pJob->queryId, taskIdx, - ctgTaskTypeStr(task.type), (int32_t)taosArrayGetSize(ctx->pNames), pJob->tbHashNum); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbNum:%lu, tbNum:%d", pJob->queryId, taskIdx, + ctgTaskTypeStr(task.type), taosArrayGetSize(ctx->pNames), pJob->tbHashNum); return TSDB_CODE_SUCCESS; } @@ -1667,7 +1667,7 @@ int32_t ctgLaunchGetTbMetasTask(SCtgTask* pTask) { int32_t baseResIdx = 0; for (int32_t i = 0; i < dbNum; ++i) { STablesReq* pReq = taosArrayGet(pCtx->pNames, i); - ctgDebug("start to check tb metas in db %s, tbNum %d", pReq->dbFName, (int32_t)taosArrayGetSize(pReq->pTables)); + ctgDebug("start to check tb metas in db %s, tbNum %ld", pReq->dbFName, taosArrayGetSize(pReq->pTables)); CTG_ERR_RET(ctgGetTbMetasFromCache(pCtg, pConn, pCtx, i, &fetchIdx, baseResIdx, pReq->pTables)); baseResIdx += taosArrayGetSize(pReq->pTables); } diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 55978855d1..9ea304dc46 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -103,7 +103,7 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey; } - qDebug("delete %ld rows, from %ld to %ld", pRes->affectedRows, pRes->skey, pRes->ekey); + qDebug("delete %" PRId64 " rows, from %" PRId64 " to %" PRId64 "", pRes->affectedRows, pRes->skey, pRes->ekey); pBuf->useSize += pEntry->dataLen; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 79f6166079..bf24fe3a3e 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -930,7 +930,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); int64_t* uid = taosArrayGet(res, i); - qDebug("tagfilter get uid:%ld, res:%d", *uid, *(bool*)var); + qDebug("tagfilter get uid:%" PRId64 ", res:%d", *uid, *(bool*)var); if (*(bool*)var == false) { taosArrayRemove(res, i); j++; @@ -952,7 +952,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, return TSDB_CODE_OUT_OF_MEMORY; } - qDebug("tagfilter get uid:%ld", info.uid); + qDebug("tagfilter get uid:%" PRId64 "", info.uid); } taosArrayDestroy(res); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 0d861c1fb9..8016e95c3e 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -857,7 +857,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); pTaskInfo->streamInfo.schema = mtInfo.schema; - qDebug("tmqsnap qStreamPrepareScan snapshot data uid %ld ts %"PRId64, mtInfo.uid, pOffset->ts); + qDebug("tmqsnap qStreamPrepareScan snapshot data uid %" PRId64 " ts %" PRId64, mtInfo.uid, pOffset->ts); } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) { SStreamRawScanInfo* pInfo = pOperator->info; SSnapContext* sContext = pInfo->sContext; @@ -865,7 +865,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version); return -1; } - qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %ld ts %"PRId64, pOffset->uid, pOffset->ts); + qDebug("tmqsnap qStreamPrepareScan snapshot meta uid %" PRId64 " ts %" PRId64, pOffset->uid, pOffset->ts); } else if (pOffset->type == TMQ_OFFSET__LOG) { SStreamRawScanInfo* pInfo = pOperator->info; tsdbReaderClose(pInfo->dataReader); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index a7e98527f4..3456a0eee0 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1774,7 +1774,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { } else { taosMemoryFree(pMsg->pData); pSourceDataInfo->code = code; - qDebug("%s fetch rsp received, index:%d, code:%s", pSourceDataInfo->taskId, index, tstrerror(code)); + qDebug("%s fetch rsp received, index:%d, error:%s", pSourceDataInfo->taskId, index, tstrerror(code)); } pSourceDataInfo->status = EX_SOURCE_DATA_READY; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 8e1858d8c0..7efd6feb16 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1551,7 +1551,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { tsdbReaderClose(pTSInfo->dataReader); pTSInfo->dataReader = NULL; tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer); - qDebug("queue scan tsdb over, switch to wal ver %"PRId64, pTaskInfo->streamInfo.snapshotVer + 1); + qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1); if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1) < 0) { return NULL; } @@ -1983,7 +1983,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { longjmp(pTaskInfo->env, terrno); } - qDebug("tmqsnap doRawScan get data uid:%ld", pBlock->info.uid); + qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.uid); pTaskInfo->streamInfo.lastStatus.type = TMQ_OFFSET__SNAPSHOT_DATA; pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.uid; pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey; @@ -1999,7 +1999,7 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { } else { pTaskInfo->streamInfo.prepareStatus.uid = mtInfo.uid; pTaskInfo->streamInfo.prepareStatus.ts = INT64_MIN; - qDebug("tmqsnap change get data uid:%ld", mtInfo.uid); + qDebug("tmqsnap change get data uid:%" PRId64 "", mtInfo.uid); qStreamPrepareScan(pTaskInfo, &pTaskInfo->streamInfo.prepareStatus, pInfo->sContext->subType); } tDeleteSSchemaWrapper(mtInfo.schema); @@ -3334,7 +3334,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags int64_t st = taosGetTimestampUs(); if (pHandle == NULL) { - qError("invalid handle, in creating operator tree", idStr); + qError("invalid handle, in creating operator tree: %s", idStr); return TSDB_CODE_INVALID_PARA; } diff --git a/source/libs/executor/src/tsimplehash.c b/source/libs/executor/src/tsimplehash.c index b66a6f6770..a5168d24ba 100644 --- a/source/libs/executor/src/tsimplehash.c +++ b/source/libs/executor/src/tsimplehash.c @@ -105,8 +105,8 @@ static void tSimpleHashTableResize(SSHashObj *pHashObj) { int32_t newCapacity = (int32_t)(pHashObj->capacity << 1u); if (newCapacity > HASH_MAX_CAPACITY) { - uDebug("current capacity:%"PRIzu", maximum capacity:%" PRIu64 ", no resize applied due to limitation is reached", - pHashObj->capacity, HASH_MAX_CAPACITY); + uDebug("current capacity:%" PRIzu ", maximum capacity:%" PRId32 ", no resize applied due to limitation is reached", + pHashObj->capacity, (int32_t)HASH_MAX_CAPACITY); return; } @@ -388,4 +388,4 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) { } return NULL; -} \ No newline at end of file +} diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 7077a9b780..5478711e81 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2540,8 +2540,9 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { tdigestAdd(pInfo->pTDigest, v, w); } } else { - qDebug("%s before add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__, - numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems); + qDebug("%s before add %d elements into histogram, total:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems: %p", + __FUNCTION__, numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, + pInfo->pHisto->elems); // might be a race condition here that pHisto can be overwritten or setup function // has not been called, need to relink the buffer pHisto points to. @@ -2558,8 +2559,9 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { tHistogramAdd(&pInfo->pHisto, v); } - qDebug("%s after add %d elements into histogram, total:%d, numOfEntry:%d, pHisto:%p, elems: %p", __FUNCTION__, - numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, pInfo->pHisto->elems); + qDebug("%s after add %d elements into histogram, total:%" PRId64 ", numOfEntry:%d, pHisto:%p, elems: %p", + __FUNCTION__, numOfElems, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto, + pInfo->pHisto->elems); } SET_VAL(pResInfo, numOfElems, 1); @@ -2638,7 +2640,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { } if (pInfo->algo != APERCT_ALGO_TDIGEST) { - qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, + qDebug("%s after merge, total:%" PRId64 ", numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries, pInfo->pHisto); } diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 1483394509..5b8389078f 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -1269,7 +1269,7 @@ void udfcUvHandleRsp(SClientUvConn *conn) { SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, connTaskQueue); while (h != &conn->taskQueue) { - fnDebug("udfc handle response iterate through queue. uvTask:%d-%p", task->seqNum, task); + fnDebug("udfc handle response iterate through queue. uvTask:%" PRId64 "-%p", task->seqNum, task); if (task->seqNum == seqNum) { if (found == false) { found = true; diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 0ff40f3b9a..0b5b051679 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -258,7 +258,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, dsGetDataLength(ctx->sinkHandle, &len, &queryEnd); if (len < 0) { - QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64, len); + QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64 "", len); QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } @@ -292,7 +292,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, } // Got data from sink - QW_TASK_DLOG("there are data in sink, dataLength:%" PRId64, len); + QW_TASK_DLOG("there are data in sink, dataLength:%" PRId64 "", len); *dataLen += len; diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 4a35a15d3e..939dcac3d6 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -408,7 +408,7 @@ static int32_t syncNodeDoMakeLogSame(SSyncNode* ths, SyncIndex FromIndex) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "update delete begin to %ld", delBegin); + snprintf(logBuf, sizeof(logBuf), "update delete begin to %" PRId64, delBegin); syncNodeEventLog(ths, logBuf); } while (0); } @@ -419,7 +419,8 @@ static int32_t syncNodeDoMakeLogSame(SSyncNode* ths, SyncIndex FromIndex) { do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "make log same from:%ld, delbegin:%ld, pass:%d", FromIndex, delBegin, pass); + snprintf(logBuf, sizeof(logBuf), "make log same from:%" PRId64 ", delbegin:%" PRId64 ", pass:%d", FromIndex, + delBegin, pass); syncNodeEventLog(ths, logBuf); } while (0); diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 511113352e..6239726823 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -77,8 +77,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { } else { pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); if (pEntry == NULL) { - sError("failed to get entry since %s. index:%lld", tstrerror(terrno), index); - return; + sError("failed to get entry since %s. index:%" PRId64, tstrerror(terrno), index); + return; } } // cannot commit, even if quorum agree. need check term! diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 28b5313ac5..fcbf4a9032 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -200,28 +200,28 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRa // for debug ------------------- void syncIndexMgrPrint(SSyncIndexMgr *pObj) { char *serialized = syncIndexMgr2Str(pObj); - printf("syncIndexMgrPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncIndexMgrPrint | len:%" PRIu64 " | %s \n", (uint64_t)strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncIndexMgrPrint2(char *s, SSyncIndexMgr *pObj) { char *serialized = syncIndexMgr2Str(pObj); - printf("syncIndexMgrPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncIndexMgrPrint2 | len:%" PRIu64 " | %s | %s \n", (uint64_t)strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncIndexMgrLog(SSyncIndexMgr *pObj) { char *serialized = syncIndexMgr2Str(pObj); - sTrace("syncIndexMgrLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncIndexMgrLog | len:%" PRIu64 " | %s", (uint64_t)strlen(serialized), serialized); taosMemoryFree(serialized); } void syncIndexMgrLog2(char *s, SSyncIndexMgr *pObj) { if (gRaftDetailLog) { char *serialized = syncIndexMgr2Str(pObj); - sTrace("syncIndexMgrLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncIndexMgrLog2 | len:%" PRIu64 " | %s | %s", (uint64_t)strlen(serialized), s, serialized); taosMemoryFree(serialized); } } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 83bd7a5f38..3de6d1a65a 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -67,7 +67,7 @@ int32_t syncInit() { syncCleanUp(); ret = -1; } else { - sDebug("sync rsetId:%" PRId64 " is open", tsNodeRefId); + sDebug("sync rsetId:%" PRId32 " is open", tsNodeRefId); ret = syncEnvStart(); } } @@ -80,7 +80,7 @@ void syncCleanUp() { ASSERT(ret == 0); if (tsNodeRefId != -1) { - sDebug("sync rsetId:%" PRId64 " is closed", tsNodeRefId); + sDebug("sync rsetId:%" PRId32 " is closed", tsNodeRefId); taosCloseRef(tsNodeRefId); tsNodeRefId = -1; } @@ -100,7 +100,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) { return -1; } - sDebug("vgId:%d, sync rid:%" PRId64 " is added to rsetId:%" PRId64, pSyncInfo->vgId, pSyncNode->rid, tsNodeRefId); + sDebug("vgId:%d, sync rid:%" PRId64 " is added to rsetId:%" PRId32, pSyncInfo->vgId, pSyncNode->rid, tsNodeRefId); return pSyncNode->rid; } @@ -146,7 +146,7 @@ void syncStop(int64_t rid) { taosReleaseRef(tsNodeRefId, pSyncNode->rid); taosRemoveRef(tsNodeRefId, rid); - sDebug("vgId:%d, sync rid:%" PRId64 " is removed from rsetId:%" PRId64, vgId, rid, tsNodeRefId); + sDebug("vgId:%d, sync rid:%" PRId64 " is removed from rsetId:%" PRId64, vgId, rid, (int64_t)tsNodeRefId); } int32_t syncSetStandby(int64_t rid) { @@ -316,7 +316,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) { } do { - char logBuf[128]; + char logBuf[256]; snprintf(logBuf, sizeof(logBuf), "begin leader transfer to %s:%u", newLeader.nodeFqdn, newLeader.nodePort); syncNodeEventLog(pSyncNode, logBuf); } while (0); @@ -867,8 +867,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) { if (!pSyncNode->restoreFinish && pSyncNode->vgId != 1) { ret = -1; terrno = TSDB_CODE_SYN_PROPOSE_NOT_READY; - sError("vgId:%d, failed to sync propose since not ready, type:%s, last:%ld, cmt:%ld", pSyncNode->vgId, - TMSG_INFO(pMsg->msgType), syncNodeGetLastIndex(pSyncNode), pSyncNode->commitIndex); + sError("vgId:%d, failed to sync propose since not ready, type:%s, last:%" PRId64 ", cmt:%" PRId64 "", + pSyncNode->vgId, TMSG_INFO(pMsg->msgType), syncNodeGetLastIndex(pSyncNode), pSyncNode->commitIndex); goto _END; } @@ -2475,35 +2475,35 @@ int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex // for debug -------------- void syncNodePrint(SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - printf("syncNodePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncNodePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncNodePrint2(char* s, SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - printf("syncNodePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncNodePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncNodeLog(SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - sTraceLong("syncNodeLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTraceLong("syncNodeLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncNodeLog2(char* s, SSyncNode* pObj) { if (gRaftDetailLog) { char* serialized = syncNode2Str(pObj); - sTraceLong("syncNodeLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncNodeLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } void syncNodeLog3(char* s, SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); - sTraceLong("syncNodeLog3 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncNodeLog3 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } @@ -2870,14 +2870,14 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p if (pEntry->term < ths->pRaftStore->currentTerm) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "little term:%lu, can not do leader transfer", pEntry->term); + snprintf(logBuf, sizeof(logBuf), "little term:%" PRIu64 ", can not do leader transfer", pEntry->term); syncNodeEventLog(ths, logBuf); return 0; } if (pEntry->index < syncNodeGetLastIndex(ths)) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "little index:%ld, can not do leader transfer", pEntry->index); + snprintf(logBuf, sizeof(logBuf), "little index:%" PRId64 ", can not do leader transfer", pEntry->index); syncNodeEventLog(ths, logBuf); return 0; } @@ -2893,7 +2893,7 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p do { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "do leader transfer, index:%ld", pEntry->index); + snprintf(logBuf, sizeof(logBuf), "do leader transfer, index:%" PRId64 "", pEntry->index); syncNodeEventLog(ths, logBuf); } while (0); @@ -3072,8 +3072,8 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, } else { code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry); if (code != 0) { - sError("vgId:%d, failed to get log entry since %s. index:%lld", ths->vgId, tstrerror(terrno), i); - return -1; + sError("vgId:%d, failed to get log entry since %s. index:%" PRId64 "", ths->vgId, tstrerror(terrno), i); + return -1; } ASSERT(pEntry != NULL); } @@ -3152,8 +3152,8 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, int64_t restoreDelay = taosGetTimestampMs() - ths->leaderTime; char eventLog[128]; - snprintf(eventLog, sizeof(eventLog), "restore finish, index:%ld, elapsed:%ld ms, ", pEntry->index, - restoreDelay); + snprintf(eventLog, sizeof(eventLog), "restore finish, index:%" PRId64 ", elapsed:%" PRId64 " ms, ", + pEntry->index, restoreDelay); syncNodeEventLog(ths, eventLog); } } diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index faebe5bbec..7c871d0542 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -133,28 +133,28 @@ char* syncRpcMsg2Str(SRpcMsg* pRpcMsg) { // for debug ---------------------- void syncRpcMsgPrint(SRpcMsg* pMsg) { char* serialized = syncRpcMsg2Str(pMsg); - printf("syncRpcMsgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncRpcMsgPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRpcMsgPrint2(char* s, SRpcMsg* pMsg) { char* serialized = syncRpcMsg2Str(pMsg); - printf("syncRpcMsgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncRpcMsgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRpcMsgLog(SRpcMsg* pMsg) { char* serialized = syncRpcMsg2Str(pMsg); - sTrace("syncRpcMsgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncRpcMsgLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncRpcMsgLog2(char* s, SRpcMsg* pMsg) { if (gRaftDetailLog) { char* serialized = syncRpcMsg2Str(pMsg); - sTrace("syncRpcMsgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncRpcMsgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -271,21 +271,21 @@ void syncTimeoutPrint(const SyncTimeout* pMsg) { void syncTimeoutPrint2(char* s, const SyncTimeout* pMsg) { char* serialized = syncTimeout2Str(pMsg); - printf("syncTimeoutPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncTimeoutPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncTimeoutLog(const SyncTimeout* pMsg) { char* serialized = syncTimeout2Str(pMsg); - sTrace("syncTimeoutLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncTimeoutLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncTimeoutLog2(char* s, const SyncTimeout* pMsg) { if (gRaftDetailLog) { char* serialized = syncTimeout2Str(pMsg); - sTrace("syncTimeoutLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncTimeoutLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -526,28 +526,28 @@ char* syncPing2Str(const SyncPing* pMsg) { // for debug ---------------------- void syncPingPrint(const SyncPing* pMsg) { char* serialized = syncPing2Str(pMsg); - printf("syncPingPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncPingPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncPingPrint2(char* s, const SyncPing* pMsg) { char* serialized = syncPing2Str(pMsg); - printf("syncPingPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncPingPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncPingLog(const SyncPing* pMsg) { char* serialized = syncPing2Str(pMsg); - sTrace("syncPingLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncPingLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncPingLog2(char* s, const SyncPing* pMsg) { if (gRaftDetailLog) { char* serialized = syncPing2Str(pMsg); - sTrace("syncPingLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncPingLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -931,28 +931,28 @@ char* syncClientRequest2Str(const SyncClientRequest* pMsg) { // for debug ---------------------- void syncClientRequestPrint(const SyncClientRequest* pMsg) { char* serialized = syncClientRequest2Str(pMsg); - printf("syncClientRequestPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncClientRequestPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestPrint2(char* s, const SyncClientRequest* pMsg) { char* serialized = syncClientRequest2Str(pMsg); - printf("syncClientRequestPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncClientRequestPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestLog(const SyncClientRequest* pMsg) { char* serialized = syncClientRequest2Str(pMsg); - sTrace("syncClientRequestLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncClientRequestLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) { if (gRaftDetailLog) { char* serialized = syncClientRequest2Str(pMsg); - sTrace("syncClientRequestLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncClientRequestLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1101,28 +1101,28 @@ char* syncClientRequestBatch2Str(const SyncClientRequestBatch* pMsg) { // for debug ---------------------- void syncClientRequestBatchPrint(const SyncClientRequestBatch* pMsg) { char* serialized = syncClientRequestBatch2Str(pMsg); - printf("syncClientRequestBatchPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncClientRequestBatchPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestBatchPrint2(char* s, const SyncClientRequestBatch* pMsg) { char* serialized = syncClientRequestBatch2Str(pMsg); - printf("syncClientRequestBatchPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncClientRequestBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncClientRequestBatchLog(const SyncClientRequestBatch* pMsg) { char* serialized = syncClientRequestBatch2Str(pMsg); - sTrace("syncClientRequestBatchLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncClientRequestBatchLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncClientRequestBatchLog2(char* s, const SyncClientRequestBatch* pMsg) { if (gRaftDetailLog) { char* serialized = syncClientRequestBatch2Str(pMsg); - sTraceLong("syncClientRequestBatchLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncClientRequestBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1252,28 +1252,28 @@ char* syncRequestVote2Str(const SyncRequestVote* pMsg) { // for debug ---------------------- void syncRequestVotePrint(const SyncRequestVote* pMsg) { char* serialized = syncRequestVote2Str(pMsg); - printf("syncRequestVotePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncRequestVotePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVotePrint2(char* s, const SyncRequestVote* pMsg) { char* serialized = syncRequestVote2Str(pMsg); - printf("syncRequestVotePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncRequestVotePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVoteLog(const SyncRequestVote* pMsg) { char* serialized = syncRequestVote2Str(pMsg); - sTrace("syncRequestVoteLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncRequestVoteLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncRequestVoteLog2(char* s, const SyncRequestVote* pMsg) { if (gRaftDetailLog) { char* serialized = syncRequestVote2Str(pMsg); - sTrace("syncRequestVoteLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncRequestVoteLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1400,28 +1400,28 @@ char* syncRequestVoteReply2Str(const SyncRequestVoteReply* pMsg) { // for debug ---------------------- void syncRequestVoteReplyPrint(const SyncRequestVoteReply* pMsg) { char* serialized = syncRequestVoteReply2Str(pMsg); - printf("syncRequestVoteReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncRequestVoteReplyPrint | len:%ld | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVoteReplyPrint2(char* s, const SyncRequestVoteReply* pMsg) { char* serialized = syncRequestVoteReply2Str(pMsg); - printf("syncRequestVoteReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncRequestVoteReplyPrint2 | len:%ld | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncRequestVoteReplyLog(const SyncRequestVoteReply* pMsg) { char* serialized = syncRequestVoteReply2Str(pMsg); - sTrace("syncRequestVoteReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncRequestVoteReplyLog | len:%ld | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncRequestVoteReplyLog2(char* s, const SyncRequestVoteReply* pMsg) { if (gRaftDetailLog) { char* serialized = syncRequestVoteReply2Str(pMsg); - sTrace("syncRequestVoteReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncRequestVoteReplyLog2 | len:%ld | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1571,28 +1571,28 @@ char* syncAppendEntries2Str(const SyncAppendEntries* pMsg) { // for debug ---------------------- void syncAppendEntriesPrint(const SyncAppendEntries* pMsg) { char* serialized = syncAppendEntries2Str(pMsg); - printf("syncAppendEntriesPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncAppendEntriesPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesPrint2(char* s, const SyncAppendEntries* pMsg) { char* serialized = syncAppendEntries2Str(pMsg); - printf("syncAppendEntriesPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncAppendEntriesPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesLog(const SyncAppendEntries* pMsg) { char* serialized = syncAppendEntries2Str(pMsg); - sTrace("syncAppendEntriesLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncAppendEntriesLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncAppendEntriesLog2(char* s, const SyncAppendEntries* pMsg) { if (gRaftDetailLog) { char* serialized = syncAppendEntries2Str(pMsg); - sTrace("syncAppendEntriesLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncAppendEntriesLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1810,28 +1810,28 @@ char* syncAppendEntriesBatch2Str(const SyncAppendEntriesBatch* pMsg) { // for debug ---------------------- void syncAppendEntriesBatchPrint(const SyncAppendEntriesBatch* pMsg) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - printf("syncAppendEntriesBatchPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncAppendEntriesBatchPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesBatchPrint2(char* s, const SyncAppendEntriesBatch* pMsg) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - printf("syncAppendEntriesBatchPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncAppendEntriesBatchPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesBatchLog(const SyncAppendEntriesBatch* pMsg) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - sTrace("syncAppendEntriesBatchLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncAppendEntriesBatchLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncAppendEntriesBatchLog2(char* s, const SyncAppendEntriesBatch* pMsg) { if (gRaftDetailLog) { char* serialized = syncAppendEntriesBatch2Str(pMsg); - sTraceLong("syncAppendEntriesBatchLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("syncAppendEntriesBatchLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -1966,28 +1966,28 @@ char* syncAppendEntriesReply2Str(const SyncAppendEntriesReply* pMsg) { // for debug ---------------------- void syncAppendEntriesReplyPrint(const SyncAppendEntriesReply* pMsg) { char* serialized = syncAppendEntriesReply2Str(pMsg); - printf("syncAppendEntriesReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncAppendEntriesReplyPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesReplyPrint2(char* s, const SyncAppendEntriesReply* pMsg) { char* serialized = syncAppendEntriesReply2Str(pMsg); - printf("syncAppendEntriesReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncAppendEntriesReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncAppendEntriesReplyLog(const SyncAppendEntriesReply* pMsg) { char* serialized = syncAppendEntriesReply2Str(pMsg); - sTrace("syncAppendEntriesReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncAppendEntriesReplyLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncAppendEntriesReplyLog2(char* s, const SyncAppendEntriesReply* pMsg) { if (gRaftDetailLog) { char* serialized = syncAppendEntriesReply2Str(pMsg); - sTrace("syncAppendEntriesReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncAppendEntriesReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2119,28 +2119,28 @@ char* syncHeartbeat2Str(const SyncHeartbeat* pMsg) { void syncHeartbeatPrint(const SyncHeartbeat* pMsg) { char* serialized = syncHeartbeat2Str(pMsg); - printf("syncHeartbeatPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncHeartbeatPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncHeartbeatPrint2(char* s, const SyncHeartbeat* pMsg) { char* serialized = syncHeartbeat2Str(pMsg); - printf("syncHeartbeatPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncHeartbeatPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncHeartbeatLog(const SyncHeartbeat* pMsg) { char* serialized = syncHeartbeat2Str(pMsg); - sTrace("syncHeartbeatLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncHeartbeatLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncHeartbeatLog2(char* s, const SyncHeartbeat* pMsg) { if (gRaftDetailLog) { char* serialized = syncHeartbeat2Str(pMsg); - sTrace("syncHeartbeatLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncHeartbeatLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2273,28 +2273,28 @@ char* syncHeartbeatReply2Str(const SyncHeartbeatReply* pMsg) { void syncHeartbeatReplyPrint(const SyncHeartbeatReply* pMsg) { char* serialized = syncHeartbeatReply2Str(pMsg); - printf("syncHeartbeatReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncHeartbeatReplyPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncHeartbeatReplyPrint2(char* s, const SyncHeartbeatReply* pMsg) { char* serialized = syncHeartbeatReply2Str(pMsg); - printf("syncHeartbeatReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncHeartbeatReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncHeartbeatReplyLog(const SyncHeartbeatReply* pMsg) { char* serialized = syncHeartbeatReply2Str(pMsg); - sTrace("syncHeartbeatReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncHeartbeatReplyLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg) { if (gRaftDetailLog) { char* serialized = syncHeartbeatReply2Str(pMsg); - sTrace("syncHeartbeatReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncHeartbeatReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2426,28 +2426,28 @@ char* syncApplyMsg2Str(const SyncApplyMsg* pMsg) { // for debug ---------------------- void syncApplyMsgPrint(const SyncApplyMsg* pMsg) { char* serialized = syncApplyMsg2Str(pMsg); - printf("syncApplyMsgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncApplyMsgPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncApplyMsgPrint2(char* s, const SyncApplyMsg* pMsg) { char* serialized = syncApplyMsg2Str(pMsg); - printf("syncApplyMsgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncApplyMsgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncApplyMsgLog(const SyncApplyMsg* pMsg) { char* serialized = syncApplyMsg2Str(pMsg); - sTrace("ssyncApplyMsgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("ssyncApplyMsgLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncApplyMsgLog2(char* s, const SyncApplyMsg* pMsg) { if (gRaftDetailLog) { char* serialized = syncApplyMsg2Str(pMsg); - sTrace("syncApplyMsgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncApplyMsgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2603,28 +2603,28 @@ char* syncSnapshotSend2Str(const SyncSnapshotSend* pMsg) { // for debug ---------------------- void syncSnapshotSendPrint(const SyncSnapshotSend* pMsg) { char* serialized = syncSnapshotSend2Str(pMsg); - printf("syncSnapshotSendPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncSnapshotSendPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotSendPrint2(char* s, const SyncSnapshotSend* pMsg) { char* serialized = syncSnapshotSend2Str(pMsg); - printf("syncSnapshotSendPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncSnapshotSendPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotSendLog(const SyncSnapshotSend* pMsg) { char* serialized = syncSnapshotSend2Str(pMsg); - sTrace("syncSnapshotSendLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncSnapshotSendLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncSnapshotSendLog2(char* s, const SyncSnapshotSend* pMsg) { if (gRaftDetailLog) { char* serialized = syncSnapshotSend2Str(pMsg); - sTrace("syncSnapshotSendLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncSnapshotSendLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2763,28 +2763,28 @@ char* syncSnapshotRsp2Str(const SyncSnapshotRsp* pMsg) { // for debug ---------------------- void syncSnapshotRspPrint(const SyncSnapshotRsp* pMsg) { char* serialized = syncSnapshotRsp2Str(pMsg); - printf("syncSnapshotRspPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncSnapshotRspPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotRspPrint2(char* s, const SyncSnapshotRsp* pMsg) { char* serialized = syncSnapshotRsp2Str(pMsg); - printf("syncSnapshotRspPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncSnapshotRspPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncSnapshotRspLog(const SyncSnapshotRsp* pMsg) { char* serialized = syncSnapshotRsp2Str(pMsg); - sTrace("syncSnapshotRspLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncSnapshotRspLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncSnapshotRspLog2(char* s, const SyncSnapshotRsp* pMsg) { if (gRaftDetailLog) { char* serialized = syncSnapshotRsp2Str(pMsg); - sTrace("syncSnapshotRspLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncSnapshotRspLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -2925,28 +2925,28 @@ char* syncLeaderTransfer2Str(const SyncLeaderTransfer* pMsg) { // for debug ---------------------- void syncLeaderTransferPrint(const SyncLeaderTransfer* pMsg) { char* serialized = syncLeaderTransfer2Str(pMsg); - printf("syncLeaderTransferPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncLeaderTransferPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg) { char* serialized = syncLeaderTransfer2Str(pMsg); - printf("syncLeaderTransferPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncLeaderTransferPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncLeaderTransferLog(const SyncLeaderTransfer* pMsg) { char* serialized = syncLeaderTransfer2Str(pMsg); - sTrace("syncLeaderTransferLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncLeaderTransferLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncLeaderTransferLog2(char* s, const SyncLeaderTransfer* pMsg) { if (gRaftDetailLog) { char* serialized = syncLeaderTransfer2Str(pMsg); - sTrace("syncLeaderTransferLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncLeaderTransferLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -3054,28 +3054,28 @@ char* syncReconfigFinish2Str(const SyncReconfigFinish* pMsg) { // for debug ---------------------- void syncReconfigFinishPrint(const SyncReconfigFinish* pMsg) { char* serialized = syncReconfigFinish2Str(pMsg); - printf("syncReconfigFinishPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncReconfigFinishPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncReconfigFinishPrint2(char* s, const SyncReconfigFinish* pMsg) { char* serialized = syncReconfigFinish2Str(pMsg); - printf("syncReconfigFinishPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncReconfigFinishPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncReconfigFinishLog(const SyncReconfigFinish* pMsg) { char* serialized = syncReconfigFinish2Str(pMsg); - sTrace("syncReconfigFinishLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncReconfigFinishLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg) { if (gRaftDetailLog) { char* serialized = syncReconfigFinish2Str(pMsg); - sTrace("syncReconfigFinishLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncReconfigFinishLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index 57126d0871..cf5bd24899 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -447,85 +447,85 @@ int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg) { // for debug ---------------------- void syncCfgPrint(SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - printf("syncCfgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("syncCfgPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void syncCfgPrint2(char *s, SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - printf("syncCfgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("syncCfgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void syncCfgLog(SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - sTrace("syncCfgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("syncCfgLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void syncCfgLog2(char *s, SSyncCfg *pCfg) { char *serialized = syncCfg2Str(pCfg); - sTrace("syncCfgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncCfgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } void syncCfgLog3(char *s, SSyncCfg *pCfg) { char *serialized = syncCfg2SimpleStr(pCfg); - sTrace("syncCfgLog3 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("syncCfgLog3 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } void raftCfgPrint(SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - printf("raftCfgPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("raftCfgPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCfgPrint2(char *s, SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - printf("raftCfgPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("raftCfgPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCfgLog(SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - sTrace("raftCfgLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("raftCfgLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftCfgLog2(char *s, SRaftCfg *pCfg) { char *serialized = raftCfg2Str(pCfg); - sTrace("raftCfgLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("raftCfgLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } // --------- void raftCfgIndexPrint(SRaftCfgIndex *pCfg) { char *serialized = raftCfgIndex2Str(pCfg); - printf("raftCfgIndexPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("raftCfgIndexPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCfgIndexPrint2(char *s, SRaftCfgIndex *pCfg) { char *serialized = raftCfgIndex2Str(pCfg); - printf("raftCfgIndexPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("raftCfgIndexPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCfgIndexLog(SRaftCfgIndex *pCfg) { char *serialized = raftCfgIndex2Str(pCfg); - sTrace("raftCfgIndexLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("raftCfgIndexLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftCfgIndexLog2(char *s, SRaftCfgIndex *pCfg) { char *serialized = raftCfgIndex2Str(pCfg); - sTrace("raftCfgIndexLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("raftCfgIndexLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index c481c55e1c..818ffa57a6 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -418,28 +418,28 @@ char* raftCache2Str(SRaftEntryHashCache* pCache) { void raftCachePrint(SRaftEntryHashCache* pCache) { char* serialized = raftCache2Str(pCache); - printf("raftCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("raftCachePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCachePrint2(char* s, SRaftEntryHashCache* pCache) { char* serialized = raftCache2Str(pCache); - printf("raftCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("raftCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftCacheLog(SRaftEntryHashCache* pCache) { char* serialized = raftCache2Str(pCache); - sTrace("raftCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("raftCacheLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftCacheLog2(char* s, SRaftEntryHashCache* pCache) { if (gRaftDetailLog) { char* serialized = raftCache2Str(pCache); - sTraceLong("raftCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("raftCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -677,28 +677,28 @@ char* raftEntryCache2Str(SRaftEntryCache* pObj) { void raftEntryCachePrint(SRaftEntryCache* pObj) { char* serialized = raftEntryCache2Str(pObj); - printf("raftEntryCachePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("raftEntryCachePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftEntryCachePrint2(char* s, SRaftEntryCache* pObj) { char* serialized = raftEntryCache2Str(pObj); - printf("raftEntryCachePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("raftEntryCachePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftEntryCacheLog(SRaftEntryCache* pObj) { char* serialized = raftEntryCache2Str(pObj); - sTrace("raftEntryCacheLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("raftEntryCacheLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftEntryCacheLog2(char* s, SRaftEntryCache* pObj) { if (gRaftDetailLog) { char* serialized = raftEntryCache2Str(pObj); - sTraceLong("raftEntryCacheLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("raftEntryCacheLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index c3dad104d1..3e806a0fb7 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -440,7 +440,7 @@ SSyncRaftEntry* logStoreGetEntryWithoutLock(SSyncLogStore* pLogStore, SyncIndex } } while (0); - sError("failed to read ver since %s. index:%lld", tstrerror(terrno), index); + sError("failed to read ver since %s. index:%" PRId64 "", tstrerror(terrno), index); return NULL; } @@ -675,14 +675,14 @@ SyncIndex logStoreWalCommitVer(SSyncLogStore* pLogStore) { // for debug ----------------- void logStorePrint(SSyncLogStore* pLogStore) { char* serialized = logStore2Str(pLogStore); - printf("logStorePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("logStorePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void logStorePrint2(char* s, SSyncLogStore* pLogStore) { char* serialized = logStore2Str(pLogStore); - printf("logStorePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("logStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } @@ -690,7 +690,7 @@ void logStorePrint2(char* s, SSyncLogStore* pLogStore) { void logStoreLog(SSyncLogStore* pLogStore) { if (gRaftDetailLog) { char* serialized = logStore2Str(pLogStore); - sTraceLong("logStoreLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTraceLong("logStoreLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } } @@ -698,7 +698,7 @@ void logStoreLog(SSyncLogStore* pLogStore) { void logStoreLog2(char* s, SSyncLogStore* pLogStore) { if (gRaftDetailLog) { char* serialized = logStore2Str(pLogStore); - sTraceLong("logStoreLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTraceLong("logStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } @@ -706,28 +706,28 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) { // for debug ----------------- void logStoreSimplePrint(SSyncLogStore* pLogStore) { char* serialized = logStoreSimple2Str(pLogStore); - printf("logStoreSimplePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("logStoreSimplePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void logStoreSimplePrint2(char* s, SSyncLogStore* pLogStore) { char* serialized = logStoreSimple2Str(pLogStore); - printf("logStoreSimplePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("logStoreSimplePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void logStoreSimpleLog(SSyncLogStore* pLogStore) { char* serialized = logStoreSimple2Str(pLogStore); - sTrace("logStoreSimpleLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("logStoreSimpleLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void logStoreSimpleLog2(char* s, SSyncLogStore* pLogStore) { if (gRaftDetailLog) { char* serialized = logStoreSimple2Str(pLogStore); - sTrace("logStoreSimpleLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("logStoreSimpleLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } } diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 6d4d54a9b1..a714a2c403 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -226,25 +226,25 @@ char *raftStore2Str(SRaftStore *pRaftStore) { // for debug ------------------- void raftStorePrint(SRaftStore *pObj) { char *serialized = raftStore2Str(pObj); - printf("raftStorePrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("raftStorePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void raftStorePrint2(char *s, SRaftStore *pObj) { char *serialized = raftStore2Str(pObj); - printf("raftStorePrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("raftStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void raftStoreLog(SRaftStore *pObj) { char *serialized = raftStore2Str(pObj); - sTrace("raftStoreLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("raftStoreLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void raftStoreLog2(char *s, SRaftStore *pObj) { char *serialized = raftStore2Str(pObj); - sTrace("raftStoreLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("raftStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 55553d5048..ff91315de7 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -127,7 +127,7 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl if (ths->state == TAOS_SYNC_STATE_CANDIDATE) { if (ths->pVotesRespond->term != pMsg->term) { char logBuf[128]; - snprintf(logBuf, sizeof(logBuf), "vote respond error vote-respond-mgr term:%lu, msg term:lu", + snprintf(logBuf, sizeof(logBuf), "vote respond error vote-respond-mgr term:%" PRIu64 ", msg term:%" PRIu64 "", ths->pVotesRespond->term, pMsg->term); syncNodeErrorLog(ths, logBuf); return -1; @@ -155,4 +155,4 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl } return 0; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncRespMgr.c b/source/libs/sync/src/syncRespMgr.c index 103c225476..30b29d335c 100644 --- a/source/libs/sync/src/syncRespMgr.c +++ b/source/libs/sync/src/syncRespMgr.c @@ -177,7 +177,7 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) { for (int32_t i = 0; i < arraySize; ++i) { uint64_t *pSeqNum = taosArrayGet(delIndexArray, i); taosHashRemove(pObj->pRespHash, pSeqNum, sizeof(uint64_t)); - sDebug("vgId:%d, resp mgr clean by ttl, seq:%d", pSyncNode->vgId, *pSeqNum); + sDebug("vgId:%d, resp mgr clean by ttl, seq:%" PRId64 "", pSyncNode->vgId, *pSeqNum); } taosArrayDestroy(delIndexArray); } diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index c3c8131cbb..fd7443222f 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -91,7 +91,7 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) { } else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) { if (atomic_load_64(&ths->electTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->electTimerCounter); - sTrace("vgId:%d, sync timer, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId, + sTrace("vgId:%d, sync timer, type:election count:%" PRId64 ", electTimerLogicClockUser:%" PRId64 "", ths->vgId, ths->electTimerCounter, ths->electTimerLogicClockUser); syncNodeElect(ths); } @@ -99,8 +99,8 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) { } else if (pMsg->timeoutType == SYNC_TIMEOUT_HEARTBEAT) { if (atomic_load_64(&ths->heartbeatTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->heartbeatTimerCounter); - sTrace("vgId:%d, sync timer, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId, - ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser); + sTrace("vgId:%d, sync timer, type:replicate count:%" PRId64 ", heartbeatTimerLogicClockUser:%" PRId64 "", + ths->vgId, ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser); syncNodeReplicate(ths, true); } } else { @@ -108,4 +108,4 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) { } return ret; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 09b79825d0..e10041d976 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -138,27 +138,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) { // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void voteGrantedPrint2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void voteGrantedLog(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void voteGrantedLog2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } @@ -267,26 +267,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) { // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized); + printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); taosMemoryFree(serialized); } void votesRespondPrint2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized); + printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); taosMemoryFree(serialized); } void votesRespondLog(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog | len:%" PRIu64 " | %s", strlen(serialized), serialized); + sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized); taosMemoryFree(serialized); } void votesRespondLog2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized); + sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); taosMemoryFree(serialized); } diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index a2803d3ecf..013c03c700 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -106,7 +106,8 @@ int32_t tdbBegin(TDB *pDb, TXN *pTxn) { for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) { ret = tdbPagerBegin(pPager, pTxn); if (ret < 0) { - tdbError("failed to begin pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId); + tdbError("failed to begin pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName, + pTxn->txnId); return -1; } } @@ -121,7 +122,8 @@ int32_t tdbCommit(TDB *pDb, TXN *pTxn) { for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) { ret = tdbPagerCommit(pPager, pTxn); if (ret < 0) { - tdbError("failed to commit pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId); + tdbError("failed to commit pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName, + pTxn->txnId); return -1; } } @@ -136,7 +138,8 @@ int32_t tdbAbort(TDB *pDb, TXN *pTxn) { for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) { ret = tdbPagerAbort(pPager, pTxn); if (ret < 0) { - tdbError("failed to abort pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId); + tdbError("failed to abort pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName, + pTxn->txnId); return -1; } } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 732a57639f..93f972b29e 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -301,8 +301,8 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn) pPage->pPager = pPageH->pPager; memcpy(pPage->pData, pPageH->pData, pPage->pageSize); - // tdbDebug("pcache/pPageH: %p %d %p %p %d", pPageH, pPageH->pPageHdr - pPageH->pData, pPageH->xCellSize, pPage, - // TDB_PAGE_PGNO(pPageH)); + // tdbDebug("pcache/pPageH: %p %ld %p %p %u", pPageH, pPageH->pPageHdr - pPageH->pData, pPageH->xCellSize, pPage, + // TDB_PAGE_PGNO(pPageH)); tdbPageInit(pPage, pPageH->pPageHdr - pPageH->pData, pPageH->xCellSize); pPage->kLen = pPageH->kLen; pPage->vLen = pPageH->vLen; diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 90332617cd..c1a21a9781 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -541,8 +541,8 @@ static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage) { ret = tdbOsWrite(pPager->jfd, pPage->pData, pPage->pageSize); if (ret < 0) { - tdbError("failed to write page data due to %s. file:%s, pageSize:%d", strerror(errno), pPager->jFileName, - pPage->pageSize); + tdbError("failed to write page data due to %s. file:%s, pageSize:%ld", strerror(errno), pPager->jFileName, + (long)pPage->pageSize); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -563,7 +563,7 @@ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) { offset = (i64)pPage->pageSize * (TDB_PAGE_PGNO(pPage) - 1); if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) { - tdbError("failed to lseek due to %s. file:%s, offset:%ld", strerror(errno), pPager->dbFileName, offset); + tdbError("failed to lseek due to %s. file:%s, offset:%" PRId64, strerror(errno), pPager->dbFileName, offset); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -618,7 +618,7 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) { i64 offset = pPager->pageSize * (pgno - 1); if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) { - tdbError("failed to lseek fd due to %s. file:%s, offset:%ld", strerror(errno), pPager->dbFileName, offset); + tdbError("failed to lseek fd due to %s. file:%s, offset:%" PRId64, strerror(errno), pPager->dbFileName, offset); terrno = TAOS_SYSTEM_ERROR(errno); tdbOsFree(pageBuf); return -1; diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 237a4b6059..f784b4c53e 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -100,11 +100,11 @@ void* rpcMallocCont(int64_t contLen) { int64_t size = contLen + TRANS_MSG_OVERHEAD; char* start = taosMemoryCalloc(1, size); if (start == NULL) { - tError("failed to malloc msg, size:%d", size); + tError("failed to malloc msg, size:%" PRId64, size); terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } else { - tTrace("malloc mem:%p size:%d", start, size); + tTrace("malloc mem:%p size:%" PRId64, start, size); } return start + sizeof(STransMsgHead); diff --git a/source/libs/transport/test/svrBench.c b/source/libs/transport/test/svrBench.c index 6eb80c8504..ce465d989a 100644 --- a/source/libs/transport/test/svrBench.c +++ b/source/libs/transport/test/svrBench.c @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) { dDebugFlag = rpcDebugFlag; uDebugFlag = rpcDebugFlag; } else { - printf("\nusage:% [options] \n", argv[0]); + printf("\nusage:%s [options] \n", argv[0]); printf(" [-p port]: server port number, default is:%d\n", rpcInit.localPort); printf(" [-t threads]: number of rpc threads, default is:%d\n", rpcInit.numOfThreads); printf(" [-s sessions]: number of sessions, default is:%d\n", rpcInit.sessions); diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index fa22805df2..55de61eb74 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -69,8 +69,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) { int64_t walCkHeadSz = sizeof(SWalCkHead); int64_t end = fileSize; int64_t offset = 0; - int32_t capacity = 0; - int32_t readSize = 0; + int64_t capacity = 0; + int64_t readSize = 0; char* buf = NULL; char* found = NULL; bool firstTrial = pFileInfo->fileSize < fileSize; @@ -200,8 +200,8 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) { // truncate file if (lastEntryEndOffset != fileSize) { - wWarn("vgId:%d, repair meta truncate file %s to %ld, orig size %ld", pWal->cfg.vgId, fnameStr, lastEntryEndOffset, - fileSize); + wWarn("vgId:%d, repair meta truncate file %s to %" PRId64 ", orig size %" PRId64, pWal->cfg.vgId, fnameStr, + lastEntryEndOffset, fileSize); if (taosFtruncateFile(pFile, lastEntryEndOffset) < 0) { wError("failed to truncate file due to %s. file:%s", strerror(errno), fnameStr); terrno = TAOS_SYSTEM_ERROR(errno); @@ -464,7 +464,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) { // determine the last valid entry end, i.e. offset while ((offset -= sizeof(SWalIdxEntry)) >= 0) { if (taosLSeekFile(pIdxFile, offset, SEEK_SET) < 0) { - wError("vgId:%d, failed to seek file due to %s. offset:" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno), + wError("vgId:%d, failed to seek file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno), offset, fnameStr); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -511,7 +511,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) { // rebuild idx file if (taosLSeekFile(pIdxFile, 0, SEEK_END) < 0) { - wError("vgId:%d, failed to seek file due to %s. offset:" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno), + wError("vgId:%d, failed to seek file due to %s. offset:%" PRId64 ", file:%s", pWal->cfg.vgId, strerror(errno), offset, fnameStr); terrno = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -528,7 +528,7 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) { idxEntry.offset, fLogNameStr); goto _err; } - wWarn("vgId:%d wal idx append new entry %ld %ld", pWal->cfg.vgId, idxEntry.ver, idxEntry.offset); + wWarn("vgId:%d wal idx append new entry %" PRId64 " %" PRId64, pWal->cfg.vgId, idxEntry.ver, idxEntry.offset); if (taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry)) < 0) { wError("vgId:%d, failed to append file since %s. file:%s", pWal->cfg.vgId, terrstr(), fnameStr); goto _err; diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 179d809c84..60c8591823 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -126,7 +126,7 @@ static int64_t walReadSeekFilePos(SWalReader *pReader, int64_t fileFirstVer, int wError("vgId:%d, failed to read idx file, since %s", pReader->pWal->cfg.vgId, terrstr()); } else { terrno = TSDB_CODE_WAL_FILE_CORRUPTED; - wError("vgId:%d, read idx file incompletely, read bytes %" PRId64 ", bytes should be %" PRIu64, + wError("vgId:%d, read idx file incompletely, read bytes %" PRId64 ", bytes should be %ld", pReader->pWal->cfg.vgId, ret, sizeof(SWalIdxEntry)); } return -1; @@ -182,7 +182,7 @@ int32_t walReadSeekVerImpl(SWalReader *pReader, int64_t ver) { tmpInfo.firstVer = ver; SWalFileInfo *pRet = taosArraySearch(pWal->fileInfoSet, &tmpInfo, compareWalFileInfo, TD_LE); if (pRet == NULL) { - wError("failed to find WAL log file with ver:%lld", ver); + wError("failed to find WAL log file with ver:%" PRId64, ver); terrno = TSDB_CODE_WAL_INVALID_VER; return -1; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 0562bbad27..3354308c49 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -419,7 +419,7 @@ static int32_t walWriteIndex(SWal *pWal, int64_t ver, int64_t offset) { int64_t size = taosWriteFile(pWal->pIdxFile, &entry, sizeof(SWalIdxEntry)); if (size != sizeof(SWalIdxEntry)) { - wError("vgId:%d, failed to write idx entry due to %s. ver:%lld", pWal->cfg.vgId, strerror(errno), ver); + wError("vgId:%d, failed to write idx entry due to %s. ver:%" PRId64, pWal->cfg.vgId, strerror(errno), ver); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -449,7 +449,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy pWal->writeHead.cksumHead = walCalcHeadCksum(&pWal->writeHead); pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen); - wDebug("vgId:%d, wal write log %ld, msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType)); + wDebug("vgId:%d, wal write log %" PRId64 ", msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType)); code = walWriteIndex(pWal, index, offset); if (code < 0) { @@ -484,16 +484,16 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy END: // recover in a reverse order if (taosFtruncateFile(pWal->pLogFile, offset) < 0) { - wFatal("vgId:%d, failed to ftruncate logfile to offset:%lld during recovery due to %s", pWal->cfg.vgId, offset, - strerror(errno)); + wFatal("vgId:%d, failed to ftruncate logfile to offset:%" PRId64 " during recovery due to %s", pWal->cfg.vgId, + offset, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); ASSERT(0 && "failed to recover from error"); } int64_t idxOffset = (index - pFileInfo->firstVer) * sizeof(SWalIdxEntry); if (taosFtruncateFile(pWal->pIdxFile, idxOffset) < 0) { - wFatal("vgId:%d, failed to ftruncate idxfile to offset:%lld during recovery due to %s", pWal->cfg.vgId, idxOffset, - strerror(errno)); + wFatal("vgId:%d, failed to ftruncate idxfile to offset:%" PRId64 "during recovery due to %s", pWal->cfg.vgId, + idxOffset, strerror(errno)); terrno = TAOS_SYSTEM_ERROR(errno); ASSERT(0 && "failed to recover from error"); } diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index a559a9c000..7d1686ef80 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -227,7 +227,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheNode * static FORCE_INLINE STrashElem *doRemoveElemInTrashcan(SCacheObj *pCacheObj, STrashElem *pElem) { if (pElem->pData->signature != pElem->pData) { - uWarn("key:sig:0x%" PRIx64 " %p data has been released, ignore", pElem->pData->signature, pElem->pData); + uWarn("key:sig:0x%" PRIx64 " %p data has been released, ignore", (int64_t)pElem->pData->signature, pElem->pData); return NULL; } diff --git a/utils/test/c/tmqSim.c b/utils/test/c/tmqSim.c index d36fe0855a..44dbb8a94a 100644 --- a/utils/test/c/tmqSim.c +++ b/utils/test/c/tmqSim.c @@ -1262,7 +1262,7 @@ void* ombProduceThreadFunc(void* param) { printf("Produce Info: totalSendLoopTimes: %d, batchPerTblTimes: %d, producerRate: %d\n", totalSendLoopTimes, batchPerTblTimes, pInfo->producerRate); - char ctbName[64] = {0}; + char ctbName[128] = {0}; sprintf(ctbName, "%s.ctb%d", g_stConfInfo.dbName, pInfo->consumerId); int64_t lastPrintTime = taosGetTimestampUs(); diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c index 4fe5fdf672..b399953938 100644 --- a/utils/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -288,7 +288,7 @@ int32_t simExecuteExpression(SScript *script, char *exp) { sprintf(t3, "%" PRId64, t1l / t2l); } } else if (op2[0] == '.') { - sprintf(t3, "%s%s", t1, t2); + snprintf(t3, sizeof(t3), "%s%s", t1, t2); } } else { tstrncpy(t3, t1, sizeof(t3)); @@ -794,7 +794,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { } taosLocalTime(&tt, &tp); - strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", &tp); + strftime(timeStr, 64, "%Y-%m-%d %H:%M:%S", &tp); if (precision == TSDB_TIME_PRECISION_MILLI) { sprintf(value, "%s.%03d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000)); } else if (precision == TSDB_TIME_PRECISION_MICRO) { From f23018e38a690246d2bf18fe704535edc796ae1e Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 19 Oct 2022 11:26:23 +0800 Subject: [PATCH 02/25] fix: get a thread id for printing with taosGetPthreadId --- source/dnode/mgmt/node_mgmt/src/dmProc.c | 8 ++++---- source/dnode/vnode/src/sma/smaEnv.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c index 0bd88a9f28..5cf73cf1fd 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmProc.c +++ b/source/dnode/mgmt/node_mgmt/src/dmProc.c @@ -380,7 +380,7 @@ int32_t dmRunProc(SProc *proc) { dError("node:%s, failed to create pthread since %s", proc->name, terrstr()); return -1; } - dDebug("node:%s, thread:%p is created to consume pqueue", proc->name, (void *)proc->pthread); + dDebug("node:%s, thread:%" PRId64 " is created to consume pqueue", proc->name, taosGetPthreadId(proc->pthread)); } if (proc->ptype & DND_PROC_CHILD) { @@ -389,7 +389,7 @@ int32_t dmRunProc(SProc *proc) { dError("node:%s, failed to create cthread since %s", proc->name, terrstr()); return -1; } - dDebug("node:%s, thread:%p is created to consume cqueue", proc->name, (void *)proc->cthread); + dDebug("node:%s, thread:%" PRId64 " is created to consume cqueue", proc->name, taosGetPthreadId(proc->cthread)); } taosThreadAttrDestroy(&thAttr); @@ -399,14 +399,14 @@ int32_t dmRunProc(SProc *proc) { void dmStopProc(SProc *proc) { proc->stop = true; if (taosCheckPthreadValid(proc->pthread)) { - dDebug("node:%s, start to join pthread:%p", proc->name, (void *)proc->pthread); + dDebug("node:%s, start to join pthread:%" PRId64 "", proc->name, taosGetPthreadId(proc->pthread)); tsem_post(&proc->pqueue->sem); taosThreadJoin(proc->pthread, NULL); taosThreadClear(&proc->pthread); } if (taosCheckPthreadValid(proc->cthread)) { - dDebug("node:%s, start to join cthread:%p", proc->name, (void *)proc->cthread); + dDebug("node:%s, start to join cthread:%" PRId64 "", proc->name, taosGetPthreadId(proc->cthread)); tsem_post(&proc->cqueue->sem); taosThreadJoin(proc->cthread, NULL); taosThreadClear(&proc->cthread); diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index 46b0a8ac1d..a272f5fc97 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -455,7 +455,7 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) { for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) { if (taosCheckPthreadValid(pthread[i])) { - smaDebug("vgId:%d, start to join pthread for rsma:%p", SMA_VID(pSma), (void *)pthread[i]); + smaDebug("vgId:%d, start to join pthread for rsma:%" PRId64 "", SMA_VID(pSma), taosGetPthreadId(pthread[i])); taosThreadJoin(pthread[i], NULL); } } From 54803a56a62497f20c2b1109b5fdb7bf261d8e5c Mon Sep 17 00:00:00 2001 From: slzhou Date: Wed, 19 Oct 2022 15:16:18 +0800 Subject: [PATCH 03/25] enhance: add log of initialize resident func --- source/libs/function/src/udfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index a319b5a25b..f17867d84b 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -961,6 +961,7 @@ int32_t udfdInitResidentFuncs() { char* token; while ((token = strtok_r(pSave, ",", &pSave)) != NULL) { char func[TSDB_FUNC_NAME_LEN+1] = {0}; + fnInfo("udfd add resident function %s", func); strncpy(func, token, TSDB_FUNC_NAME_LEN); taosArrayPush(global.residentFuncs, func); } From 90bdfd8f0156db679036e9dc6d295acf29354f08 Mon Sep 17 00:00:00 2001 From: slzhou Date: Wed, 19 Oct 2022 15:20:12 +0800 Subject: [PATCH 04/25] enhance: add log of initialize resident func --- source/libs/function/src/udfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index f17867d84b..0b67fa356a 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -961,8 +961,8 @@ int32_t udfdInitResidentFuncs() { char* token; while ((token = strtok_r(pSave, ",", &pSave)) != NULL) { char func[TSDB_FUNC_NAME_LEN+1] = {0}; - fnInfo("udfd add resident function %s", func); strncpy(func, token, TSDB_FUNC_NAME_LEN); + fnInfo("udfd add resident function %s", func); taosArrayPush(global.residentFuncs, func); } From 0930f1b7422dcaaa5a799ee02144baeb983d0709 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 19 Oct 2022 16:13:14 +0800 Subject: [PATCH 05/25] fix: disable the -Wformat-y2k compiler option to keep tsim testcases from affected --- cmake/cmake.define | 4 ++-- utils/tsim/src/simExe.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/cmake.define b/cmake/cmake.define index 4a32be84c3..78eab0a59a 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -117,8 +117,8 @@ ELSE () SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0") MESSAGE(STATUS "Will compile with Address Sanitizer!") ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") ENDIF () MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c index 4756ed4a09..582b6c054a 100644 --- a/utils/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -798,7 +798,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { } taosLocalTime(&tt, &tp); - strftime(timeStr, 64, "%Y-%m-%d %H:%M:%S", &tp); + strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", &tp); if (precision == TSDB_TIME_PRECISION_MILLI) { sprintf(value, "%s.%03d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000)); } else if (precision == TSDB_TIME_PRECISION_MICRO) { @@ -1044,4 +1044,4 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { return true; } } -#endif \ No newline at end of file +#endif From 9805c50b389bad4d58db218a04c4a81515b0de83 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 19 Oct 2022 19:44:07 +0800 Subject: [PATCH 06/25] rm deleted table idx --- source/dnode/vnode/src/meta/metaTable.c | 45 +++++++++---- tests/script/jenkins/basic.txt | 2 + tests/script/tsim/tag/drop_tag.sim | 84 +++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 tests/script/tsim/tag/drop_tag.sim diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 2b7982d381..8819711bd9 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -15,17 +15,18 @@ #include "meta.h" -static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); -static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); -static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME); -static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME); -static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME); -static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME); -static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME); -static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME); -static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME); -static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry); -static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type); +static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); +static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema); +static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME); +static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME); +static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry); +static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type); +static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey); static void metaGetEntryInfo(const SMetaEntry *pEntry, SMetaInfo *pInfo) { pInfo->uid = pEntry->uid; @@ -591,6 +592,28 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { const SSchema *pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0]; if (pTagColumn->type == TSDB_DATA_TYPE_JSON) { metaDelJsonVarFromIdx(pMeta, &e, pTagColumn); + } else { + STagIdxKey *pTagIdxKey = NULL; + int32_t nTagIdxKey; + + const void *pTagData = NULL; + int32_t nTagData = 0; + + STagVal tagVal = {.cid = pTagColumn->colId}; + tTagGet((const STag *)e.ctbEntry.pTags, &tagVal); + if (IS_VAR_DATA_TYPE(pTagColumn->type)) { + pTagData = tagVal.pData; + nTagData = (int32_t)tagVal.nData; + } else { + pTagData = &(tagVal.i64); + nTagData = tDataTypes[pTagColumn->type].bytes; + } + + if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid, + &pTagIdxKey, &nTagIdxKey) == 0) { + tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, &pMeta->txn); + } + metaDestroyTagIdxKey(pTagIdxKey); } tDecoderClear(&tdc); } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index d8f4a36261..0944892e79 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -454,5 +454,7 @@ ./test.sh -f tsim/tag/set.sim ./test.sh -f tsim/tag/smallint.sim ./test.sh -f tsim/tag/tinyint.sim +./test.sh -f tsim/tag/drop_tag.sim + #======================b1-end=============== diff --git a/tests/script/tsim/tag/drop_tag.sim b/tests/script/tsim/tag/drop_tag.sim new file mode 100644 index 0000000000..03892039f9 --- /dev/null +++ b/tests/script/tsim/tag/drop_tag.sim @@ -0,0 +1,84 @@ + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + + +$dbPrefix = ta_bib_db +$tbPrefix = ta_bib_tb +$mtPrefix = ta_bib_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db + +sql create database $db vgroups 1 +sql use $db + +print ======== test bigint +sql create table if not exists st( ts timestamp, order_id bigint) tags (account_id bigint) + +sql create table t1 using st tags(111) +sql create table t2 using st tags(222) + +sql insert into t1(ts, order_id) values(1648791213001, 1) +sql insert into t2(ts, order_id) values(1648791213002, 2) +sql select account_id,count(*) from st where account_id = 111 group by account_id + +sql drop table t1 + +sql create table t1 using st tags(111) + +sql insert into t1(ts, order_id) values(1648791213001, 1) +sql insert into t2(ts, order_id) values(1648791213002, 2) + +sql select account_id,count(*) from st where account_id = 111 group by account_id + +if $rows != 1 then + return -1 +endi + +print ======== test varchar + +sql drop stable st + +sql create table if not exists st( ts timestamp, order_id bigint) tags (account_id binary(16)) + +sql create table t1 using st tags("aac") +sql create table t2 using st tags("abc") + +sql insert into t1(ts, order_id) values(1648791213001, 1) +sql insert into t2(ts, order_id) values(1648791213002, 2) +sql select account_id,count(*) from st where account_id = "aac" group by account_id + +sql drop table t1 + +sql create table t1 using st tags("aac") + +sql insert into t1(ts, order_id) values(1648791213001, 1) +sql insert into t2(ts, order_id) values(1648791213002, 2) + +sql select account_id,count(*) from st where account_id = "aac" group by account_id + +if $rows != 1 then + return -1 +endi + +print ====== test empty table +sql drop table t1 + +sql select account_id,count(*) from st where account_id = "aac" group by account_id +if $rows != 0 then + return -1 +endi + + +sql drop database $db + From 720c16bf0ae7557f03eac81dc34d22ac78429837 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 19 Oct 2022 19:53:10 +0800 Subject: [PATCH 07/25] fix(shell): coverity problem for some --- source/util/src/tconfig.c | 2 ++ tools/shell/src/shellAuto.c | 20 ++++++-------------- tools/shell/src/shellCommand.c | 8 ++++++++ tools/shell/src/shellTire.c | 23 +++++++++++------------ 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index edb2f0380e..0bf9e7cc33 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -944,6 +944,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { if (taosReadFile(pFile, buf, fileSize) <= 0) { taosCloseFile(&pFile); uError("load json file error: %s", filepath); + taosMemoryFreeClear(buf); return -1; } taosCloseFile(&pFile); @@ -953,6 +954,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { if (jsonParseError != NULL) { uError("load json file parse error: %s", jsonParseError); } + taosMemoryFreeClear(buf); return -1; } taosMemoryFreeClear(buf); diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 46eaf6cff1..8d980ba653 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -562,23 +562,15 @@ void parseCommand(SWords* command, bool pattern) { // free SShellCmd void freeCommand(SWords* command) { - SWord* word = command->head; - if (word == NULL) { - return; - } - + SWord* item = command->head; // loop - while (word->next) { - SWord* tmp = word; - word = word->next; + while (item) { + SWord* tmp = item; + item = item->next; // if malloc need free if (tmp->free && tmp->word) taosMemoryFree(tmp->word); taosMemoryFree(tmp); } - - // if malloc need free - if (word->free && word->word) taosMemoryFree(word->word); - taosMemoryFree(word); } void GenerateVarType(int type, char** p, int count) { @@ -1204,11 +1196,11 @@ bool nextMatchCommand(TAOS* con, SShellCmd* cmd, SWords* firstMatch) { #endif // free + freeCommand(input); if (input->source) { taosMemoryFree(input->source); input->source = NULL; } - freeCommand(input); taosMemoryFree(input); return true; @@ -1377,7 +1369,7 @@ bool appendAfterSelect(TAOS* con, SShellCmd* cmd, char* sql, int32_t len) { bool ret = false; if (from == NULL) { bool fieldEnd = fieldsInputEnd(p); - // cheeck fields input end then insert from keyword + // check fields input end then insert from keyword if (fieldEnd && p[len - 1] == ' ') { shellInsertChar(cmd, "from", 4); taosMemoryFree(p); diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index c34b22b691..665c832b85 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -103,6 +103,8 @@ void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) { cmd->cursorOffset += size; cmd->screenOffset += taosWcharWidth(wc); cmd->endOffset += taosWcharWidth(wc); + // set string end + cmd->command[cmd->commandSize] = 0; #ifdef WINDOWS #else shellShowOnScreen(cmd); @@ -123,6 +125,8 @@ void shellBackspaceChar(SShellCmd *cmd) { cmd->cursorOffset -= size; cmd->screenOffset -= width; cmd->endOffset -= width; + // set string end + cmd->command[cmd->commandSize] = 0; shellShowOnScreen(cmd); } } @@ -136,6 +140,8 @@ void shellClearLineBefore(SShellCmd *cmd) { cmd->cursorOffset = 0; cmd->screenOffset = 0; cmd->endOffset = cmd->commandSize; + // set string end + cmd->command[cmd->commandSize] = 0; shellShowOnScreen(cmd); } @@ -160,6 +166,8 @@ void shellDeleteChar(SShellCmd *cmd) { cmd->commandSize - cmd->cursorOffset - size); cmd->commandSize -= size; cmd->endOffset -= width; + // set string end + cmd->command[cmd->commandSize] = 0; shellShowOnScreen(cmd); } } diff --git a/tools/shell/src/shellTire.c b/tools/shell/src/shellTire.c index 346757b76f..0628570904 100644 --- a/tools/shell/src/shellTire.c +++ b/tools/shell/src/shellTire.c @@ -309,27 +309,24 @@ void matchPrefixFromTree(STire* tire, char* prefix, SMatch* match) { } SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match) { - if (match == NULL) { - match = (SMatch*)taosMemoryMalloc(sizeof(SMatch)); - memset(match, 0, sizeof(SMatch)); + SMatch* rMatch = match; // define return match + if (rMatch == NULL) { + rMatch = (SMatch*)taosMemoryMalloc(sizeof(SMatch)); + memset(rMatch, 0, sizeof(SMatch)); } switch (tire->type) { case TIRE_TREE: - matchPrefixFromTree(tire, prefix, match); + matchPrefixFromTree(tire, prefix, rMatch); + break; case TIRE_LIST: - matchPrefixFromList(tire, prefix, match); + matchPrefixFromList(tire, prefix, rMatch); + break; default: break; } - // return if need - if (match->count == 0) { - freeMatch(match); - match = NULL; - } - - return match; + return rMatch; } // get all items from tires tree @@ -378,8 +375,10 @@ SMatch* enumAll(STire* tire) { switch (tire->type) { case TIRE_TREE: enumFromTree(tire, match); + break; case TIRE_LIST: enumFromList(tire, match); + break; default: break; } From 39e303b79b67c87688e9a7db80515fd9c456d5a8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 19 Oct 2022 20:07:15 +0800 Subject: [PATCH 08/25] enh: show the restore status of vnode when show vgroups --- include/common/tmsg.h | 6 ++++-- source/common/src/tmsg.c | 12 ++++++++---- source/dnode/mnode/impl/inc/mndDef.h | 6 ++++-- source/dnode/mnode/impl/src/mndDb.c | 4 ++-- source/dnode/mnode/impl/src/mndDnode.c | 15 +++++++++------ source/dnode/mnode/impl/src/mndMain.c | 11 ++++++----- source/dnode/mnode/impl/src/mndMnode.c | 14 +++++++------- source/dnode/mnode/impl/src/mndVgroup.c | 24 ++++++++++++++---------- source/dnode/vnode/src/vnd/vnodeQuery.c | 1 + source/libs/monitor/src/monMsg.c | 12 ++++++++---- 10 files changed, 63 insertions(+), 42 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 42bdc3af16..3409071932 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1074,7 +1074,8 @@ typedef struct { typedef struct { int32_t vgId; - int32_t syncState; + int8_t syncState; + int8_t syncRestore; int64_t cacheUsage; int64_t numOfTables; int64_t numOfTimeSeries; @@ -1089,7 +1090,8 @@ typedef struct { } SVnodeLoad; typedef struct { - int32_t syncState; + int8_t syncState; + int8_t syncRestore; } SMnodeLoad; typedef struct { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 1f0023278f..65541ca9cc 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -993,7 +993,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { for (int32_t i = 0; i < vlen; ++i) { SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i); if (tEncodeI32(&encoder, pload->vgId) < 0) return -1; - if (tEncodeI32(&encoder, pload->syncState) < 0) return -1; + if (tEncodeI8(&encoder, pload->syncState) < 0) return -1; + if (tEncodeI8(&encoder, pload->syncRestore) < 0) return -1; if (tEncodeI64(&encoder, pload->cacheUsage) < 0) return -1; if (tEncodeI64(&encoder, pload->numOfTables) < 0) return -1; if (tEncodeI64(&encoder, pload->numOfTimeSeries) < 0) return -1; @@ -1003,7 +1004,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { } // mnode loads - if (tEncodeI32(&encoder, pReq->mload.syncState) < 0) return -1; + if (tEncodeI8(&encoder, pReq->mload.syncState) < 0) return -1; + if (tEncodeI8(&encoder, pReq->mload.syncRestore) < 0) return -1; if (tEncodeI32(&encoder, pReq->qload.dnodeId) < 0) return -1; if (tEncodeI64(&encoder, pReq->qload.numOfProcessedQuery) < 0) return -1; @@ -1063,7 +1065,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { for (int32_t i = 0; i < vlen; ++i) { SVnodeLoad vload = {0}; if (tDecodeI32(&decoder, &vload.vgId) < 0) return -1; - if (tDecodeI32(&decoder, &vload.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &vload.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &vload.syncRestore) < 0) return -1; if (tDecodeI64(&decoder, &vload.cacheUsage) < 0) return -1; if (tDecodeI64(&decoder, &vload.numOfTables) < 0) return -1; if (tDecodeI64(&decoder, &vload.numOfTimeSeries) < 0) return -1; @@ -1076,7 +1079,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { } } - if (tDecodeI32(&decoder, &pReq->mload.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->mload.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->mload.syncRestore) < 0) return -1; if (tDecodeI32(&decoder, &pReq->qload.dnodeId) < 0) return -1; if (tDecodeI64(&decoder, &pReq->qload.numOfProcessedQuery) < 0) return -1; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 48eea7daea..2ee732e797 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -204,7 +204,8 @@ typedef struct { int32_t id; int64_t createdTime; int64_t updateTime; - ESyncState state; + ESyncState syncState; + bool syncRestore; int64_t stateStartTime; SDnodeObj* pDnode; } SMnodeObj; @@ -324,7 +325,8 @@ typedef struct { typedef struct { int32_t dnodeId; - ESyncState role; + ESyncState syncState; + bool syncRestore; } SVnodeGid; typedef struct { diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 3b31873857..654664269d 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1157,7 +1157,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { pEp->port = pDnode->port; } mndReleaseDnode(pMnode, pDnode); - if (pVgid->role == TAOS_SYNC_STATE_LEADER) { + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) { vgInfo.epSet.inUse = gid; } } @@ -1553,7 +1553,7 @@ bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) { if (pVgroup->dbUid == pDb->uid && pVgroup->replica > 1) { bool hasLeader = false; for (int32_t i = 0; i < pVgroup->replica; ++i) { - if (pVgroup->vnodeGid[i].role == TAOS_SYNC_STATE_LEADER) { + if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER) { hasLeader = true; } } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index fba1fd94d6..264b8d979b 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -361,10 +361,12 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { bool roleChanged = false; for (int32_t vg = 0; vg < pVgroup->replica; ++vg) { if (pVgroup->vnodeGid[vg].dnodeId == statusReq.dnodeId) { - if (pVgroup->vnodeGid[vg].role != pVload->syncState) { + if (pVgroup->vnodeGid[vg].syncState != pVload->syncState || + pVgroup->vnodeGid[vg].syncRestore != pVload->syncRestore) { + pVgroup->vnodeGid[vg].syncState = pVload->syncState; + pVgroup->vnodeGid[vg].syncRestore = pVload->syncRestore; roleChanged = true; } - pVgroup->vnodeGid[vg].role = pVload->syncState; break; } } @@ -378,10 +380,11 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { SMnodeObj *pObj = mndAcquireMnode(pMnode, pDnode->id); if (pObj != NULL) { - if (pObj->state != statusReq.mload.syncState) { - mInfo("dnode:%d, mnode syncstate from %s to %s", pObj->id, syncStr(pObj->state), - syncStr(statusReq.mload.syncState)); - pObj->state = statusReq.mload.syncState; + if (pObj->syncState != statusReq.mload.syncState || pObj->syncRestore != statusReq.mload.syncRestore) { + mInfo("dnode:%d, mnode syncState from %s to %s, restoreState from %d to %d", pObj->id, syncStr(pObj->syncState), + syncStr(statusReq.mload.syncState), pObj->syncRestore, statusReq.mload.syncRestore); + pObj->syncState = statusReq.mload.syncState; + pObj->syncRestore = statusReq.mload.syncRestore; pObj->stateStartTime = taosGetTimestampMs(); } mndReleaseMnode(pMnode, pObj); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 4eb2e2978b..a6177fc69f 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -765,7 +765,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr // pClusterInfo->master_uptime = (ms - pObj->stateStartTime) / (86400000.0f); tstrncpy(desc.role, syncStr(TAOS_SYNC_STATE_LEADER), sizeof(desc.role)); } else { - tstrncpy(desc.role, syncStr(pObj->state), sizeof(desc.role)); + tstrncpy(desc.role, syncStr(pObj->syncState), sizeof(desc.role)); } taosArrayPush(pClusterInfo->mnodes, &desc); sdbRelease(pSdb, pObj); @@ -795,12 +795,12 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; SMonVnodeDesc *pVnDesc = &desc.vnodes[i]; pVnDesc->dnode_id = pVgid->dnodeId; - tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->role), sizeof(pVnDesc->vnode_role)); - if (pVgid->role == TAOS_SYNC_STATE_LEADER) { + tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->syncState), sizeof(pVnDesc->vnode_role)); + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) { tstrncpy(desc.status, "ready", sizeof(desc.status)); pClusterInfo->vgroups_alive++; } - if (pVgid->role != TAOS_SYNC_STATE_ERROR) { + if (pVgid->syncState != TAOS_SYNC_STATE_ERROR) { pClusterInfo->vnodes_alive++; } pClusterInfo->vnodes_total++; @@ -845,7 +845,8 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad) { pLoad->syncState = syncGetMyRole(pMnode->syncMgmt.sync); - mTrace("mnode current syncstate is %s", syncStr(pLoad->syncState)); + pLoad->syncRestore = pMnode->restored; + mTrace("mnode current syncState is %s, syncRestore:%d", syncStr(pLoad->syncState), pLoad->syncRestore); return 0; } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index f6ea81c565..1ab0ba8a16 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -187,7 +187,7 @@ static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) { return -1; } - pObj->state = TAOS_SYNC_STATE_ERROR; + pObj->syncState = TAOS_SYNC_STATE_ERROR; mndReloadSyncConfig(pSdb->pMnode); return 0; } @@ -604,19 +604,19 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, b1, false); - const char *roles = "offline"; + char role[20] = "offline"; if (pObj->id == pMnode->selfDnodeId) { - roles = syncStr(TAOS_SYNC_STATE_LEADER); + snprintf(role, sizeof(role), "%s%s", syncStr(TAOS_SYNC_STATE_LEADER), pMnode->restored ? "" : "*"); } if (mndIsDnodeOnline(pObj->pDnode, curMs)) { - roles = syncStr(pObj->state); - if (pObj->state == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) { - roles = syncStr(TAOS_SYNC_STATE_ERROR); + tstrncpy(role, syncStr(pObj->syncState), sizeof(role)); + if (pObj->syncState == TAOS_SYNC_STATE_LEADER && pObj->id != pMnode->selfDnodeId) { + tstrncpy(role, syncStr(TAOS_SYNC_STATE_ERROR), sizeof(role)); mError("mnode:%d, is leader too", pObj->id); } } char b2[12 + VARSTR_HEADER_SIZE] = {0}; - STR_WITH_MAXSIZE_TO_VARSTR(b2, roles, pShow->pMeta->pSchemas[cols].bytes); + STR_WITH_MAXSIZE_TO_VARSTR(b2, role, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)b2, false); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 4ab80b0a40..47245fa2c4 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -142,7 +142,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; SDB_GET_INT32(pRaw, dataPos, &pVgid->dnodeId, _OVER) if (pVgroup->replica == 1) { - pVgid->role = TAOS_SYNC_STATE_LEADER; + pVgid->syncState = TAOS_SYNC_STATE_LEADER; } } SDB_GET_RESERVE(pRaw, dataPos, VGROUP_RESERVE_SIZE, _OVER) @@ -485,9 +485,9 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup pVgid->dnodeId = pDnode->id; if (pVgroup->replica == 1) { - pVgid->role = TAOS_SYNC_STATE_LEADER; + pVgid->syncState = TAOS_SYNC_STATE_LEADER; } else { - pVgid->role = TAOS_SYNC_STATE_FOLLOWER; + pVgid->syncState = TAOS_SYNC_STATE_FOLLOWER; } mInfo("db:%s, vgId:%d, vn:%d is alloced, memory:%" PRId64 ", dnode:%d avail:%" PRId64 " used:%" PRId64, @@ -587,7 +587,7 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) { SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId); if (pDnode == NULL) continue; - if (pVgid->role == TAOS_SYNC_STATE_LEADER) { + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) { epset.inUse = epset.numOfEps; } @@ -681,8 +681,12 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p mndReleaseDnode(pMnode, pDnode); } - char buf1[20] = {0}; - const char *role = online ? syncStr(pVgroup->vnodeGid[i].role) : "offline"; + char buf1[20] = {0}; + char role[20] = "offline"; + if (online) { + bool show = (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER && !pVgroup->vnodeGid[i].syncRestore); + snprintf(role, sizeof(role), "%s%s", syncStr(pVgroup->vnodeGid[i].syncState), show ? "*" : ""); + } STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); @@ -809,7 +813,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->replica, false); char buf[20] = {0}; - STR_TO_VARSTR(buf, syncStr(pVgid->role)); + STR_TO_VARSTR(buf, syncStr(pVgid->syncState)); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataAppend(pColInfo, numOfRows, (const char *)buf, false); @@ -887,7 +891,7 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) { } pVgid->dnodeId = pDnode->id; - pVgid->role = TAOS_SYNC_STATE_ERROR; + pVgid->syncState = TAOS_SYNC_STATE_ERROR; mInfo("db:%s, vgId:%d, vn:%d is added, memory:%" PRId64 ", dnode:%d avail:%" PRId64 " used:%" PRId64, pVgroup->dbName, pVgroup->vgId, pVgroup->replica, vgMem, pVgid->dnodeId, pDnode->memAvail, pDnode->memUsed); @@ -1179,7 +1183,7 @@ static int32_t mndAddIncVgroupReplicaToTrans(SMnode *pMnode, STrans *pTrans, SDb SVnodeGid *pGid = &pVgroup->vnodeGid[pVgroup->replica]; pVgroup->replica++; pGid->dnodeId = newDnodeId; - pGid->role = TAOS_SYNC_STATE_ERROR; + pGid->syncState = TAOS_SYNC_STATE_ERROR; if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, pVgroup, pGid, true) != 0) return -1; if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, pVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1; @@ -1233,7 +1237,7 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, mInfo("vgId:%d, vgroup info before redistribute, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { mInfo("vgId:%d, vnode:%d dnode:%d role:%s", newVg.vgId, i, newVg.vnodeGid[i].dnodeId, - syncStr(newVg.vnodeGid[i].role)); + syncStr(newVg.vnodeGid[i].syncState)); } if (pNew1 != NULL && pOld1 != NULL) { diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 64df3aa1eb..6a18ae2fa1 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -385,6 +385,7 @@ _exit: int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { pLoad->vgId = TD_VID(pVnode); pLoad->syncState = syncGetMyRole(pVnode->sync); + pLoad->syncRestore = pVnode->restored; pLoad->cacheUsage = tsdbCacheGetUsage(pVnode); pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta); diff --git a/source/libs/monitor/src/monMsg.c b/source/libs/monitor/src/monMsg.c index bbee8b1166..dd371f874c 100644 --- a/source/libs/monitor/src/monMsg.c +++ b/source/libs/monitor/src/monMsg.c @@ -509,7 +509,8 @@ int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo) for (int32_t i = 0; i < taosArrayGetSize(pInfo->pVloads); ++i) { SVnodeLoad *pLoad = taosArrayGet(pInfo->pVloads, i); if (tEncodeI32(&encoder, pLoad->vgId) < 0) return -1; - if (tEncodeI32(&encoder, pLoad->syncState) < 0) return -1; + if (tEncodeI8(&encoder, pLoad->syncState) < 0) return -1; + if (tEncodeI8(&encoder, pLoad->syncRestore) < 0) return -1; if (tEncodeI64(&encoder, pLoad->cacheUsage) < 0) return -1; if (tEncodeI64(&encoder, pLoad->numOfTables) < 0) return -1; if (tEncodeI64(&encoder, pLoad->numOfTimeSeries) < 0) return -1; @@ -544,7 +545,8 @@ int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInf for (int32_t i = 0; i < arraySize; ++i) { SVnodeLoad load = {0}; if (tDecodeI32(&decoder, &load.vgId) < 0) return -1; - if (tDecodeI32(&decoder, &load.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &load.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &load.syncRestore) < 0) return -1; if (tDecodeI64(&decoder, &load.cacheUsage) < 0) return -1; if (tDecodeI64(&decoder, &load.numOfTables) < 0) return -1; if (tDecodeI64(&decoder, &load.numOfTimeSeries) < 0) return -1; @@ -575,7 +577,8 @@ int32_t tSerializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInfo) if (tStartEncode(&encoder) < 0) return -1; if (tEncodeI8(&encoder, pInfo->isMnode) < 0) return -1; - if (tEncodeI32(&encoder, pInfo->load.syncState) < 0) return -1; + if (tEncodeI8(&encoder, pInfo->load.syncState) < 0) return -1; + if (tEncodeI8(&encoder, pInfo->load.syncRestore) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -589,7 +592,8 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf if (tStartDecode(&decoder) < 0) return -1; if (tDecodeI8(&decoder, &pInfo->isMnode) < 0) return -1; - if (tDecodeI32(&decoder, &pInfo->load.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &pInfo->load.syncState) < 0) return -1; + if (tDecodeI8(&decoder, &pInfo->load.syncRestore) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); From 48069ca974cc50832fa326289e0bc1235e6d0fd9 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 19 Oct 2022 20:14:30 +0800 Subject: [PATCH 09/25] fix(shell): restore zhiqiang modify chinese char show modifing --- tools/shell/src/shellCommand.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index 665c832b85..047aeb5b95 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -101,8 +101,11 @@ void shellInsertChar(SShellCmd *cmd, char *c, int32_t size) { /* update the values */ cmd->commandSize += size; cmd->cursorOffset += size; - cmd->screenOffset += taosWcharWidth(wc); - cmd->endOffset += taosWcharWidth(wc); + for (int i = 0; i < size; i++) { + taosMbToWchar(&wc, c + i, size); + cmd->screenOffset += taosWcharWidth(wc); + cmd->endOffset += taosWcharWidth(wc); + } // set string end cmd->command[cmd->commandSize] = 0; #ifdef WINDOWS From 228640af3ba92a63ba4f4399af86015058ce4faf Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 19 Oct 2022 20:51:25 +0800 Subject: [PATCH 10/25] fix: compile error --- source/dnode/vnode/src/tsdb/tsdbRead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index d97c6e6869..ea4e86fb78 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2555,7 +2555,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { } if (pScanInfo == NULL) { - tsdbError("failed to get table, uid:"PRIu64 ", %s", pBlockInfo->uid, pReader->idStr); + tsdbError("failed to get table, uid:%" PRIu64 ", %s", pBlockInfo->uid, pReader->idStr); code = TSDB_CODE_INVALID_PARA; return code; } From 4968b11a5b4f8e80b0847968f26358bd70ff3844 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 19 Oct 2022 21:01:24 +0800 Subject: [PATCH 11/25] test: adjust case --- .../6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py | 6 +++--- .../vnode/4dnode1mnode_basic_replica1_insertdatas.py | 4 ++-- .../vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py | 4 ++-- .../vnode/4dnode1mnode_basic_replica3_insertdatas.py | 4 ++-- .../vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py | 4 ++-- ...ic_replica3_insertdatas_querys_loop_restart_all_vnode.py | 4 ++-- ...sic_replica3_insertdatas_querys_loop_restart_follower.py | 4 ++-- ...basic_replica3_insertdatas_querys_loop_restart_leader.py | 4 ++-- ...e1mnode_basic_replica3_insertdatas_stop_follower_sync.py | 4 ++-- ...mnode_basic_replica3_insertdatas_stop_follower_unsync.py | 4 ++-- ..._replica3_insertdatas_stop_follower_unsync_force_stop.py | 4 ++-- ...de_basic_replica3_insertdatas_stop_leader_forece_stop.py | 4 ++-- ...4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py | 4 ++-- .../6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py | 4 ++-- .../vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py | 4 ++-- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py index 050c10d093..8d07dc6b38 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py @@ -61,7 +61,7 @@ class TDTestCase: # only for 1 mnode mnode_name = k - if v[2] =='leader': + if v[2] in ['leader', 'leader*']: is_leader=True if count==1 and is_leader: @@ -109,12 +109,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader', 'leader*', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py index 1e1f45d65e..470278cd8e 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py @@ -115,12 +115,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py index ca12dd6c9d..a5ce8171c7 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py @@ -116,12 +116,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py index 2d3e5e3178..60e3167304 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py @@ -115,12 +115,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py index c8fa8ee435..9d96ab1e9e 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py @@ -116,12 +116,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py index 447da77db3..8e7ac388fb 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py @@ -119,12 +119,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py index 6175f4e7cc..39bd0133cf 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py @@ -118,12 +118,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py index 27405774cc..6d4a9172f7 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py @@ -118,12 +118,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py index 1dc364c2fd..90358069aa 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py @@ -124,12 +124,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py index 3873040d20..55a2318817 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py @@ -124,12 +124,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py index 188b0030f2..f5e4ea0663 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py @@ -124,12 +124,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py index 5ba6c6ab8d..4ec558655f 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py @@ -207,12 +207,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py index 0a4162bd99..0a1c4e1183 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py @@ -116,12 +116,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py index 8a6412dfcc..bd7c05b03c 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py @@ -115,12 +115,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py index 5475d1cc37..00f20abe84 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py @@ -118,12 +118,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','follower']: + if role in ['leader','leader*','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0]=="leader": + if len(v) ==1 and v[0] in ['leader', 'leader*']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) From a8002d7541f4ef533d014c1e6543aeed6900b85e Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Wed, 19 Oct 2022 14:32:11 +0000 Subject: [PATCH 12/25] test:add testcase of taosd command --- tests/system-test/0-others/taosdShell.py | 468 +++++++++++++++++++++++ 1 file changed, 468 insertions(+) create mode 100644 tests/system-test/0-others/taosdShell.py diff --git a/tests/system-test/0-others/taosdShell.py b/tests/system-test/0-others/taosdShell.py new file mode 100644 index 0000000000..868aa198f1 --- /dev/null +++ b/tests/system-test/0-others/taosdShell.py @@ -0,0 +1,468 @@ + +import taos +import sys +import time +import socket +import os +import platform +if platform.system().lower() == 'windows': + import wexpect as taosExpect +else: + import pexpect as taosExpect + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +class TDTestCase: + #updatecfgDict = {'clientCfg': {'serverPort': 7080, 'firstEp': 'trd02:7080', 'secondEp':'trd02:7080'},\ + # 'serverPort': 7080, 'firstEp': 'trd02:7080'} + # hostname = socket.gethostname() + # if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""): + # try: + # config = eval(tdDnodes.dnodes[0].remoteIP) + # hostname = config["host"] + # except Exception: + # hostname = tdDnodes.dnodes[0].remoteIP + # serverPort = '7080' + # rpcDebugFlagVal = '143' + # clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + # clientCfgDict["serverPort"] = serverPort + # clientCfgDict["firstEp"] = hostname + ':' + serverPort + # clientCfgDict["secondEp"] = hostname + ':' + serverPort + # clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal + # clientCfgDict["fqdn"] = hostname + + # updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + # updatecfgDict["clientCfg"] = clientCfgDict + # updatecfgDict["serverPort"] = serverPort + # updatecfgDict["firstEp"] = hostname + ':' + serverPort + # updatecfgDict["secondEp"] = hostname + ':' + serverPort + # updatecfgDict["fqdn"] = hostname + + # print ("===================: ", updatecfgDict) + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files or "taosd.exe" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def get_process_pid(self,processname): + #origin artical link:https://blog.csdn.net/weixin_45623536/article/details/122099062 + process_info_list = [] + process = os.popen('ps -A | grep %s'% processname) + process_info = process.read() + for i in process_info.split(' '): + if i != "": + process_info_list.append(i) + print(process_info_list) + if len(process_info_list) != 0 : + pid = int(process_info_list[0]) + else : + pid = 0 + return pid + + def checkAndstopPro(self,processName,startAction): + i = 1 + count = 10 + for i in range(count): + taosdPid=self.get_process_pid(processName) + if taosdPid != 0 and taosdPid != "" : + tdLog.info("stop taosd %s ,kill pid :%s "%(startAction,taosdPid)) + os.system("kill -9 %d"%taosdPid) + break + else: + tdLog.info( "wait start taosd ,times: %d "%i) + sleep + i+= 1 + else : + tdLog.exit("taosd %s is not running "%startAction) + + def taosdCommandStop(self,startAction,taosdCmdRun): + processName="taosd" + taosdCmd = taosdCmdRun + startAction + tdLog.printNoPrefix("%s"%taosdCmd) + os.system(f"nohup {taosdCmd} & ") + self.checkAndstopPro(processName,startAction) + + def taosdCommandExe(self,startAction,taosdCmdRun): + taosdCmd = taosdCmdRun + startAction + tdLog.printNoPrefix("%s"%taosdCmd) + os.system(f"{taosdCmd}") + + def run(self): + tdSql.prepare() + # time.sleep(2) + tdSql.query("create user testpy pass 'testpy'") + + #hostname = socket.gethostname() + #tdLog.info ("hostname: %s" % hostname) + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + cfgPath = buildPath + "/../sim/psim/cfg" + taosdCfgPath = buildPath + "/../sim/dnode1/cfg" + + + taosdCmdRun= buildPath + '/build/bin/taosd' + tdLog.info("cfgPath: %s" % cfgPath) + # keyDict['h'] = self.hostname + # keyDict['c'] = cfgPath + # keyDict['P'] = self.serverPort + tdDnodes.stop(1) + + startAction = " --help" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandExe(startAction,taosdCmdRun) + + startAction = " -h" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandExe(startAction,taosdCmdRun) + + startAction=" -a jsonFile:./taosdCaseTmp.json" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + os.system("echo \'{\"queryPolicy\":\"3\"}\' > taosdCaseTmp.json") + self.taosdCommandStop(startAction,taosdCmdRun) + + startAction = " -a jsonFile:./taosdCaseTmp.json -C " + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandExe(startAction,taosdCmdRun) + + os.system("rm -rf taosdCaseTmp.json") + + startAction = " -c " + taosdCfgPath + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandStop(startAction,taosdCmdRun) + + startAction = " -s" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandExe(startAction,taosdCmdRun) + + startAction = " -e TAOS_QUERY_POLICY=2 " + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandStop(startAction,taosdCmdRun) + + + startAction=" -E taosdCaseTmp/.env" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + os.system(" mkdir -p taosdCaseTmp/.env ") + os.system("echo \'TAOS_QUERY_POLICY=3\' > taosdCaseTmp/.env ") + self.taosdCommandStop(startAction,taosdCmdRun) + os.system(" rm -rf taosdCaseTmp/.env ") + + startAction = " -V" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandExe(startAction,taosdCmdRun) + + startAction = " -k" + tdLog.printNoPrefix("================================ parameter: %s"%startAction) + self.taosdCommandExe(startAction,taosdCmdRun) + + # if retCode != "TAOS_OK": + # tdLog.exit("taos -h %s fail"%keyDict['h']) + # else: + # #dataDbName = ["information_schema", "performance_schema", "db", newDbName] + # tdSql.query("select * from information_schema.ins_databases") + # #tdSql.getResult("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -h %s fail"%keyDict['h']) + + # tdSql.query('drop database %s'%newDbName) + + # tdLog.printNoPrefix("================================ parameter: -P") + # #tdDnodes.stop(1) + # #sleep(3) + # #tdDnodes.start(1) + # #sleep(3) + # #keyDict['P'] = 6030 + # newDbName = "dbpp" + # sqlString = 'create database ' + newDbName + ';' + # retCode = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], sqlString) + # if retCode != "TAOS_OK": + # tdLog.exit("taos -P %s fail"%keyDict['P']) + # else: + # tdSql.query("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -P %s fail"%keyDict['P']) + + # tdSql.query('drop database %s'%newDbName) + + # tdLog.printNoPrefix("================================ parameter: -u") + # newDbName="dbu" + # sqlString = 'create database ' + newDbName + ';' + # retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, "p", keyDict['p']) + # if retCode != "TAOS_OK": + # tdLog.exit("taos -u %s -p%s fail"%(keyDict['u'], keyDict['p'])) + # else: + # tdSql.query("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -u %s -p%s fail"%(keyDict['u'], keyDict['p'])) + + # tdSql.query('drop database %s'%newDbName) + + # tdLog.printNoPrefix("================================ parameter: -A") + # newDbName="dbaa" + # retCode, retVal = taos_command(buildPath, "p", keyDict['p'], "taos>", keyDict['c'], '', "A", '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -A fail") + + # sqlString = 'create database ' + newDbName + ';' + # retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', retVal) + # if retCode != "TAOS_OK": + # tdLog.exit("taos -u %s -a %s"%(keyDict['u'], retVal)) + + # tdSql.query("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -u %s -a %s fail"%(keyDict['u'], retVal)) + + # tdSql.query('drop database %s'%newDbName) + + # tdLog.printNoPrefix("================================ parameter: -s") + # newDbName="dbss" + # keyDict['s'] = "\"create database " + newDbName + "\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -s fail") + + # print ("========== check new db ==========") + # tdSql.query("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -s %s fail"%(keyDict['s'])) + + # keyDict['s'] = "\"create table " + newDbName + ".stb (ts timestamp, c int) tags (t int)\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -s create table fail") + + # keyDict['s'] = "\"create table " + newDbName + ".ctb0 using " + newDbName + ".stb tags (0) " + newDbName + ".ctb1 using " + newDbName + ".stb tags (1)\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -s create table fail") + + # keyDict['s'] = "\"insert into " + newDbName + ".ctb0 values('2021-04-01 08:00:00.000', 10)('2021-04-01 08:00:01.000', 20) " + newDbName + ".ctb1 values('2021-04-01 08:00:00.000', 11)('2021-04-01 08:00:01.000', 21)\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -s insert data fail") + + # sqlString = "select * from " + newDbName + ".ctb0" + # tdSql.query(sqlString) + # tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') + # tdSql.checkData(0, 1, 10) + # tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') + # tdSql.checkData(1, 1, 20) + # sqlString = "select * from " + newDbName + ".ctb1" + # tdSql.query(sqlString) + # tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') + # tdSql.checkData(0, 1, 11) + # tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') + # tdSql.checkData(1, 1, 21) + + # keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "2021-04-01 08:00:01.000", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -r show fail") + + # tdLog.printNoPrefix("================================ parameter: -r") + # keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "1617235200000", keyDict['c'], '', 'r', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -r show fail") + + # keyDict['s'] = "\"select * from " + newDbName + ".ctb1\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "1617235201000", keyDict['c'], '', 'r', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -r show fail") + + # tdSql.query('drop database %s'%newDbName) + + # tdLog.printNoPrefix("================================ parameter: -f") + # pwd=os.getcwd() + # newDbName="dbf" + # sqlFile = pwd + "/0-others/sql.txt" + # sql1 = "echo create database " + newDbName + " > " + sqlFile + # sql2 = "echo use " + newDbName + " >> " + sqlFile + # if platform.system().lower() == 'windows': + # sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile + # sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile + # else: + # sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile + # sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile + # sql5 = "echo show databases >> " + sqlFile + # os.system(sql1) + # os.system(sql2) + # os.system(sql3) + # os.system(sql4) + # os.system(sql5) + + # keyDict['f'] = pwd + "/0-others/sql.txt" + # retCode = taos_command(buildPath, "f", keyDict['f'], 'performance_schema', keyDict['c'], '', '', '') + # print("============ ret code: ", retCode) + # if retCode != "TAOS_OK": + # tdLog.exit("taos -f fail") + + # print ("========== check new db ==========") + # tdSql.query("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0))) + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -f fail") + + # sqlString = "select * from " + newDbName + ".ntbf" + # tdSql.query(sqlString) + # tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') + # tdSql.checkData(0, 1, 'test taos -f1') + # tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') + # tdSql.checkData(1, 1, 'test taos -f2') + + # shellCmd = "rm -f " + sqlFile + # os.system(shellCmd) + # tdSql.query('drop database %s'%newDbName) + + # tdLog.printNoPrefix("================================ parameter: -C") + # #newDbName="dbcc" + # retCode, retVal = taos_command(buildPath, "C", keyDict['C'], "buildinfo", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -C fail") + + + # #print ("-C return content:\n ", retVal) + # totalCfgItem = {"firstEp":['', '', ''], } + # for line in retVal.splitlines(): + # strList = line.split() + # if (len(strList) > 2): + # totalCfgItem[strList[1]] = strList + + # #print ("dict content:\n ", totalCfgItem) + # firstEp = keyDict["h"] + ':' + keyDict['P'] + # if (totalCfgItem["firstEp"][2] != firstEp) and (totalCfgItem["firstEp"][0] != 'cfg_file'): + # tdLog.exit("taos -C return firstEp error!") + + # if (totalCfgItem["rpcDebugFlag"][2] != self.rpcDebugFlagVal) and (totalCfgItem["rpcDebugFlag"][0] != 'cfg_file'): + # tdLog.exit("taos -C return rpcDebugFlag error!") + + # count = os.cpu_count() + # if (totalCfgItem["numOfCores"][2] != count) and (totalCfgItem["numOfCores"][0] != 'default'): + # tdLog.exit("taos -C return numOfCores error!") + + # version = totalCfgItem["version"][2] + + # tdLog.printNoPrefix("================================ parameter: -V") + # #newDbName="dbvv" + # retCode, retVal = taos_command(buildPath, "V", keyDict['V'], "", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -V fail") + + # version = 'version: ' + version + # retVal = retVal.replace("\n", "") + # retVal = retVal.replace("\r", "") + # if retVal != version: + # print ("return version: [%s]"%retVal) + # print ("dict version: [%s]"%version) + # tdLog.exit("taos -V version not match") + + # tdLog.printNoPrefix("================================ parameter: -d") + # newDbName="dbd" + # sqlString = 'create database ' + newDbName + ';' + # retCode = taos_command(buildPath, "d", keyDict['d'], "taos>", keyDict['c'], sqlString, '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -d %s fail"%(keyDict['d'])) + # else: + # tdSql.query("select * from information_schema.ins_databases") + # for i in range(tdSql.queryRows): + # if tdSql.getData(i, 0) == newDbName: + # break + # else: + # tdLog.exit("create db fail after taos -d %s fail"%(keyDict['d'])) + + # tdSql.query('drop database %s'%newDbName) + + # retCode = taos_command(buildPath, "d", 'dbno', "taos>", keyDict['c'], sqlString, '', '') + # if retCode != "TAOS_FAIL": + # tdLog.exit("taos -d dbno fail") + + # tdLog.printNoPrefix("================================ parameter: -w") + # newDbName="dbw" + # keyDict['s'] = "\"create database " + newDbName + "\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w fail") + + # keyDict['s'] = "\"create table " + newDbName + ".ntb (ts timestamp, c binary(128))\"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w create table fail") + + # keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.001', 'abcd0123456789')('2021-04-01 08:00:00.002', 'abcd012345678901234567890123456789') \"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w insert data fail") + + # keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.003', 'aaaaaaaaaaaaaaaaaaaa')('2021-04-01 08:00:01.004', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') \"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w insert data fail") + + # keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.005', 'cccccccccccccccccccc')('2021-04-01 08:00:01.006', 'dddddddddddddddddddddddddddddddddddddddd') \"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w insert data fail") + + # keyDict['s'] = "\"select * from " + newDbName + ".ntb \"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "aaaaaaaaaaaaaaaaaaaa", keyDict['c'], '', '', '') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w insert data fail") + + # keyDict['s'] = "\"select * from " + newDbName + ".ntb \"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "dddddddddddddddddddddddddddddddddddddddd", keyDict['c'], '', '', '') + # if retCode != "TAOS_FAIL": + # tdLog.exit("taos -w insert data fail") + + # keyDict['s'] = "\"select * from " + newDbName + ".ntb \"" + # retCode = taos_command(buildPath, "s", keyDict['s'], "dddddddddddddddddddddddddddddddddddddddd", keyDict['c'], '', 'w', '60') + # if retCode != "TAOS_OK": + # tdLog.exit("taos -w insert data fail") + + # tdSql.query('drop database %s'%newDbName) + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From ae625d3199340871149f1ab461451b5bf313f27b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 19 Oct 2022 22:33:15 +0800 Subject: [PATCH 13/25] refactor: remove redundant codes and do some internal refactor. --- include/common/ttypes.h | 4 --- source/common/src/ttime.c | 54 ++++++++++++++---------------- source/common/src/ttypes.c | 13 ------- source/libs/scalar/src/sclfunc.c | 8 ++--- source/libs/scalar/src/sclvector.c | 51 ---------------------------- 5 files changed, 27 insertions(+), 103 deletions(-) diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 733270dbed..eace9d7dd6 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -340,12 +340,8 @@ typedef struct tDataTypeDescriptor { } tDataTypeDescriptor; extern tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX]; - bool isValidDataType(int32_t type); -void setVardataNull(void *val, int32_t type); -//void setNull(void *val, int32_t type, int32_t bytes); -//void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems); void assignVal(char *val, const char *src, int32_t len, int32_t type); void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type); void *getDataMin(int32_t type); diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index bb82863e73..e0cc5bd311 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -244,8 +244,7 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) { * 2013-04-12T15:52:01.123+0800 */ int32_t parseTimeWithTz(const char* timestr, int64_t* time, int32_t timePrec, char delim) { - int64_t factor = - (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); + int64_t factor = TSDB_TICK_PER_SECOND(timePrec); int64_t tzOffset = 0; struct tm tm = {0}; @@ -339,8 +338,8 @@ static FORCE_INLINE bool validateTm(struct tm* pTm) { return true; } -int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePrec, char delim) { - *time = 0; +int32_t parseLocaltime(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) { + *utime = 0; struct tm tm = {0}; char* str; @@ -378,15 +377,12 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePr } } - int64_t factor = - (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); - *time = factor * seconds + fraction; - + *utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction; return 0; } -int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t timePrec, char delim) { - *time = 0; +int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) { + *utime = 0; struct tm tm = {0}; tm.tm_isdst = -1; @@ -411,7 +407,6 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim int64_t seconds = taosMktime(&tm); int64_t fraction = 0; - if (*str == '.') { /* parse the second fraction part */ if ((fraction = parseFraction(str + 1, &str, timePrec)) < 0) { @@ -419,9 +414,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim } } - int64_t factor = - (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); - *time = factor * seconds + fraction; + *utime = TSDB_TICK_PER_SECOND(timePrec) * seconds + fraction; return 0; } @@ -437,58 +430,61 @@ char getPrecisionUnit(int32_t precision) { } } -int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { - assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || +int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPrecision) { + ASSERT(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || fromPrecision == TSDB_TIME_PRECISION_NANO); - assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO || + ASSERT(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO || toPrecision == TSDB_TIME_PRECISION_NANO); - double tempResult = (double)time; + + double tempResult = (double)utime; + switch (fromPrecision) { case TSDB_TIME_PRECISION_MILLI: { switch (toPrecision) { case TSDB_TIME_PRECISION_MILLI: - return time; + return utime; case TSDB_TIME_PRECISION_MICRO: tempResult *= 1000; - time *= 1000; + utime *= 1000; goto end_; case TSDB_TIME_PRECISION_NANO: tempResult *= 1000000; - time *= 1000000; + utime *= 1000000; goto end_; } } // end from milli case TSDB_TIME_PRECISION_MICRO: { switch (toPrecision) { case TSDB_TIME_PRECISION_MILLI: - return time / 1000; + return utime / 1000; case TSDB_TIME_PRECISION_MICRO: - return time; + return utime; case TSDB_TIME_PRECISION_NANO: tempResult *= 1000; - time *= 1000; + utime *= 1000; goto end_; } } // end from micro case TSDB_TIME_PRECISION_NANO: { switch (toPrecision) { case TSDB_TIME_PRECISION_MILLI: - return time / 1000000; + return utime / 1000000; case TSDB_TIME_PRECISION_MICRO: - return time / 1000; + return utime / 1000; case TSDB_TIME_PRECISION_NANO: - return time; + return utime; } } // end from nano default: { assert(0); - return time; // only to pass windows compilation + return utime; // only to pass windows compilation } } // end switch fromPrecision + end_: if (tempResult >= (double)INT64_MAX) return INT64_MAX; if (tempResult <= (double)INT64_MIN) return INT64_MIN; // INT64_MIN means NULL - return time; + return utime; } // !!!!notice:there are precision problems, double lose precison if time is too large, for example: diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index 3dbd8a05a2..a4e7a12ce4 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -16,7 +16,6 @@ #define _DEFAULT_SOURCE #include "ttypes.h" #include "tcompression.h" -#include "trow.h" const int32_t TYPE_BYTES[16] = { -1, // TSDB_DATA_TYPE_NULL @@ -86,18 +85,6 @@ FORCE_INLINE void *getDataMax(int32_t type) { bool isValidDataType(int32_t type) { return type >= TSDB_DATA_TYPE_NULL && type < TSDB_DATA_TYPE_MAX; } -void setVardataNull(void *val, int32_t type) { - if (type == TSDB_DATA_TYPE_BINARY) { - varDataSetLen(val, sizeof(int8_t)); - *(uint8_t *)varDataVal(val) = TSDB_DATA_BINARY_NULL; - } else if (type == TSDB_DATA_TYPE_NCHAR) { - varDataSetLen(val, sizeof(int32_t)); - *(uint32_t *)varDataVal(val) = TSDB_DATA_NCHAR_NULL; - } else { - assert(0); - } -} - #define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b))) void assignVal(char *val, const char *src, int32_t len, int32_t type) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 339065633b..1d8744d726 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1178,9 +1178,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData); GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); - int64_t factor = - (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); - + int64_t factor = TSDB_TICK_PER_SECOND(timePrec); int64_t unit = timeUnit * 1000 / factor; for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { @@ -1372,9 +1370,7 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); } - int64_t factor = - (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); - + int64_t factor = TSDB_TICK_PER_SECOND(timePrec); int32_t numOfRows = 0; for (int32_t i = 0; i < inputNum; ++i) { if (pInput[i].numOfRows > numOfRows) { diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index f467721248..80c55e31cc 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -1426,57 +1426,6 @@ void vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, pOut->numOfQualified = pRight->numOfQualified * pOut->numOfRows; } -void vectorConcat(SScalarParam *pLeft, SScalarParam *pRight, void *out, int32_t _ord) { -#if 0 - int32_t len = pLeft->bytes + pRight->bytes; - - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; - - char *output = (char *)out; - if (pLeft->numOfRows == pRight->numOfRows) { - for (; i < pRight->numOfRows && i >= 0; i += step, output += len) { - char* left = POINTER_SHIFT(pLeft->data, pLeft->bytes * i); - char* right = POINTER_SHIFT(pRight->data, pRight->bytes * i); - - if (isNull(left, pLeftCol->info.type) || isNull(right, pRight->info.type)) { - setVardataNull(output, TSDB_DATA_TYPE_BINARY); - continue; - } - - // todo define a macro - memcpy(varDataVal(output), varDataVal(left), varDataLen(left)); - memcpy(varDataVal(output) + varDataLen(left), varDataVal(right), varDataLen(right)); - varDataSetLen(output, varDataLen(left) + varDataLen(right)); - } - } else if (pLeft->numOfRows == 1) { - for (; i >= 0 && i < pRight->numOfRows; i += step, output += len) { - char *right = POINTER_SHIFT(pRight->data, pRight->bytes * i); - if (isNull(pLeft->data, pLeftCol->info.type) || isNull(right, pRight->info.type)) { - setVardataNull(output, TSDB_DATA_TYPE_BINARY); - continue; - } - - memcpy(varDataVal(output), varDataVal(pLeft->data), varDataLen(pLeft->data)); - memcpy(varDataVal(output) + varDataLen(pLeft->data), varDataVal(right), varDataLen(right)); - varDataSetLen(output, varDataLen(pLeft->data) + varDataLen(right)); - } - } else if (pRight->numOfRows == 1) { - for (; i >= 0 && i < pLeft->numOfRows; i += step, output += len) { - char* left = POINTER_SHIFT(pLeft->data, pLeft->bytes * i); - if (isNull(left, pLeftCol->info.type) || isNull(pRight->data, pRight->info.type)) { - SET_DOUBLE_NULL(output); - continue; - } - - memcpy(varDataVal(output), varDataVal(left), varDataLen(pRight->data)); - memcpy(varDataVal(output) + varDataLen(left), varDataVal(pRight->data), varDataLen(pRight->data)); - varDataSetLen(output, varDataLen(left) + varDataLen(pRight->data)); - } - } -#endif -} - static void vectorBitAndHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); From 68bae21b816ba90ee4c02b36a9843136fd831fab Mon Sep 17 00:00:00 2001 From: chenhaoran Date: Wed, 19 Oct 2022 14:34:57 +0000 Subject: [PATCH 14/25] test:add testcase of taosd command --- tests/system-test/0-others/taosdShell.py | 285 +---------------------- 1 file changed, 1 insertion(+), 284 deletions(-) diff --git a/tests/system-test/0-others/taosdShell.py b/tests/system-test/0-others/taosdShell.py index 868aa198f1..6d62420efe 100644 --- a/tests/system-test/0-others/taosdShell.py +++ b/tests/system-test/0-others/taosdShell.py @@ -176,290 +176,7 @@ class TDTestCase: startAction = " -k" tdLog.printNoPrefix("================================ parameter: %s"%startAction) self.taosdCommandExe(startAction,taosdCmdRun) - - # if retCode != "TAOS_OK": - # tdLog.exit("taos -h %s fail"%keyDict['h']) - # else: - # #dataDbName = ["information_schema", "performance_schema", "db", newDbName] - # tdSql.query("select * from information_schema.ins_databases") - # #tdSql.getResult("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -h %s fail"%keyDict['h']) - - # tdSql.query('drop database %s'%newDbName) - - # tdLog.printNoPrefix("================================ parameter: -P") - # #tdDnodes.stop(1) - # #sleep(3) - # #tdDnodes.start(1) - # #sleep(3) - # #keyDict['P'] = 6030 - # newDbName = "dbpp" - # sqlString = 'create database ' + newDbName + ';' - # retCode = taos_command(buildPath, "P", keyDict['P'], "taos>", keyDict['c'], sqlString) - # if retCode != "TAOS_OK": - # tdLog.exit("taos -P %s fail"%keyDict['P']) - # else: - # tdSql.query("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -P %s fail"%keyDict['P']) - - # tdSql.query('drop database %s'%newDbName) - - # tdLog.printNoPrefix("================================ parameter: -u") - # newDbName="dbu" - # sqlString = 'create database ' + newDbName + ';' - # retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, "p", keyDict['p']) - # if retCode != "TAOS_OK": - # tdLog.exit("taos -u %s -p%s fail"%(keyDict['u'], keyDict['p'])) - # else: - # tdSql.query("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -u %s -p%s fail"%(keyDict['u'], keyDict['p'])) - - # tdSql.query('drop database %s'%newDbName) - - # tdLog.printNoPrefix("================================ parameter: -A") - # newDbName="dbaa" - # retCode, retVal = taos_command(buildPath, "p", keyDict['p'], "taos>", keyDict['c'], '', "A", '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -A fail") - - # sqlString = 'create database ' + newDbName + ';' - # retCode = taos_command(buildPath, "u", keyDict['u'], "taos>", keyDict['c'], sqlString, 'a', retVal) - # if retCode != "TAOS_OK": - # tdLog.exit("taos -u %s -a %s"%(keyDict['u'], retVal)) - - # tdSql.query("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -u %s -a %s fail"%(keyDict['u'], retVal)) - - # tdSql.query('drop database %s'%newDbName) - - # tdLog.printNoPrefix("================================ parameter: -s") - # newDbName="dbss" - # keyDict['s'] = "\"create database " + newDbName + "\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -s fail") - - # print ("========== check new db ==========") - # tdSql.query("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -s %s fail"%(keyDict['s'])) - - # keyDict['s'] = "\"create table " + newDbName + ".stb (ts timestamp, c int) tags (t int)\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -s create table fail") - - # keyDict['s'] = "\"create table " + newDbName + ".ctb0 using " + newDbName + ".stb tags (0) " + newDbName + ".ctb1 using " + newDbName + ".stb tags (1)\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -s create table fail") - - # keyDict['s'] = "\"insert into " + newDbName + ".ctb0 values('2021-04-01 08:00:00.000', 10)('2021-04-01 08:00:01.000', 20) " + newDbName + ".ctb1 values('2021-04-01 08:00:00.000', 11)('2021-04-01 08:00:01.000', 21)\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -s insert data fail") - - # sqlString = "select * from " + newDbName + ".ctb0" - # tdSql.query(sqlString) - # tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') - # tdSql.checkData(0, 1, 10) - # tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') - # tdSql.checkData(1, 1, 20) - # sqlString = "select * from " + newDbName + ".ctb1" - # tdSql.query(sqlString) - # tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') - # tdSql.checkData(0, 1, 11) - # tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') - # tdSql.checkData(1, 1, 21) - - # keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "2021-04-01 08:00:01.000", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -r show fail") - - # tdLog.printNoPrefix("================================ parameter: -r") - # keyDict['s'] = "\"select * from " + newDbName + ".ctb0\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "1617235200000", keyDict['c'], '', 'r', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -r show fail") - - # keyDict['s'] = "\"select * from " + newDbName + ".ctb1\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "1617235201000", keyDict['c'], '', 'r', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -r show fail") - - # tdSql.query('drop database %s'%newDbName) - - # tdLog.printNoPrefix("================================ parameter: -f") - # pwd=os.getcwd() - # newDbName="dbf" - # sqlFile = pwd + "/0-others/sql.txt" - # sql1 = "echo create database " + newDbName + " > " + sqlFile - # sql2 = "echo use " + newDbName + " >> " + sqlFile - # if platform.system().lower() == 'windows': - # sql3 = "echo create table ntbf (ts timestamp, c binary(40)) >> " + sqlFile - # sql4 = "echo insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\") >> " + sqlFile - # else: - # sql3 = "echo 'create table ntbf (ts timestamp, c binary(40))' >> " + sqlFile - # sql4 = "echo 'insert into ntbf values (\"2021-04-01 08:00:00.000\", \"test taos -f1\")(\"2021-04-01 08:00:01.000\", \"test taos -f2\")' >> " + sqlFile - # sql5 = "echo show databases >> " + sqlFile - # os.system(sql1) - # os.system(sql2) - # os.system(sql3) - # os.system(sql4) - # os.system(sql5) - - # keyDict['f'] = pwd + "/0-others/sql.txt" - # retCode = taos_command(buildPath, "f", keyDict['f'], 'performance_schema', keyDict['c'], '', '', '') - # print("============ ret code: ", retCode) - # if retCode != "TAOS_OK": - # tdLog.exit("taos -f fail") - - # print ("========== check new db ==========") - # tdSql.query("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # #print ("dbseq: %d, dbname: %s"%(i, tdSql.getData(i, 0))) - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -f fail") - - # sqlString = "select * from " + newDbName + ".ntbf" - # tdSql.query(sqlString) - # tdSql.checkData(0, 0, '2021-04-01 08:00:00.000') - # tdSql.checkData(0, 1, 'test taos -f1') - # tdSql.checkData(1, 0, '2021-04-01 08:00:01.000') - # tdSql.checkData(1, 1, 'test taos -f2') - - # shellCmd = "rm -f " + sqlFile - # os.system(shellCmd) - # tdSql.query('drop database %s'%newDbName) - - # tdLog.printNoPrefix("================================ parameter: -C") - # #newDbName="dbcc" - # retCode, retVal = taos_command(buildPath, "C", keyDict['C'], "buildinfo", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -C fail") - - - # #print ("-C return content:\n ", retVal) - # totalCfgItem = {"firstEp":['', '', ''], } - # for line in retVal.splitlines(): - # strList = line.split() - # if (len(strList) > 2): - # totalCfgItem[strList[1]] = strList - - # #print ("dict content:\n ", totalCfgItem) - # firstEp = keyDict["h"] + ':' + keyDict['P'] - # if (totalCfgItem["firstEp"][2] != firstEp) and (totalCfgItem["firstEp"][0] != 'cfg_file'): - # tdLog.exit("taos -C return firstEp error!") - - # if (totalCfgItem["rpcDebugFlag"][2] != self.rpcDebugFlagVal) and (totalCfgItem["rpcDebugFlag"][0] != 'cfg_file'): - # tdLog.exit("taos -C return rpcDebugFlag error!") - - # count = os.cpu_count() - # if (totalCfgItem["numOfCores"][2] != count) and (totalCfgItem["numOfCores"][0] != 'default'): - # tdLog.exit("taos -C return numOfCores error!") - - # version = totalCfgItem["version"][2] - - # tdLog.printNoPrefix("================================ parameter: -V") - # #newDbName="dbvv" - # retCode, retVal = taos_command(buildPath, "V", keyDict['V'], "", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -V fail") - - # version = 'version: ' + version - # retVal = retVal.replace("\n", "") - # retVal = retVal.replace("\r", "") - # if retVal != version: - # print ("return version: [%s]"%retVal) - # print ("dict version: [%s]"%version) - # tdLog.exit("taos -V version not match") - - # tdLog.printNoPrefix("================================ parameter: -d") - # newDbName="dbd" - # sqlString = 'create database ' + newDbName + ';' - # retCode = taos_command(buildPath, "d", keyDict['d'], "taos>", keyDict['c'], sqlString, '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -d %s fail"%(keyDict['d'])) - # else: - # tdSql.query("select * from information_schema.ins_databases") - # for i in range(tdSql.queryRows): - # if tdSql.getData(i, 0) == newDbName: - # break - # else: - # tdLog.exit("create db fail after taos -d %s fail"%(keyDict['d'])) - - # tdSql.query('drop database %s'%newDbName) - - # retCode = taos_command(buildPath, "d", 'dbno', "taos>", keyDict['c'], sqlString, '', '') - # if retCode != "TAOS_FAIL": - # tdLog.exit("taos -d dbno fail") - - # tdLog.printNoPrefix("================================ parameter: -w") - # newDbName="dbw" - # keyDict['s'] = "\"create database " + newDbName + "\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w fail") - - # keyDict['s'] = "\"create table " + newDbName + ".ntb (ts timestamp, c binary(128))\"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w create table fail") - - # keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.001', 'abcd0123456789')('2021-04-01 08:00:00.002', 'abcd012345678901234567890123456789') \"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w insert data fail") - - # keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.003', 'aaaaaaaaaaaaaaaaaaaa')('2021-04-01 08:00:01.004', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') \"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w insert data fail") - - # keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.005', 'cccccccccccccccccccc')('2021-04-01 08:00:01.006', 'dddddddddddddddddddddddddddddddddddddddd') \"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w insert data fail") - - # keyDict['s'] = "\"select * from " + newDbName + ".ntb \"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "aaaaaaaaaaaaaaaaaaaa", keyDict['c'], '', '', '') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w insert data fail") - - # keyDict['s'] = "\"select * from " + newDbName + ".ntb \"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "dddddddddddddddddddddddddddddddddddddddd", keyDict['c'], '', '', '') - # if retCode != "TAOS_FAIL": - # tdLog.exit("taos -w insert data fail") - - # keyDict['s'] = "\"select * from " + newDbName + ".ntb \"" - # retCode = taos_command(buildPath, "s", keyDict['s'], "dddddddddddddddddddddddddddddddddddddddd", keyDict['c'], '', 'w', '60') - # if retCode != "TAOS_OK": - # tdLog.exit("taos -w insert data fail") - - # tdSql.query('drop database %s'%newDbName) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") From 00e56d678bb9bc3f1efac690b4272ef63c469839 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 19 Oct 2022 22:38:12 +0800 Subject: [PATCH 15/25] refactor: remove redundant codes. --- include/util/tdef.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/include/util/tdef.h b/include/util/tdef.h index d9bb558b74..e4ebfc380d 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -237,7 +237,6 @@ typedef enum ELogicConditionType { #define TSDB_MAX_BYTES_PER_ROW 49151 #define TSDB_MAX_TAGS_LEN 16384 #define TSDB_MAX_TAGS 128 -#define TSDB_MAX_TAG_CONDITIONS 1024 #define TSDB_MAX_COL_TAG_NUM (TSDB_MAX_COLUMNS + TSDB_MAX_TAGS) #define TSDB_MAX_JSON_TAG_LEN 16384 @@ -274,8 +273,6 @@ typedef enum ELogicConditionType { #define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE #define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value -#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth -#define TSDB_CQ_SQL_SIZE 1024 #define TSDB_MIN_VNODES 16 #define TSDB_MAX_VNODES 512 @@ -285,10 +282,7 @@ typedef enum ELogicConditionType { #define TSDB_MAX_REPLICA 5 -#define TSDB_TBNAME_COLUMN_INDEX (-1) -#define TSDB_UD_COLUMN_INDEX (-1000) -#define TSDB_RES_COL_ID (-5000) - +#define TSDB_TBNAME_COLUMN_INDEX (-1) #define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta #define TSDB_MIN_VNODES_PER_DB 1 @@ -398,9 +392,6 @@ typedef enum ELogicConditionType { #define TSDB_MAX_EXPLAIN_RATIO 1 #define TSDB_DEFAULT_EXPLAIN_RATIO 0.001 -#define TSDB_MAX_JOIN_TABLE_NUM 10 -#define TSDB_MAX_UNION_CLAUSE 5 - #define TSDB_DEFAULT_EXPLAIN_VERBOSE false #define TSDB_EXPLAIN_RESULT_ROW_SIZE (16 * 1024) @@ -419,7 +410,6 @@ typedef enum ELogicConditionType { #endif #define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type -#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode #define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default From 368f5134c51edec94c52ed34f071bd0c6598913f Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Thu, 20 Oct 2022 09:04:51 +0800 Subject: [PATCH 16/25] feat(stream):optimize state window disc buff --- include/libs/stream/streamState.h | 3 +- source/libs/executor/src/timewindowoperator.c | 4 +- source/libs/stream/src/streamState.c | 57 +++++++++++-------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index ec68e8ed71..3d59a69dea 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -68,9 +68,10 @@ int32_t streamStateSessionClear(SStreamState* pState); int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, const void** pVal, int32_t* pVLen); int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen, state_key_cmpr_fn fn, void** pVal, int32_t* pVLen); +int32_t streamStateSessionGetKey(SStreamState* pState, const SSessionKey* key, SSessionKey* curKey); SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key); -SStreamStateCur* streamStateSessionSeekKeyPrev(SStreamState* pState, const SSessionKey* key); +SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key); SStreamStateCur* streamStateSessionGetCur(SStreamState* pState, const SSessionKey* key); int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 505654d967..15cad81d23 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -3594,9 +3594,7 @@ void getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endT pKey->win.skey = startTs; pKey->win.ekey = endTs; pKey->groupId = groupId; - SStreamStateCur* pCur = streamStateSessionGetCur(pAggSup->pState, pKey); - int32_t code = streamStateSessionGetKVByCur(pCur, pKey, NULL, 0); - streamStateFreeCur(pCur); + int32_t code = streamStateSessionGetKey(pAggSup->pState, pKey, pKey); if (code != TSDB_CODE_SUCCESS) { SET_SESSION_WIN_KEY_INVALID(pKey); } diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index c3c58e125a..4b3affa9de 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -526,7 +526,7 @@ int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key) { return tdbTbDelete(pState->pSessionStateDb, &sKey, sizeof(SStateSessionKey), &pState->txn); } -SStreamStateCur* streamStateSessionSeekKeyPrev(SStreamState* pState, const SSessionKey* key) { +SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key) { SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); if (pCur == NULL) { return NULL; @@ -544,7 +544,7 @@ SStreamStateCur* streamStateSessionSeekKeyPrev(SStreamState* pState, const SSess streamStateFreeCur(pCur); return NULL; } - if (c > 0) return pCur; + if (c >= 0) return pCur; if (tdbTbcMoveToPrev(pCur->pCur) < 0) { streamStateFreeCur(pCur); @@ -572,7 +572,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess streamStateFreeCur(pCur); return NULL; } - if (c > 0) return pCur; + if (c < 0) return pCur; if (tdbTbcMoveToNext(pCur->pCur) < 0) { streamStateFreeCur(pCur); @@ -630,7 +630,7 @@ SStreamStateCur* streamStateSessionGetCur(SStreamState* pState, const SSessionKe streamStateCurPrev(pState, pCur); SSessionKey tmpKey = *key; int32_t code = streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0); - if (code == TSDB_CODE_SUCCESS && sessionKeyCmpr(key, &tmpKey) == 0) { + if (code == 0 && sessionKeyCmpr(key, &tmpKey) == 0) { resKey = tmpKey; } else { break; @@ -640,9 +640,28 @@ SStreamStateCur* streamStateSessionGetCur(SStreamState* pState, const SSessionKe return streamStateSessionGetRanomCur(pState, &resKey); } +int32_t streamStateSessionGetKey(SStreamState* pState, const SSessionKey* key, SSessionKey* curKey) { + SStreamStateCur* pCur = streamStateSessionGetRanomCur(pState, key); + SSessionKey resKey = *key; + int32_t res = -1; + while (1) { + SSessionKey tmpKey = *key; + int32_t code = streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0); + if (code == 0 && sessionKeyCmpr(key, &tmpKey) == 0) { + res = 0; + resKey = tmpKey; + } else { + break; + } + streamStateCurPrev(pState, pCur); + } + *curKey = resKey; + return res; +} + int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen) { // todo refactor - SStreamStateCur* pCur = streamStateSessionGetCur(pState, key); + SStreamStateCur* pCur = streamStateSessionGetRanomCur(pState, key); int32_t size = *pVLen; void* tmp = NULL; *pVal = tdbRealloc(NULL, size); @@ -659,7 +678,7 @@ int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen, state_key_cmpr_fn fn, void** pVal, int32_t* pVLen) { // todo refactor - int32_t res = TSDB_CODE_SUCCESS; + int32_t res = 0; SSessionKey tmpKey = *key; int32_t valSize = *pVLen; void* tmp = tdbRealloc(NULL, valSize); @@ -667,21 +686,14 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch return -1; } - SStreamStateCur* pCur = streamStateSessionGetRanomCur(pState, key); + SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev(pState, key); int32_t code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen); - if (code == TSDB_CODE_SUCCESS) { - memcpy(tmp, *pVal, valSize); - *pVal = tmp; - streamStateFreeCur(pCur); - return res; - } - streamStateFreeCur(pCur); + if (code == 0) { + if (key->win.skey <= tmpKey.win.skey && tmpKey.win.ekey <= key->win.ekey) { + memcpy(tmp, *pVal, valSize); + goto _end; + } - streamStateSessionPut(pState, key, NULL, 0); - pCur = streamStateSessionGetRanomCur(pState, key); - streamStateCurPrev(pState, pCur); - code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen); - if (code == TSDB_CODE_SUCCESS) { void* stateKey = (char*)(*pVal) + (valSize - keyDataLen); if (fn(pKeyData, stateKey) == true) { memcpy(tmp, *pVal, valSize); @@ -689,11 +701,9 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch } } - streamStateFreeCur(pCur); - *key = tmpKey; - pCur = streamStateSessionSeekKeyNext(pState, key); + streamStateCurNext(pState, pCur); code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen); - if (code == TSDB_CODE_SUCCESS) { + if (code == 0) { void* stateKey = (char*)(*pVal) + (valSize - keyDataLen); if (fn(pKeyData, stateKey) == true) { memcpy(tmp, *pVal, valSize); @@ -708,7 +718,6 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch _end: *pVal = tmp; - streamStateSessionDel(pState, &tmpKey); streamStateFreeCur(pCur); return res; } From 991da9564320c50d334470e23f8ec3458f31f39d Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 20 Oct 2022 09:06:18 +0800 Subject: [PATCH 17/25] fix: fix coverity issues --- source/dnode/vnode/src/vnd/vnodeQuery.c | 28 +++++++++++++++++++++++++ source/libs/executor/src/dataInserter.c | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 6a18ae2fa1..9adef918ba 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -285,15 +285,43 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) { } for (int32_t i = 0; i < msgNum; ++i) { + if (offset >= pMsg->contLen) { + qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen); + terrno = TSDB_CODE_MSG_NOT_PROCESSED; + taosArrayDestroy(batchRsp); + return -1; + } + req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset)); offset += sizeof(req.msgIdx); + if (offset >= pMsg->contLen) { + qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen); + terrno = TSDB_CODE_MSG_NOT_PROCESSED; + taosArrayDestroy(batchRsp); + return -1; + } + req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset)); offset += sizeof(req.msgType); + if (offset >= pMsg->contLen) { + qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen); + terrno = TSDB_CODE_MSG_NOT_PROCESSED; + taosArrayDestroy(batchRsp); + return -1; + } + req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset)); offset += sizeof(req.msgLen); + if (offset >= pMsg->contLen) { + qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen); + terrno = TSDB_CODE_MSG_NOT_PROCESSED; + taosArrayDestroy(batchRsp); + return -1; + } + req.msg = (char *)pMsg->pCont + offset; offset += req.msgLen; diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index d996634d8e..78afdd16b7 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -329,6 +329,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat } if (pInserterNode->stableId != suid) { + destroyDataSinker((SDataSinkHandle*)inserter); + taosMemoryFree(inserter); terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; return terrno; } @@ -336,6 +338,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat inserter->pDataBlocks = taosArrayInit(1, POINTER_BYTES); taosThreadMutexInit(&inserter->mutex, NULL); if (NULL == inserter->pDataBlocks) { + destroyDataSinker((SDataSinkHandle*)inserter); + taosMemoryFree(inserter); terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY; } From 951d110b3b4b6b0cf6d2e529d16aae61e568c040 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Thu, 20 Oct 2022 09:31:17 +0800 Subject: [PATCH 18/25] fix: coverity scan for trow --- include/common/tdataformat.h | 2 -- include/common/trow.h | 2 +- source/common/src/tdatablock.c | 8 ++--- source/common/src/trow.c | 49 +++++++++++++++-------------- source/dnode/mnode/impl/src/mndDb.c | 2 +- source/libs/index/src/indexComm.c | 4 +-- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index a1fefa6902..c0c3fc7fbc 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -234,8 +234,6 @@ struct STag { // Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap. #define TD_SUPPORT_BITMAP -#define TASSERT(x) ASSERT(x) - #define STR_TO_VARSTR(x, str) \ do { \ VarDataLenT __len = (VarDataLenT)strlen(str); \ diff --git a/include/common/trow.h b/include/common/trow.h index 8b0349c99b..c5293fa45f 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -255,7 +255,7 @@ static FORCE_INLINE void *tdGetBitmapAddrKv(STSRow *pRow, col_id_t nKvCols) { void *tdGetBitmapAddr(STSRow *pRow, uint8_t rowType, uint32_t flen, col_id_t nKvCols); int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int8_t bitmapMode); int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType); -bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode); +// bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode); int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode); // ----------------- Tuple row structure(STpRow) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index a22837d981..fda1a05290 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1858,7 +1858,7 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { char* pData = colDataGetVarData(pColInfoData, j); int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData)); memset(pBuf, 0, dataSize); - taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf); + (void)taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf); printf(" %15s |", pBuf); } break; default: @@ -1946,7 +1946,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) char* pData = colDataGetVarData(pColInfoData, j); int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData)); memset(pBuf, 0, sizeof(pBuf)); - taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf); + (void)taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf); len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf); if (len >= size - 1) return dumpBuf; } break; @@ -2053,7 +2053,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_MEDIUMBLOB: uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type); - TASSERT(0); + ASSERT(0); break; default: if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) { @@ -2084,7 +2084,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB } } else { uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type); - TASSERT(0); + ASSERT(0); } break; } diff --git a/source/common/src/trow.c b/source/common/src/trow.c index d5c0f2ddf8..b007075efe 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -481,7 +481,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) { if (!pBitmap || colIdx < 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -503,7 +503,7 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa *pValType = ((*pDestByte) & 0x03); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -512,7 +512,7 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType) { if (!pBitmap || colIdx < 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -546,7 +546,7 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal *pValType = ((*pDestByte) & 0x01); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -555,7 +555,7 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) { if (!pBitmap || colIdx < 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -598,7 +598,7 @@ int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) { // *pDestByte |= (valType); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -607,7 +607,7 @@ int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) { int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int32_t offset, int16_t colIdx) { #ifdef TD_SUPPORT_BITMAP - TASSERT(colIdx < tdRowGetNCols(pRow) - 1); + ASSERT(colIdx < tdRowGetNCols(pRow) - 1); if (tdGetBitmapValType(pBitmap, colIdx, &output->valType, 0) != TSDB_CODE_SUCCESS) { output->valType = TD_VTYPE_NONE; return terrno; @@ -621,7 +621,7 @@ int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int32_ output->val = POINTER_SHIFT(pRow, offset); } #else - TASSERT(0); + ASSERT(0); if (offset < 0) { terrno = TSDB_CODE_INVALID_PARA; output->valType = TD_VTYPE_NONE; @@ -671,7 +671,7 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp return terrno; } #else - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; #endif @@ -709,7 +709,7 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset, col_id_t colId) { if ((offset < (int32_t)sizeof(SKvRowIdx)) || (colIdx < 1)) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -798,7 +798,7 @@ int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBou pBuilder->nCols = nCols; pBuilder->nBoundCols = nBoundCols; if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -820,7 +820,7 @@ int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBou int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { pBuilder->pBuf = (STSRow *)pBuf; if (!pBuilder->pBuf) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -831,7 +831,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { TD_ROW_SET_INFO(pBuilder->pBuf, 0); TD_ROW_SET_TYPE(pBuilder->pBuf, pBuilder->rowType); - TASSERT(pBuilder->nBitmaps > 0 && pBuilder->flen > 0); + ASSERT(pBuilder->nBitmaps > 0 && pBuilder->flen > 0); uint32_t len = 0; switch (pBuilder->rowType) { @@ -857,7 +857,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { TD_ROW_SET_NCOLS(pBuilder->pBuf, pBuilder->nBoundCols); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -868,12 +868,12 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) { int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) { pBuilder->pBuf = (STSRow *)pBuf; if (!pBuilder->pBuf) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } - TASSERT(pBuilder->nBitmaps > 0 && pBuilder->flen > 0); + ASSERT(pBuilder->nBitmaps > 0 && pBuilder->flen > 0); uint32_t len = 0; switch (pBuilder->rowType) { @@ -888,7 +888,7 @@ int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) { #endif break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -908,7 +908,7 @@ int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) { pBuilder->flen = flen; pBuilder->nCols = nCols; if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -927,7 +927,7 @@ int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, pBuilder->nCols = nCols; pBuilder->nBoundCols = nBoundCols; if (pBuilder->flen <= 0 || pBuilder->nCols <= 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -956,13 +956,13 @@ int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValT tdGetBitmapValTypeI(pBitmap, colIdx, pValType); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return TSDB_CODE_FAILED; } return TSDB_CODE_SUCCESS; } - +#if 0 bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode) { TDRowValT valType = 0; tdGetBitmapValType(pBitmap, idx, &valType, bitmapMode); @@ -971,10 +971,11 @@ bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode) } return false; } +#endif int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) { if (!pBitmap || colIdx < 0) { - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1001,7 +1002,7 @@ int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) { // *pDestByte |= (valType); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1018,7 +1019,7 @@ int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int tdSetBitmapValTypeI(pBitmap, colIdx, valType); break; default: - TASSERT(0); + ASSERT(0); terrno = TSDB_CODE_INVALID_PARA; return TSDB_CODE_FAILED; } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 654664269d..2660fa3146 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -113,7 +113,7 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT8(pRaw, dataPos, pDb->cfg.hashMethod, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.numOfRetensions, _OVER) for (int32_t i = 0; i < pDb->cfg.numOfRetensions; ++i) { - TASSERT(taosArrayGetSize(pDb->cfg.pRetensions) == pDb->cfg.numOfRetensions); + ASSERT(taosArrayGetSize(pDb->cfg.pRetensions) == pDb->cfg.numOfRetensions); SRetention *pRetension = taosArrayGet(pDb->cfg.pRetensions, i); SDB_SET_INT64(pRaw, dataPos, pRetension->freq, _OVER) SDB_SET_INT64(pRaw, dataPos, pRetension->keep, _OVER) diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 25036996fc..e3f140047a 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -367,7 +367,7 @@ int32_t idxConvertData(void* src, int8_t type, void** dst) { tlen = taosEncodeBinary(dst, src, strlen(src)); break; default: - TASSERT(0); + ASSERT(0); break; } *dst = (char*)*dst - tlen; @@ -459,7 +459,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { *dst = (char*)*dst - tlen; break; default: - TASSERT(0); + ASSERT(0); break; } return tlen; From 63096c9d4380647d85041316c9ae3f227d8a4f74 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 20 Oct 2022 09:17:19 +0800 Subject: [PATCH 19/25] fix(sim): buffer size not enough --- utils/tsim/inc/simInt.h | 52 ++++++++++++++++++++++++++++++++--------- utils/tsim/src/simExe.c | 10 ++++---- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/utils/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h index 9438e11fbd..f512b119b4 100644 --- a/utils/tsim/inc/simInt.h +++ b/utils/tsim/inc/simInt.h @@ -19,20 +19,20 @@ #include "os.h" #include "cJSON.h" -#include "tconfig.h" #include "taos.h" #include "taoserror.h" +#include "tconfig.h" +#include "tglobal.h" #include "tidpool.h" #include "tlog.h" #include "ttimer.h" #include "ttypes.h" #include "tutil.h" -#include "tglobal.h" #define MAX_MAIN_SCRIPT_NUM 10 #define MAX_BACKGROUND_SCRIPT_NUM 10 #define MAX_FILE_NAME_LEN 256 -#define MAX_ERROR_LEN 1024 +#define MAX_ERROR_LEN 4096 #define MAX_QUERY_VALUE_LEN 1024 #define MAX_QUERY_COL_NUM 100 #define MAX_QUERY_ROW_NUM 100 @@ -55,12 +55,42 @@ #define FAILED_POSTFIX "" #endif -#define simFatal(...) { if (simDebugFlag & DEBUG_FATAL) { taosPrintLog("SIM FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} -#define simError(...) { if (simDebugFlag & DEBUG_ERROR) { taosPrintLog("SIM ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} -#define simWarn(...) { if (simDebugFlag & DEBUG_WARN) { taosPrintLog("SIM WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} -#define simInfo(...) { if (simDebugFlag & DEBUG_INFO) { taosPrintLog("SIM ", DEBUG_INFO, 255, __VA_ARGS__); }} -#define simDebug(...) { if (simDebugFlag & DEBUG_DEBUG) { taosPrintLog("SIM ", DEBUG_DEBUG, simDebugFlag, __VA_ARGS__); }} -#define simTrace(...) { if (simDebugFlag & DEBUG_TRACE) { taosPrintLog("SIM ", DEBUG_TRACE, simDebugFlag, __VA_ARGS__); }} +#define simFatal(...) \ + { \ + if (simDebugFlag & DEBUG_FATAL) { \ + taosPrintLog("SIM FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \ + } \ + } +#define simError(...) \ + { \ + if (simDebugFlag & DEBUG_ERROR) { \ + taosPrintLog("SIM ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); \ + } \ + } +#define simWarn(...) \ + { \ + if (simDebugFlag & DEBUG_WARN) { \ + taosPrintLog("SIM WARN ", DEBUG_WARN, 255, __VA_ARGS__); \ + } \ + } +#define simInfo(...) \ + { \ + if (simDebugFlag & DEBUG_INFO) { \ + taosPrintLog("SIM ", DEBUG_INFO, 255, __VA_ARGS__); \ + } \ + } +#define simDebug(...) \ + { \ + if (simDebugFlag & DEBUG_DEBUG) { \ + taosPrintLog("SIM ", DEBUG_DEBUG, simDebugFlag, __VA_ARGS__); \ + } \ + } +#define simTrace(...) \ + { \ + if (simDebugFlag & DEBUG_TRACE) { \ + taosPrintLog("SIM ", DEBUG_TRACE, simDebugFlag, __VA_ARGS__); \ + } \ + } enum { SIM_SCRIPT_TYPE_MAIN, SIM_SCRIPT_TYPE_BACKGROUND }; @@ -143,7 +173,7 @@ typedef struct _script_t { char *optionBuffer; SCmdLine *lines; // command list SVariable variables[MAX_VAR_LEN]; - TdThread bgPid; + TdThread bgPid; char auth[128]; struct _script_t *bgScripts[MAX_BACKGROUND_SCRIPT_NUM]; } SScript; @@ -182,4 +212,4 @@ bool simExecuteLineInsertCmd(SScript *script, char *option); bool simExecuteLineInsertErrorCmd(SScript *script, char *option); void simVisuallizeOption(SScript *script, char *src, char *dst); -#endif /*_TD_SIM_INT_H_*/ \ No newline at end of file +#endif /*_TD_SIM_INT_H_*/ diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c index 7218ea39f8..5ef6cd16be 100644 --- a/utils/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -657,11 +657,11 @@ bool simCreateTaosdConnect(SScript *script, char *rest) { } bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { - char timeStr[80] = {0}; - time_t tt; - struct tm tp; - SCmdLine *line = &script->lines[script->linePos]; - int32_t ret = -1; + char timeStr[80] = {0}; + time_t tt; + struct tm tp; + SCmdLine *line = &script->lines[script->linePos]; + int32_t ret = -1; TAOS_RES *pSql = NULL; From 446e8c5d6d88925c8567e9e556b367f6b0e842a6 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 20 Oct 2022 09:36:15 +0800 Subject: [PATCH 20/25] fix: coverity scan problem --- source/dnode/vnode/src/meta/metaTable.c | 5 +++++ source/dnode/vnode/src/tsdb/tsdbCommit.c | 1 + source/dnode/vnode/src/tsdb/tsdbFS.c | 4 +++- source/dnode/vnode/src/tsdb/tsdbRetention.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 0e8b3cf949..45a6265da0 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -668,6 +668,11 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl SSchemaWrapper *pSchema; int c; + if (pAlterTbReq->colName == NULL) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + // search name index ret = tdbTbGet(pMeta->pNameIdx, pAlterTbReq->tbName, strlen(pAlterTbReq->tbName) + 1, &pVal, &nVal); if (ret < 0) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 460ef611a3..674cdc115f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -1054,6 +1054,7 @@ static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) { _exit: tsdbFSDestroy(&pCommitter->fs); taosArrayDestroy(pCommitter->aTbDataP); + pCommitter->aTbDataP = NULL; if (code || eno) { tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code)); } else { diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index c63247c21a..4039520851 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -149,6 +149,7 @@ _exit: void tsdbFSDestroy(STsdbFS *pFS) { if (pFS->pDelFile) { taosMemoryFree(pFS->pDelFile); + pFS->pDelFile = NULL; } for (int32_t iSet = 0; iSet < taosArrayGetSize(pFS->aDFileSet); iSet++) { @@ -162,6 +163,7 @@ void tsdbFSDestroy(STsdbFS *pFS) { } taosArrayDestroy(pFS->aDFileSet); + pFS->aDFileSet = NULL; } static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) { @@ -296,7 +298,7 @@ static int32_t tsdbLoadFSFromFile(const char *fname, STsdbFS *pFS) { // load binary TdFilePtr pFD = taosOpenFile(fname, TD_FILE_READ); if (pFD == NULL) { - code = terrno; + code = TAOS_SYSTEM_ERROR(errno); TSDB_CHECK_CODE(code, lino, _exit); } diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index 259c30d591..c6e1ed99f1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -47,7 +47,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) { } // do retention - STsdbFS fs; + STsdbFS fs = {0}; code = tsdbFSCopy(pTsdb, &fs); if (code) goto _err; From 716c3f8a5999b60c93bf0fc204b87fda2d511f7a Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 20 Oct 2022 09:47:04 +0800 Subject: [PATCH 21/25] fix: coverity issues --- source/dnode/vnode/src/meta/metaTable.c | 11 +++++++++-- source/libs/tdb/src/db/tdbTable.c | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 0e8b3cf949..4717d57c17 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -575,7 +575,11 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); - metaDecodeEntry(&dc, &e); + rc = metaDecodeEntry(&dc, &e); + if (rc < 0) { + tDecoderClear(&dc); + return -1; + } if (type) *type = e.type; @@ -1244,7 +1248,10 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); tDecoderInit(&dc, pData, nData); - metaDecodeEntry(&dc, &stbEntry); + ret = metaDecodeEntry(&dc, &stbEntry); + if (ret < 0) { + goto end; + } pTagColumn = &stbEntry.stbEntry.schemaTag.pSchema[0]; diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 73cc34a86f..8b029b06d6 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -53,6 +53,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF if (strcmp(TDB_MAINDB_NAME, tbname)) { pPager = tdbEnvGetPager(pEnv, fFullName); if (!pPager) { + tdbOsFree(pTb); return -1; } @@ -72,6 +73,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF if (pPager == NULL) { ret = tdbPagerOpen(pEnv->pCache, fFullName, &pPager); if (ret < 0) { + tdbOsFree(pTb); return -1; } @@ -94,6 +96,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF snprintf(fFullName, TDB_FILENAME_LEN, "%s/%s", pEnv->dbName, tbname); ret = tdbPagerOpen(pEnv->pCache, fFullName, &pPager); if (ret < 0) { + tdbOsFree(pTb); return -1; } From 0ed1d883c3164a989c87a2c5103b8695746e59c4 Mon Sep 17 00:00:00 2001 From: slzhou Date: Thu, 20 Oct 2022 09:53:08 +0800 Subject: [PATCH 22/25] fix: fix coverity scan issue --- source/libs/function/inc/tudfInt.h | 2 +- source/libs/function/src/tudf.c | 11 ++++++----- source/libs/function/src/udfd.c | 23 ++++++++++++++--------- source/libs/function/test/runUdf.c | 7 +++++-- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/source/libs/function/inc/tudfInt.h b/source/libs/function/inc/tudfInt.h index c1b0941d4b..c69d19b8a6 100644 --- a/source/libs/function/inc/tudfInt.h +++ b/source/libs/function/inc/tudfInt.h @@ -35,7 +35,7 @@ enum { }; typedef struct SUdfSetupRequest { - char udfName[TSDB_FUNC_NAME_LEN]; + char udfName[TSDB_FUNC_NAME_LEN + 1]; } SUdfSetupRequest; typedef struct SUdfSetupResponse { diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 1483394509..69e58829a0 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -315,7 +315,7 @@ enum { UV_TASK_CONNECT = 0, UV_TASK_REQ_RSP = 1, UV_TASK_DISCONNECT = 2 }; int64_t gUdfTaskSeqNum = 0; typedef struct SUdfcFuncStub { - char udfName[TSDB_FUNC_NAME_LEN]; + char udfName[TSDB_FUNC_NAME_LEN + 1]; UdfcFuncHandle handle; int32_t refCount; int64_t lastRefTime; @@ -353,7 +353,7 @@ typedef struct SUdfcUvSession { int32_t outputLen; int32_t bufSize; - char udfName[TSDB_FUNC_NAME_LEN]; + char udfName[TSDB_FUNC_NAME_LEN + 1]; } SUdfcUvSession; typedef struct SClientUvTaskNode { @@ -898,7 +898,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) { int32_t code = 0; uv_mutex_lock(&gUdfdProxy.udfStubsMutex); SUdfcFuncStub key = {0}; - strcpy(key.udfName, udfName); + strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN); int32_t stubIndex = taosArraySearchIdx(gUdfdProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ); if (stubIndex != -1) { SUdfcFuncStub *foundStub = taosArrayGet(gUdfdProxy.udfStubs, stubIndex); @@ -936,7 +936,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) { void releaseUdfFuncHandle(char *udfName) { uv_mutex_lock(&gUdfdProxy.udfStubsMutex); SUdfcFuncStub key = {0}; - strcpy(key.udfName, udfName); + strncpy(key.udfName, udfName, TSDB_FUNC_NAME_LEN); SUdfcFuncStub *foundStub = taosArraySearch(gUdfdProxy.udfStubs, &key, compareUdfcFuncSub, TD_EQ); if (!foundStub) { uv_mutex_unlock(&gUdfdProxy.udfStubsMutex); @@ -1446,6 +1446,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { QUEUE_INSERT_TAIL(connTaskQueue, &uvTask->connTaskQueue); int err = uv_write(write, (uv_stream_t *)pipe, &uvTask->reqBuf, 1, onUdfcPipeWrite); if (err != 0) { + taosMemoryFree(write); fnError("udfc event loop start req_rsp task uv_write failed. uvtask: %p, code: %s", uvTask, uv_strerror(err)); } code = err; @@ -1637,7 +1638,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) { task->session->outputType = rsp->outputType; task->session->outputLen = rsp->outputLen; task->session->bufSize = rsp->bufSize; - strcpy(task->session->udfName, udfName); + strncpy(task->session->udfName, udfName, TSDB_FUNC_NAME_LEN); if (task->errCode != 0) { fnError("failed to setup udf. udfname: %s, err: %d", udfName, task->errCode) } else { diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 0b67fa356a..f8c4f171ba 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -71,7 +71,7 @@ typedef struct SUdf { uv_cond_t condReady; bool resident; - char name[TSDB_FUNC_NAME_LEN]; + char name[TSDB_FUNC_NAME_LEN + 1]; int8_t funcType; int8_t scriptType; int8_t outputType; @@ -188,11 +188,12 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { SUdf *udfNew = taosMemoryCalloc(1, sizeof(SUdf)); udfNew->refCount = 1; udfNew->state = UDF_STATE_INIT; - uv_mutex_init(&udfNew->lock); uv_cond_init(&udfNew->condReady); + udf = udfNew; - taosHashPut(global.udfsHash, request->setup.udfName, strlen(request->setup.udfName), &udfNew, sizeof(&udfNew)); + SUdf** pUdf = &udf; + taosHashPut(global.udfsHash, request->setup.udfName, strlen(request->setup.udfName), pUdf, POINTER_BYTES); uv_mutex_unlock(&global.udfsMutex); } @@ -246,7 +247,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { SUdfCallRequest *call = &request->call; - fnDebug("%" PRId64 "call request. call type %d, handle: %" PRIx64, request->seqNum, call->callType, call->udfHandle); + fnDebug("call request. call type %d, handle: %" PRIx64 ", seq num %" PRId64 , call->callType, call->udfHandle, request->seqNum); SUdfcFuncHandle * handle = (SUdfcFuncHandle *)(call->udfHandle); SUdf * udf = handle->udf; SUdfResponse response = {0}; @@ -372,7 +373,7 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { } taosMemoryFree(handle); - SUdfResponse response; + SUdfResponse response = {0}; SUdfResponse *rsp = &response; rsp->seqNum = request->seqNum; rsp->type = request->type; @@ -428,7 +429,9 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { } else if (msgInfo->rpcType == UDFD_RPC_RETRIVE_FUNC) { SRetrieveFuncRsp retrieveRsp = {0}; tDeserializeSRetrieveFuncRsp(pMsg->pCont, pMsg->contLen, &retrieveRsp); - + if (retrieveRsp.pFuncInfos == NULL) { + goto _return; + } SFuncInfo *pFuncInfo = (SFuncInfo *)taosArrayGet(retrieveRsp.pFuncInfos, 0); SUdf * udf = msgInfo->param; udf->funcType = pFuncInfo->funcType; @@ -540,7 +543,7 @@ int32_t udfdConnectToMnode() { } int32_t udfdLoadUdf(char *udfName, SUdf *udf) { - strcpy(udf->name, udfName); + strncpy(udf->name, udfName, TSDB_FUNC_NAME_LEN); int32_t err = 0; err = udfdFillUdfInfoFromMNode(global.clientRpc, udf->name, udf); @@ -880,6 +883,8 @@ static int32_t udfdUvInit() { uv_loop_t *loop = taosMemoryMalloc(sizeof(uv_loop_t)); if (loop) { uv_loop_init(loop); + } else { + return -1; } global.loop = loop; @@ -901,12 +906,12 @@ static int32_t udfdUvInit() { if ((r = uv_pipe_bind(&global.listeningPipe, global.listenPipeName))) { fnError("Bind error %s", uv_err_name(r)); removeListeningPipe(); - return -1; + return -2; } if ((r = uv_listen((uv_stream_t *)&global.listeningPipe, 128, udfdOnNewConnection))) { fnError("Listen error %s", uv_err_name(r)); removeListeningPipe(); - return -2; + return -3; } return 0; } diff --git a/source/libs/function/test/runUdf.c b/source/libs/function/test/runUdf.c index f1e3f4c60c..b5d1b1576b 100644 --- a/source/libs/function/test/runUdf.c +++ b/source/libs/function/test/runUdf.c @@ -110,8 +110,11 @@ int aggregateFuncTest() { taosArrayDestroy(pBlock->pDataBlock); doCallUdfAggFinalize(handle, &newBuf, &resultBuf); - fprintf(stderr, "agg result: %f\n", *(double *)resultBuf.buf); - + if (resultBuf.buf != NULL) { + fprintf(stderr, "agg result: %f\n", *(double *)resultBuf.buf); + } else { + fprintf(stderr, "result buffer is null"); + } freeUdfInterBuf(&buf); freeUdfInterBuf(&newBuf); freeUdfInterBuf(&resultBuf); From 70adc0ea3314fa5ca87b4ef530bf2cafd61b7050 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 20 Oct 2022 11:27:33 +0800 Subject: [PATCH 23/25] fix(query): fix coverity issues. --- source/dnode/vnode/src/tsdb/tsdbCacheRead.c | 2 +- source/dnode/vnode/src/tsdb/tsdbMergeTree.c | 82 +++++++++++--------- source/dnode/vnode/src/tsdb/tsdbRead.c | 44 ++++++++--- source/libs/executor/inc/executorimpl.h | 8 +- source/libs/executor/src/cachescanoperator.c | 4 +- source/libs/executor/src/dataDeleter.c | 7 +- source/libs/executor/src/executor.c | 6 +- source/libs/executor/src/executorimpl.c | 76 +++++------------- source/libs/executor/src/groupoperator.c | 75 +++++++++++++----- source/libs/executor/src/joinoperator.c | 28 +++++-- source/libs/executor/src/scanoperator.c | 8 +- source/libs/executor/src/sortoperator.c | 20 ++--- source/libs/executor/src/tlinearhash.c | 1 + source/libs/executor/src/tsort.c | 40 ++++++---- 14 files changed, 229 insertions(+), 172 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index 20352bb502..ed491ca182 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -194,7 +194,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 } } else if ((pr->type & CACHESCAN_RETRIEVE_TYPE_ALL) == CACHESCAN_RETRIEVE_TYPE_ALL) { for (int32_t i = pr->tableIndex; i < numOfTables; ++i) { - STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, i); + STableKeyInfo* pKeyInfo = (STableKeyInfo*) taosArrayGet(pr->pTableList, i); code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h); if (code != TSDB_CODE_SUCCESS) { return code; diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 2f4fdfc5f8..8808f3c50c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -120,44 +120,46 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) { return &pInfo->blockData[1]; } - pInfo->currentLoadBlockIndex ^= 1; - if (pIter->pSttBlk != NULL) { // current block not loaded yet - int64_t st = taosGetTimestampUs(); - - SBlockData *pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex]; - - TABLEID id = {0}; - if (pIter->pSttBlk->suid != 0) { - id.suid = pIter->pSttBlk->suid; - } else { - id.uid = pIter->uid; - } - - code = tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols); - if (code != TSDB_CODE_SUCCESS) { - goto _exit; - } - - code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock); - if (code != TSDB_CODE_SUCCESS) { - goto _exit; - } - - double el = (taosGetTimestampUs() - st) / 1000.0; - pInfo->elapsedTime += el; - pInfo->loadBlocks += 1; - - tsdbDebug("read last block, total load:%d, trigger by uid:%" PRIu64 - ", last file index:%d, last block index:%d, entry:%d, %p, elapsed time:%.2f ms, %s", - pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock, el, - idStr); - - pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk; - tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr); - - pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1; + if (pIter->pSttBlk == NULL) { + return NULL; } + // current block not loaded yet + pInfo->currentLoadBlockIndex ^= 1; + int64_t st = taosGetTimestampUs(); + + SBlockData *pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex]; + + TABLEID id = {0}; + if (pIter->pSttBlk->suid != 0) { + id.suid = pIter->pSttBlk->suid; + } else { + id.uid = pIter->uid; + } + + code = tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols); + if (code != TSDB_CODE_SUCCESS) { + goto _exit; + } + + code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock); + if (code != TSDB_CODE_SUCCESS) { + goto _exit; + } + + double el = (taosGetTimestampUs() - st) / 1000.0; + pInfo->elapsedTime += el; + pInfo->loadBlocks += 1; + + tsdbDebug("read last block, total load:%d, trigger by uid:%" PRIu64 + ", last file index:%d, last block index:%d, entry:%d, %p, elapsed time:%.2f ms, %s", + pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock, el, + idStr); + + pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk; + tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr); + + pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1; return &pInfo->blockData[pInfo->currentLoadBlockIndex]; _exit: @@ -259,7 +261,8 @@ static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t iStt, int8_t backward, uint64_t suid, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo *pBlockLoadInfo, const char *idStr) { - int32_t code = 0; + int32_t code = TSDB_CODE_SUCCESS; + *pIter = taosMemoryCalloc(1, sizeof(SLDataIter)); if (*pIter == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -336,7 +339,10 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t (*pIter)->iRow = ((*pIter)->backward) ? (*pIter)->pSttBlk->nRow : -1; } + return code; + _exit: + taosMemoryFree(*pIter); return code; } @@ -473,7 +479,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { int32_t iBlockL = pIter->iSttBlk; SBlockData *pBlockData = loadLastBlock(pIter, idStr); - if (pBlockData == NULL && terrno != TSDB_CODE_SUCCESS) { + if (pBlockData == NULL || terrno != TSDB_CODE_SUCCESS) { goto _exit; } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 452e8c5d55..6580951ce0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -1047,11 +1047,16 @@ static int32_t fileDataBlockOrderCompar(const void* pLeft, const void* pRight, v return pLeftBlock->offset > pRightBlock->offset ? 1 : -1; } -static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter) { +static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter, const char* idStr) { SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); if (pBlockInfo != NULL) { STableBlockScanInfo* pScanInfo = taosHashGet(pBlockIter->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); - int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx); + if (pScanInfo == NULL) { + tsdbError("failed to locate the uid:%"PRIu64" in query table uid list, %s", pBlockInfo->uid, idStr); + return TSDB_CODE_INVALID_PARA; + } + + int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx); tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetDataBlk); } @@ -1135,7 +1140,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte pBlockIter->index = asc ? 0 : (numOfBlocks - 1); cleanupBlockOrderSupporter(&sup); - doSetCurrentBlock(pBlockIter); + doSetCurrentBlock(pBlockIter, pReader->idStr); return TSDB_CODE_SUCCESS; } @@ -1175,12 +1180,12 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte taosMemoryFree(pTree); pBlockIter->index = asc ? 0 : (numOfBlocks - 1); - doSetCurrentBlock(pBlockIter); + doSetCurrentBlock(pBlockIter, pReader->idStr); return TSDB_CODE_SUCCESS; } -static bool blockIteratorNext(SDataBlockIter* pBlockIter) { +static bool blockIteratorNext(SDataBlockIter* pBlockIter, const char* idStr) { bool asc = ASCENDING_TRAVERSE(pBlockIter->order); int32_t step = asc ? 1 : -1; @@ -1189,7 +1194,7 @@ static bool blockIteratorNext(SDataBlockIter* pBlockIter) { } pBlockIter->index += step; - doSetCurrentBlock(pBlockIter); + doSetCurrentBlock(pBlockIter, idStr); return true; } @@ -1260,7 +1265,7 @@ static int32_t setFileBlockActiveInBlockIter(SDataBlockIter* pBlockIter, int32_t ASSERT(pBlockInfo->uid == fblock.uid && pBlockInfo->tbBlockIdx == fblock.tbBlockIdx); } - doSetCurrentBlock(pBlockIter); + doSetCurrentBlock(pBlockIter, ""); return TSDB_CODE_SUCCESS; } @@ -2190,6 +2195,8 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI } static int32_t buildComposedDataBlock(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + SSDataBlock* pResBlock = pReader->pResBlock; SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); @@ -2200,6 +2207,13 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { STableBlockScanInfo* pBlockScanInfo = NULL; if (pBlockInfo != NULL) { pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); + if (pBlockScanInfo == NULL) { + code = TSDB_CODE_INVALID_PARA; + tsdbError("failed to locate the uid:%"PRIu64" in query table uid list, total tables:%d, %s", + pBlockInfo->uid, taosHashGetSize(pReader->status.pTableMap), pReader->idStr); + goto _end; + } + SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); TSDBKEY keyInBuf = getCurrentKeyInBuf(pBlockScanInfo, pReader); @@ -2276,7 +2290,7 @@ _end: pResBlock->info.rows, el, pReader->idStr); } - return TSDB_CODE_SUCCESS; + return code; } void setComposedBlockFlag(STsdbReader* pReader, bool composed) { pReader->status.composedDataBlock = composed; } @@ -2732,7 +2746,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) { // current block are exhausted, try the next file block if (pDumpInfo->allDumped) { // try next data block in current file - bool hasNext = blockIteratorNext(&pReader->status.blockIter); + bool hasNext = blockIteratorNext(&pReader->status.blockIter, pReader->idStr); if (hasNext) { // check for the next block in the block accessed order list initBlockDumpInfo(pReader, pBlockIter); } else { @@ -3849,8 +3863,14 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) { return pReader->pResBlock->pDataBlock; } - SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pStatus->blockIter); - STableBlockScanInfo* pBlockScanInfo = taosHashGet(pStatus->pTableMap, &pFBlock->uid, sizeof(pFBlock->uid)); + SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter); + STableBlockScanInfo* pBlockScanInfo = taosHashGet(pStatus->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); + if (pBlockScanInfo == NULL) { + terrno = TSDB_CODE_INVALID_PARA; + tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid, + taosHashGetSize(pReader->status.pTableMap), pReader->idStr); + return NULL; + } int32_t code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData, pBlockScanInfo->uid); if (code != TSDB_CODE_SUCCESS) { @@ -3979,7 +3999,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa int32_t bucketIndex = getBucketIndex(pTableBlockInfo->defMinRows, bucketRange, numOfRows); pTableBlockInfo->blockRowsHisto[bucketIndex]++; - hasNext = blockIteratorNext(&pStatus->blockIter); + hasNext = blockIteratorNext(&pStatus->blockIter, pReader->idStr); } else { code = initForFirstBlockInFile(pReader, pBlockIter); if ((code != TSDB_CODE_SUCCESS) || (pReader->status.loadFromFile == false)) { diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index fc996a6003..f9442bf46b 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -955,9 +955,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, - SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo, - int32_t numOfScalarExpr, bool mergeResult, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo); @@ -981,9 +979,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SExecTaskInfo* pTaskInfo, int32_t numOfChild); SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionWinodwPhysiNode* pSessionNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, - SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition, - SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode *pAggNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* readHandle, uint64_t uid, SBlockDistScanPhysiNode* pBlockScanNode, SExecTaskInfo* pTaskInfo); diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index ebf23ba6bc..1074678efd 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -162,7 +162,9 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { if (pTableList->map != NULL) { int64_t* groupId = taosHashGet(pTableList->map, &pInfo->pRes->info.uid, sizeof(int64_t)); - pInfo->pRes->info.groupId = *groupId; + if (groupId != NULL) { + pInfo->pRes->info.groupId = *groupId; + } } else { ASSERT(taosArrayGetSize(pTableList->pTableList) == 1); STableKeyInfo* pKeyInfo = taosArrayGet(pTableList->pTableList, 0); diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 55978855d1..e9c3bfe34d 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -227,8 +227,11 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) { while (!taosQueueEmpty(pDeleter->pDataBlocks)) { SDataDeleterBuf* pBuf = NULL; taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf); - taosMemoryFreeClear(pBuf->pData); - taosFreeQitem(pBuf); + + if (pBuf != NULL) { + taosMemoryFreeClear(pBuf->pData); + taosFreeQitem(pBuf); + } } taosCloseQueue(pDeleter->pDataBlocks); taosThreadMutexDestroy(&pDeleter->mutex); diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index ba687ab7fc..4f4b6364e9 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -358,15 +358,15 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SDataSinkMgtCfg cfg = {.maxDataBlockNum = 10000, .maxDataBlockNumPerQuery = 5000}; code = dsDataSinkMgtInit(&cfg); if (code != TSDB_CODE_SUCCESS) { - qError("failed to dsDataSinkMgtInit, code: %s", tstrerror(code)); + qError("failed to dsDataSinkMgtInit, code:%s, %s", tstrerror(code), (*pTask)->id.str); goto _error; } if (handle) { void* pSinkParam = NULL; code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTaskInfo, readHandle); - if (code != TSDB_CODE_SUCCESS) { - qError("failed to createDataSinkParam, code: %s", tstrerror(code)); + if (code != TSDB_CODE_SUCCESS || pSinkParam == NULL) { + qError("failed to createDataSinkParam, vgId:%d, code:%s, %s", vgId, tstrerror(code), (*pTask)->id.str); goto _error; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 8e53cc2c33..a17ba79819 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3047,32 +3047,40 @@ void cleanupExprSupp(SExprSupp* pSupp) { taosMemoryFree(pSupp->rowEntryInfoOffset); } -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, - SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo, - int32_t numOfScalarExpr, bool mergeResult, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode,SExecTaskInfo* pTaskInfo) { SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + SSDataBlock* pResBlock = createResDataBlock(pAggNode->node.pOutputDataBlockDesc); + initBasicInfo(&pInfo->binfo, pResBlock); + int32_t numOfScalarExpr = 0; + SExprInfo* pScalarExprInfo = NULL; + if (pAggNode->pExprs != NULL) { + pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); + } + + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; initResultSizeInfo(&pOperator->resultInfo, 4096); - int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); + int32_t code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; } - initBasicInfo(&pInfo->binfo, pResultBlock); code = initExprSupp(&pInfo->scalarExprSup, pScalarExprInfo, numOfScalarExpr); if (code != TSDB_CODE_SUCCESS) { goto _error; } - pInfo->binfo.mergeResultBlock = mergeResult; + pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; pInfo->groupId = UINT64_MAX; - pInfo->pCondition = pCondition; + pInfo->pCondition = pAggNode->node.pConditions; pOperator->name = "TableAggregate"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_AGG; pOperator->blocking = true; @@ -3331,8 +3339,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT return pTaskInfo; } -static SArray* extractColumnInfo(SNodeList* pNodeList); - SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, SExecTaskInfo* pTaskInfo) { @@ -3709,22 +3715,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createProjectOperatorInfo(ops[0], (SProjectPhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_HASH_AGG == type) { SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode; - SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); - - int32_t numOfScalarExpr = 0; - SExprInfo* pScalarExprInfo = NULL; - if (pAggNode->pExprs != NULL) { - pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); - } - if (pAggNode->pGroupKeys != NULL) { - SArray* pColList = extractColumnInfo(pAggNode->pGroupKeys); - pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, - pScalarExprInfo, numOfScalarExpr, pTaskInfo); + pOptr = createGroupOperatorInfo(ops[0], pAggNode, pTaskInfo); } else { - pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pAggNode->node.pConditions, - pScalarExprInfo, numOfScalarExpr, pAggNode->mergeDataBlock, pTaskInfo); + pOptr = createAggregateOperatorInfo(ops[0], pAggNode, pTaskInfo); } } else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type) { SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; @@ -3814,39 +3808,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return pOptr; } -SArray* extractColumnInfo(SNodeList* pNodeList) { - size_t numOfCols = LIST_LENGTH(pNodeList); - SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn)); - if (pList == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; - } - - for (int32_t i = 0; i < numOfCols; ++i) { - STargetNode* pNode = (STargetNode*)nodesListGetNode(pNodeList, i); - - if (nodeType(pNode->pExpr) == QUERY_NODE_COLUMN) { - SColumnNode* pColNode = (SColumnNode*)pNode->pExpr; - - SColumn c = extractColumnFromColumnNode(pColNode); - taosArrayPush(pList, &c); - } else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) { - SValueNode* pValNode = (SValueNode*)pNode->pExpr; - SColumn c = {0}; - c.slotId = pNode->slotId; - c.colId = pNode->slotId; - c.type = pValNode->node.type; - c.bytes = pValNode->node.resType.bytes; - c.scale = pValNode->node.resType.scale; - c.precision = pValNode->node.resType.precision; - - taosArrayPush(pList, &c); - } - } - - return pList; -} - static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanInfo** ppInfo) { if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { @@ -4070,6 +4031,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead (*pTaskInfo)->sql = sql; sql = NULL; + (*pTaskInfo)->pSubplan = pPlan; (*pTaskInfo)->pRoot = createOperatorTree(pPlan->pNode, *pTaskInfo, pHandle, &(*pTaskInfo)->tableqinfoList, pPlan->pTagCond, pPlan->pTagIndexCond, pPlan->user); diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 4ca4ef7b3f..60b11b7326 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -30,6 +30,7 @@ static void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDa static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity); static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup); +static SArray* extractColumnInfo(SNodeList* pNodeList); static void freeGroupKey(void* param) { SGroupKeys* pKey = (SGroupKeys*)param; @@ -61,7 +62,7 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** int32_t numOfGroupCols = taosArrayGetSize(pGroupColList); for (int32_t i = 0; i < numOfGroupCols; ++i) { - SColumn* pCol = taosArrayGet(pGroupColList, i); + SColumn* pCol = (SColumn*) taosArrayGet(pGroupColList, i); (*keyLen) += pCol->bytes; // actual data + null_flag SGroupKeys key = {0}; @@ -396,41 +397,48 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) { return buildGroupResultDataBlock(pOperator); } -SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, - SSDataBlock* pResultBlock, SArray* pGroupColList, SNode* pCondition, - SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode *pAggNode, SExecTaskInfo* pTaskInfo) { SGroupbyOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SGroupbyOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - pInfo->pGroupCols = pGroupColList; - pInfo->pCondition = pCondition; + SSDataBlock* pResBlock = createResDataBlock(pAggNode->node.pOutputDataBlockDesc); + initBasicInfo(&pInfo->binfo, pResBlock); + + int32_t numOfScalarExpr = 0; + SExprInfo* pScalarExprInfo = NULL; + if (pAggNode->pExprs != NULL) { + pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); + } + + pInfo->pGroupCols = extractColumnInfo(pAggNode->pGroupKeys); + pInfo->pCondition = pAggNode->node.pConditions; int32_t code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, numOfScalarExpr); if (code != TSDB_CODE_SUCCESS) { goto _error; } - code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList); + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); + code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pInfo->pGroupCols); if (code != TSDB_CODE_SUCCESS) { goto _error; } initResultSizeInfo(&pOperator->resultInfo, 4096); - code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, pInfo->groupKeyLen, pTaskInfo->id.str); + code = initAggInfo(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, pInfo->groupKeyLen, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; } - initBasicInfo(&pInfo->binfo, pResultBlock); initResultRowInfo(&pInfo->binfo.resultRowInfo); pOperator->name = "GroupbyAggOperator"; pOperator->blocking = true; pOperator->status = OP_NOT_OPENED; - // pOperator->operatorType = OP_Groupby; pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; @@ -451,8 +459,6 @@ _error: } static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) { - // SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SPartitionOperatorInfo* pInfo = pOperator->info; for (int32_t j = 0; j < pBlock->info.rows; ++j) { @@ -760,7 +766,6 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition int32_t numOfCols = 0; SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &numOfCols); - pInfo->pGroupCols = extractPartitionColInfo(pPartNode->pPartitionKeys); if (pPartNode->pExprs != NULL) { @@ -781,14 +786,13 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition uint32_t defaultPgsz = 0; uint32_t defaultBufsz = 0; - SSDataBlock* pResBlock = createResDataBlock(pPartNode->node.pOutputDataBlockDesc); - getBufferPgSize(pResBlock->info.rowSize, &defaultPgsz, &defaultBufsz); + pInfo->binfo.pRes = createResDataBlock(pPartNode->node.pOutputDataBlockDesc); + getBufferPgSize(pInfo->binfo.pRes->info.rowSize, &defaultPgsz, &defaultBufsz); if (!osTempSpaceAvailable()) { terrno = TSDB_CODE_NO_AVAIL_DISK; pTaskInfo->code = terrno; qError("Create partition operator info failed since %s", terrstr(terrno)); - blockDataDestroy(pResBlock); goto _error; } @@ -797,8 +801,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition goto _error; } - pInfo->rowCapacity = blockDataGetCapacityInRow(pResBlock, getBufPageSize(pInfo->pBuf)); - pInfo->columnOffset = setupColumnOffset(pResBlock, pInfo->rowCapacity); + pInfo->rowCapacity = blockDataGetCapacityInRow(pInfo->binfo.pRes, getBufPageSize(pInfo->pBuf)); + pInfo->columnOffset = setupColumnOffset(pInfo->binfo.pRes, pInfo->rowCapacity); code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pInfo->pGroupCols); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -808,7 +812,6 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition pOperator->blocking = true; pOperator->status = OP_NOT_OPENED; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PARTITION; - pInfo->binfo.pRes = pResBlock; pOperator->exprSupp.numOfExprs = numOfCols; pOperator->exprSupp.pExprInfo = pExprInfo; pOperator->info = pInfo; @@ -1102,3 +1105,37 @@ _error: taosMemoryFreeClear(pOperator); return NULL; } + + +SArray* extractColumnInfo(SNodeList* pNodeList) { + size_t numOfCols = LIST_LENGTH(pNodeList); + SArray* pList = taosArrayInit(numOfCols, sizeof(SColumn)); + if (pList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + for (int32_t i = 0; i < numOfCols; ++i) { + STargetNode* pNode = (STargetNode*)nodesListGetNode(pNodeList, i); + + if (nodeType(pNode->pExpr) == QUERY_NODE_COLUMN) { + SColumnNode* pColNode = (SColumnNode*)pNode->pExpr; + + SColumn c = extractColumnFromColumnNode(pColNode); + taosArrayPush(pList, &c); + } else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) { + SValueNode* pValNode = (SValueNode*)pNode->pExpr; + SColumn c = {0}; + c.slotId = pNode->slotId; + c.colId = pNode->slotId; + c.type = pValNode->node.type; + c.bytes = pValNode->node.resType.bytes; + c.scale = pValNode->node.resType.scale; + c.precision = pValNode->node.resType.precision; + + taosArrayPush(pList, &c); + } + } + + return pList; +} diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index 53cfa6c27a..eab0307e01 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -59,15 +59,16 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo) { SJoinOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SJoinOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + + int32_t code = TSDB_CODE_SUCCESS; if (pOperator == NULL || pInfo == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; goto _error; } + int32_t numOfCols = 0; SSDataBlock* pResBlock = createResDataBlock(pJoinNode->node.pOutputDataBlockDesc); - - int32_t numOfCols = 0; - SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &numOfCols); - + SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &numOfCols); initResultSizeInfo(&pOperator->resultInfo, 4096); pInfo->pRes = pResBlock; @@ -84,8 +85,18 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t if (pJoinNode->pOnConditions != NULL && pJoinNode->node.pConditions != NULL) { pInfo->pCondAfterMerge = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + if (pInfo->pCondAfterMerge == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _error; + } + SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(pInfo->pCondAfterMerge); pLogicCond->pParameterList = nodesMakeList(); + if (pLogicCond->pParameterList == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _error; + } + nodesListMakeAppend(&pLogicCond->pParameterList, nodesCloneNode(pJoinNode->pOnConditions)); nodesListMakeAppend(&pLogicCond->pParameterList, nodesCloneNode(pJoinNode->node.pConditions)); pLogicCond->condType = LOGIC_COND_TYPE_AND; @@ -106,7 +117,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyMergeJoinOperator, NULL, NULL, NULL); - int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream); + code = appendDownstream(pOperator, pDownstream, numOfDownstream); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -114,9 +125,12 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t return pOperator; _error: - taosMemoryFree(pInfo); + if (pInfo != NULL) { + destroyMergeJoinOperator(pInfo); + } + taosMemoryFree(pOperator); - pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + pTaskInfo->code = code; return NULL; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 109e402b45..62ac94dd60 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -494,7 +494,13 @@ void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* p SScalarParam srcParam = {.numOfRows = pBlock->info.rows, .param = pMeta, .columnData = &infoData}; SScalarParam param = {.columnData = pColInfoData}; - fpSet.process(&srcParam, 1, ¶m); + + if (fpSet.process != NULL) { + fpSet.process(&srcParam, 1, ¶m); + } else { + qError("failed to get the corresponding callback function, functionId:%d", functionId); + } + colDataDestroy(&infoData); } diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 7ca3de5214..c00b5c4802 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -719,12 +719,16 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SDataBlockDescNode* pDescNode = pPhyNode->pOutputDataBlockDesc; - pInfo->binfo.pRes = createResDataBlock(pDescNode); - int32_t rowSize = pInfo->binfo.pRes->info.rowSize; - if (pInfo == NULL || pOperator == NULL || rowSize > 100 * 1024 * 1024) { + int32_t code = TSDB_CODE_SUCCESS; + if (pInfo == NULL || pOperator == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; goto _error; } + pInfo->binfo.pRes = createResDataBlock(pDescNode); + int32_t rowSize = pInfo->binfo.pRes->info.rowSize; + ASSERT(rowSize < 100 * 1024 * 1024); + SArray* pSortInfo = createSortInfo(pMergePhyNode->pMergeKeys); int32_t numOfOutputCols = 0; SArray* pColMatchColInfo = @@ -737,6 +741,9 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size pInfo->pSortInfo = pSortInfo; pInfo->pColMatchInfo = pColMatchColInfo; pInfo->pInputBlock = pInputBlock; + pInfo->bufPageSize = getProperSortPageSize(rowSize); + pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result. + pOperator->name = "MultiwayMerge"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE; pOperator->blocking = false; @@ -744,15 +751,10 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; - pInfo->bufPageSize = getProperSortPageSize(rowSize); - - // one additional is reserved for merged result. - pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); - pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL, NULL, destroyMultiwayMergeOperatorInfo, NULL, NULL, getMultiwayMergeExplainExecInfo); - int32_t code = appendDownstream(pOperator, downStreams, numStreams); + code = appendDownstream(pOperator, downStreams, numStreams); if (code != TSDB_CODE_SUCCESS) { goto _error; } diff --git a/source/libs/executor/src/tlinearhash.c b/source/libs/executor/src/tlinearhash.c index b133041fdc..4204692514 100644 --- a/source/libs/executor/src/tlinearhash.c +++ b/source/libs/executor/src/tlinearhash.c @@ -251,6 +251,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_ if (!osTempSpaceAvailable()) { terrno = TSDB_CODE_NO_AVAIL_DISK; printf("tHash Init failed since %s", terrstr(terrno)); + taosMemoryFree(pHashObj); return NULL; } diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 03248f5069..7ad5c1365c 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -140,6 +140,7 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSource int32_t* sourceId, SArray* pPageIdList) { SSortSource* pSource = taosMemoryCalloc(1, sizeof(SSortSource)); if (pSource == NULL) { + taosArrayDestroy(pPageIdList); return TSDB_CODE_QRY_OUT_OF_MEMORY; } @@ -155,6 +156,7 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSource int32_t numOfRows = (getBufPageSize(pBuf) - blockDataGetSerialMetaSize(taosArrayGetSize(pBlock->pDataBlock))) / rowSize; ASSERT(numOfRows > 0); + return blockDataEnsureCapacity(pSource->src.pBlock, numOfRows); } @@ -224,6 +226,22 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int int32_t code = 0; + // multi-pass internal merge sort is required + if (pHandle->pBuf == NULL) { + if (!osTempSpaceAvailable()) { + code = TSDB_CODE_NO_AVAIL_DISK; + qError("Sort compare init failed since %s", terrstr(code)); + return code; + } + + code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, + "sortComparInit", tsTempDir); + dBufSetPrintInfo(pHandle->pBuf); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + if (pHandle->type == SORT_SINGLESOURCE_SORT) { for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { SSortSource* pSource = cmpParam->pSources[i]; @@ -245,22 +263,6 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int releaseBufPage(pHandle->pBuf, pPage); } } else { - // multi-pass internal merge sort is required - if (pHandle->pBuf == NULL) { - if (!osTempSpaceAvailable()) { - terrno = TSDB_CODE_NO_AVAIL_DISK; - code = terrno; - qError("Sort compare init failed since %s", terrstr(terrno)); - return code; - } - code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, - "sortComparInit", tsTempDir); - dBufSetPrintInfo(pHandle->pBuf); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { SSortSource* pSource = cmpParam->pSources[i]; pSource->src.pBlock = pHandle->fetchfp(pSource->param); @@ -507,12 +509,14 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { int32_t code = sortComparInit(&pHandle->cmpParam, pHandle->pOrderedSource, i * numOfInputSources, end, pHandle); if (code != TSDB_CODE_SUCCESS) { + taosArrayDestroy(pResList); return code; } code = tMergeTreeCreate(&pHandle->pMergeTree, pHandle->cmpParam.numOfSources, &pHandle->cmpParam, pHandle->comparFn); if (code != TSDB_CODE_SUCCESS) { + taosArrayDestroy(pResList); return code; } @@ -520,12 +524,16 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { while (1) { SSDataBlock* pDataBlock = getSortedBlockDataInner(pHandle, &pHandle->cmpParam, numOfRows); if (pDataBlock == NULL) { + taosArrayDestroy(pResList); + taosArrayDestroy(pPageIdList); break; } int32_t pageId = -1; void* pPage = getNewBufPage(pHandle->pBuf, &pageId); if (pPage == NULL) { + taosArrayDestroy(pResList); + taosArrayDestroy(pPageIdList); return terrno; } From 12e81869bcbf88d209f5eba73b6026da6a7d2d73 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 20 Oct 2022 11:52:30 +0800 Subject: [PATCH 24/25] fix(query): remove invalid free. --- source/dnode/vnode/src/tsdb/tsdbRead.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 6580951ce0..3c727ee63a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -3672,10 +3672,6 @@ void tsdbReaderClose(STsdbReader* pReader) { taosMemoryFree(pLReader); } - if (pReader->innerReader[0] != 0) { - tsdbUntakeReadSnap(pReader->innerReader[0]->pTsdb, pReader->innerReader[0]->pReadSnap, pReader->idStr); - } - tsdbDebug( "%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64 " SMA-time:%.2f ms, fileBlocks:%" PRId64 From 3fcd60e627dbce997fd74ff6bf71ccfe5ac67431 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 20 Oct 2022 12:18:56 +0800 Subject: [PATCH 25/25] fix(query): remove invalid check. --- source/libs/executor/src/executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 4f4b6364e9..19c81aef2b 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -365,7 +365,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, if (handle) { void* pSinkParam = NULL; code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTaskInfo, readHandle); - if (code != TSDB_CODE_SUCCESS || pSinkParam == NULL) { + if (code != TSDB_CODE_SUCCESS) { qError("failed to createDataSinkParam, vgId:%d, code:%s, %s", vgId, tstrerror(code), (*pTask)->id.str); goto _error; }