Merge branch '3.0' into fix/TD-30813-6

This commit is contained in:
Minglei Jin 2024-09-25 09:28:08 +08:00
commit 5951a0ff2b
100 changed files with 1583 additions and 828 deletions

View File

@ -115,7 +115,7 @@ typedef struct {
} SValueColumnCompressInfo; } SValueColumnCompressInfo;
int32_t tValueColumnInit(SValueColumn *valCol); int32_t tValueColumnInit(SValueColumn *valCol);
int32_t tValueColumnDestroy(SValueColumn *valCol); void tValueColumnDestroy(SValueColumn *valCol);
void tValueColumnClear(SValueColumn *valCol); void tValueColumnClear(SValueColumn *valCol);
int32_t tValueColumnAppend(SValueColumn *valCol, const SValue *value); int32_t tValueColumnAppend(SValueColumn *valCol, const SValue *value);
int32_t tValueColumnUpdate(SValueColumn *valCol, int32_t idx, const SValue *value); int32_t tValueColumnUpdate(SValueColumn *valCol, int32_t idx, const SValue *value);

View File

@ -177,7 +177,7 @@ int32_t walRollback(SWal *, int64_t ver);
int32_t walBeginSnapshot(SWal *, int64_t ver, int64_t logRetention); int32_t walBeginSnapshot(SWal *, int64_t ver, int64_t logRetention);
int32_t walEndSnapshot(SWal *); int32_t walEndSnapshot(SWal *);
int32_t walRestoreFromSnapshot(SWal *, int64_t ver); int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
int32_t walApplyVer(SWal *, int64_t ver); void walApplyVer(SWal *, int64_t ver);
// wal reader // wal reader
SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond, int64_t id); SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond, int64_t id);

View File

@ -268,7 +268,7 @@ typedef struct {
uint8_t lvl[3]; // l[0] = 'low', l[1] = 'mid', l[2] = 'high' uint8_t lvl[3]; // l[0] = 'low', l[1] = 'mid', l[2] = 'high'
} TCmprLvlSet; } TCmprLvlSet;
int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level); void tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level);
#define DEFINE_VAR(cmprAlg) \ #define DEFINE_VAR(cmprAlg) \
uint8_t l1 = COMPRESS_L1_TYPE_U32(cmprAlg); \ uint8_t l1 = COMPRESS_L1_TYPE_U32(cmprAlg); \

View File

@ -361,7 +361,7 @@ static void processCreateStb(SMqMetaRsp* metaRsp, cJSON** pJson) {
buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE, &req.colCmpr, pJson); buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE, &req.colCmpr, pJson);
end: end:
uDebug("create stable return, sql json:%s", cJSON_PrintUnformatted(*pJson)); uDebug("create stable return");
tDecoderClear(&coder); tDecoderClear(&coder);
} }
@ -381,7 +381,7 @@ static void processAlterStb(SMqMetaRsp* metaRsp, cJSON** pJson) {
buildAlterSTableJson(req.alterOriData, req.alterOriDataLen, pJson); buildAlterSTableJson(req.alterOriData, req.alterOriDataLen, pJson);
end: end:
uDebug("alter stable return, sql json:%s", cJSON_PrintUnformatted(*pJson)); uDebug("alter stable return");
tDecoderClear(&coder); tDecoderClear(&coder);
} }
@ -393,7 +393,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
int64_t id = pCreateReq->uid; int64_t id = pCreateReq->uid;
uint8_t tagNum = pCreateReq->ctb.tagNum; uint8_t tagNum = pCreateReq->ctb.tagNum;
int32_t code = 0; int32_t code = 0;
cJSON* tags = NULL;
cJSON* tableName = cJSON_CreateString(name); cJSON* tableName = cJSON_CreateString(name);
RAW_NULL_CHECK(tableName); RAW_NULL_CHECK(tableName);
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName)); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
@ -404,7 +404,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
RAW_NULL_CHECK(tagNumJson); RAW_NULL_CHECK(tagNumJson);
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tagNum", tagNumJson)); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tagNum", tagNumJson));
cJSON* tags = cJSON_CreateArray(); tags = cJSON_CreateArray();
RAW_NULL_CHECK(tags); RAW_NULL_CHECK(tags);
SArray* pTagVals = NULL; SArray* pTagVals = NULL;
RAW_RETURN_CHECK(tTagToValArray(pTag, &pTagVals)); RAW_RETURN_CHECK(tTagToValArray(pTag, &pTagVals));
@ -543,7 +543,7 @@ static void processCreateTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
} }
end: end:
uDebug("create table return, sql json:%s", cJSON_PrintUnformatted(*pJson)); uDebug("create table return");
tDeleteSVCreateTbBatchReq(&req); tDeleteSVCreateTbBatchReq(&req);
tDecoderClear(&decoder); tDecoderClear(&decoder);
} }
@ -772,7 +772,7 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
} }
end: end:
uDebug("alter table return, sql json:%s", cJSON_PrintUnformatted(json)); uDebug("alter table return");
tDecoderClear(&decoder); tDecoderClear(&decoder);
*pJson = json; *pJson = json;
} }
@ -807,7 +807,7 @@ static void processDropSTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName)); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
end: end:
uDebug("processDropSTable return, sql json:%s", cJSON_PrintUnformatted(json)); uDebug("processDropSTable return");
tDecoderClear(&decoder); tDecoderClear(&decoder);
*pJson = json; *pJson = json;
} }
@ -843,7 +843,7 @@ static void processDeleteTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", sqlJson)); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", sqlJson));
end: end:
uDebug("processDeleteTable return, sql json:%s", cJSON_PrintUnformatted(json)); uDebug("processDeleteTable return");
tDecoderClear(&coder); tDecoderClear(&coder);
*pJson = json; *pJson = json;
} }
@ -880,7 +880,7 @@ static void processDropTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableNameList", tableNameList)); RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableNameList", tableNameList));
end: end:
uDebug("processDropTable return, json sql:%s", cJSON_PrintUnformatted(json)); uDebug("processDropTable return");
tDecoderClear(&decoder); tDecoderClear(&decoder);
*pJson = json; *pJson = json;
} }
@ -1923,6 +1923,10 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true, err, ERR_MSG_LEN); code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true, err, ERR_MSG_LEN);
taosMemoryFree(fields); taosMemoryFree(fields);
taosMemoryFreeClear(pTableMeta); taosMemoryFreeClear(pTableMeta);
if (pCreateReqDst) {
tdDestroySVCreateTbReq(pCreateReqDst);
taosMemoryFreeClear(pCreateReqDst);
}
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
SET_ERROR_MSG("table:%s, err:%s", tbName, err); SET_ERROR_MSG("table:%s, err:%s", tbName, err);
goto end; goto end;
@ -1944,7 +1948,7 @@ end:
taosMemoryFreeClear(pTableMeta); taosMemoryFreeClear(pTableMeta);
if (pCreateReqDst) { if (pCreateReqDst) {
tdDestroySVCreateTbReq(pCreateReqDst); tdDestroySVCreateTbReq(pCreateReqDst);
taosMemoryFree(pCreateReqDst); taosMemoryFreeClear(pCreateReqDst);
} }
return code; return code;
} }
@ -2038,6 +2042,7 @@ char* tmq_get_json_meta(TAOS_RES* res) {
processSimpleMeta(&pMetaRspObj->metaRsp, &pJson); processSimpleMeta(&pMetaRspObj->metaRsp, &pJson);
char* string = cJSON_PrintUnformatted(pJson); char* string = cJSON_PrintUnformatted(pJson);
cJSON_Delete(pJson); cJSON_Delete(pJson);
uDebug("tmq_get_json_meta string:%s", string);
return string; return string;
} }

View File

@ -32,10 +32,14 @@ static void removeEmptyDir() {
empty = false; empty = false;
} }
if (empty) taosRemoveDir(filename); if (empty) taosRemoveDir(filename);
(void)taosCloseDir(&pDirTmp); if (taosCloseDir(&pDirTmp) != 0) {
uError("[rsync] close dir error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
}
} }
(void)taosCloseDir(&pDir); if (taosCloseDir(&pDir) != 0) {
uError("[rsync] close dir error," ERRNO_ERR_FORMAT, ERRNO_ERR_DATA);
}
} }
#ifdef WINDOWS #ifdef WINDOWS

View File

@ -4171,12 +4171,12 @@ int32_t tValueColumnInit(SValueColumn *valCol) {
return 0; return 0;
} }
int32_t tValueColumnDestroy(SValueColumn *valCol) { void tValueColumnDestroy(SValueColumn *valCol) {
valCol->type = TSDB_DATA_TYPE_NULL; valCol->type = TSDB_DATA_TYPE_NULL;
valCol->numOfValues = 0; valCol->numOfValues = 0;
tBufferDestroy(&valCol->data); tBufferDestroy(&valCol->data);
tBufferDestroy(&valCol->offsets); tBufferDestroy(&valCol->offsets);
return 0; return;
} }
void tValueColumnClear(SValueColumn *valCol) { void tValueColumnClear(SValueColumn *valCol) {

View File

@ -164,6 +164,9 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
if (argc < 2) return 0; if (argc < 2) return 0;
global.envCmd = taosMemoryMalloc((argc - 1) * sizeof(char *)); global.envCmd = taosMemoryMalloc((argc - 1) * sizeof(char *));
if (global.envCmd == NULL) {
return terrno;
}
memset(global.envCmd, 0, (argc - 1) * sizeof(char *)); memset(global.envCmd, 0, (argc - 1) * sizeof(char *));
for (int32_t i = 1; i < argc; ++i) { for (int32_t i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-c") == 0) { if (strcmp(argv[i], "-c") == 0) {

View File

@ -235,7 +235,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pNode->nodePort = pCreate->replicas[pCfg->syncCfg.replicaNum].port; pNode->nodePort = pCreate->replicas[pCfg->syncCfg.replicaNum].port;
pNode->nodeRole = TAOS_SYNC_ROLE_VOTER; pNode->nodeRole = TAOS_SYNC_ROLE_VOTER;
tstrncpy(pNode->nodeFqdn, pCreate->replicas[pCfg->syncCfg.replicaNum].fqdn, TSDB_FQDN_LEN); tstrncpy(pNode->nodeFqdn, pCreate->replicas[pCfg->syncCfg.replicaNum].fqdn, TSDB_FQDN_LEN);
(void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); bool ret = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
pCfg->syncCfg.replicaNum++; pCfg->syncCfg.replicaNum++;
} }
if (pCreate->selfIndex != -1) { if (pCreate->selfIndex != -1) {
@ -247,7 +247,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pNode->nodePort = pCreate->learnerReplicas[pCfg->syncCfg.totalReplicaNum].port; pNode->nodePort = pCreate->learnerReplicas[pCfg->syncCfg.totalReplicaNum].port;
pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER; pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER;
tstrncpy(pNode->nodeFqdn, pCreate->learnerReplicas[pCfg->syncCfg.totalReplicaNum].fqdn, TSDB_FQDN_LEN); tstrncpy(pNode->nodeFqdn, pCreate->learnerReplicas[pCfg->syncCfg.totalReplicaNum].fqdn, TSDB_FQDN_LEN);
(void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); bool ret = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
pCfg->syncCfg.totalReplicaNum++; pCfg->syncCfg.totalReplicaNum++;
} }
pCfg->syncCfg.totalReplicaNum += pCfg->syncCfg.replicaNum; pCfg->syncCfg.totalReplicaNum += pCfg->syncCfg.replicaNum;

View File

@ -150,6 +150,10 @@ int32_t dmReadEps(SDnodeData *pData) {
} }
char *tmp = taosMemoryMalloc(scopeLen + 1); char *tmp = taosMemoryMalloc(scopeLen + 1);
if (tmp == NULL) {
dError("failed to malloc memory for tsEncryptScope:%s", tsEncryptScope);
goto _OVER;
}
memset(tmp, 0, scopeLen + 1); memset(tmp, 0, scopeLen + 1);
memcpy(tmp, tsEncryptScope, scopeLen); memcpy(tmp, tsEncryptScope, scopeLen);

View File

@ -342,6 +342,11 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
int len = ENCRYPTED_LEN(size); int len = ENCRYPTED_LEN(size);
result = taosMemoryMalloc(len); result = taosMemoryMalloc(len);
if (result == NULL) {
code = terrno;
encryptError("failed to alloc memory file:%s since %s", file, tstrerror(code));
goto _OVER;
}
SCryptOpts opts = {0}; SCryptOpts opts = {0};
strncpy(opts.key, key, ENCRYPT_KEY_LEN); strncpy(opts.key, key, ENCRYPT_KEY_LEN);

View File

@ -292,7 +292,7 @@ int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData
int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx); int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx);
// tsdbRead.c ============================================================================================== // tsdbRead.c ==============================================================================================
int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap, const char* id); int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STsdbReadSnap **ppSnap, const char *id);
void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive); void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive);
int32_t tsdbGetTableSchema(SMeta *pMeta, int64_t uid, STSchema **pSchema, int64_t *suid); int32_t tsdbGetTableSchema(SMeta *pMeta, int64_t uid, STSchema **pSchema, int64_t *suid);
@ -1069,6 +1069,13 @@ int32_t tsdbSnapPrepDescription(SVnode *pVnode, SSnapshot *pSnap);
void tsdbRemoveFile(const char *path); void tsdbRemoveFile(const char *path);
#define taosCloseFileWithLog(fd) \
do { \
if (taosCloseFile(fd) < 0) { \
tsdbTrace("failed to close file"); \
} \
} while (0)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -143,7 +143,7 @@ typedef struct STbUidStore STbUidStore;
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback); int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
int metaUpgrade(SVnode* pVnode, SMeta** ppMeta); int metaUpgrade(SVnode* pVnode, SMeta** ppMeta);
int metaClose(SMeta** pMeta); void metaClose(SMeta** pMeta);
int metaBegin(SMeta* pMeta, int8_t fromSys); int metaBegin(SMeta* pMeta, int8_t fromSys);
TXN* metaGetTxn(SMeta* pMeta); TXN* metaGetTxn(SMeta* pMeta);
int metaCommit(SMeta* pMeta, TXN* txn); int metaCommit(SMeta* pMeta, TXN* txn);
@ -207,7 +207,7 @@ int32_t metaGetInfo(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo, SMetaReader* pR
// tsdb // tsdb
int32_t tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback, bool force); int32_t tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback, bool force);
int32_t tsdbClose(STsdb** pTsdb); void tsdbClose(STsdb** pTsdb);
int32_t tsdbBegin(STsdb* pTsdb); int32_t tsdbBegin(STsdb* pTsdb);
// int32_t tsdbPrepareCommit(STsdb* pTsdb); // int32_t tsdbPrepareCommit(STsdb* pTsdb);
// int32_t tsdbCommit(STsdb* pTsdb, SCommitInfo* pInfo); // int32_t tsdbCommit(STsdb* pTsdb, SCommitInfo* pInfo);
@ -284,7 +284,7 @@ int32_t tqProcessTaskConsenChkptIdReq(STQ* pTq, SRpcMsg* pMsg);
int32_t smaInit(); int32_t smaInit();
void smaCleanUp(); void smaCleanUp();
int32_t smaOpen(SVnode* pVnode, int8_t rollback, bool force); int32_t smaOpen(SVnode* pVnode, int8_t rollback, bool force);
int32_t smaClose(SSma* pSma); void smaClose(SSma* pSma);
int32_t smaBegin(SSma* pSma); int32_t smaBegin(SSma* pSma);
int32_t smaPrepareAsyncCommit(SSma* pSma); int32_t smaPrepareAsyncCommit(SSma* pSma);
int32_t smaCommit(SSma* pSma, SCommitInfo* pInfo); int32_t smaCommit(SSma* pSma, SCommitInfo* pInfo);

View File

@ -216,7 +216,7 @@ void metaCacheClose(SMeta* pMeta) {
} }
} }
static int32_t metaRehashCache(SMetaCache* pCache, int8_t expand) { static void metaRehashCache(SMetaCache* pCache, int8_t expand) {
int32_t code = 0; int32_t code = 0;
int32_t nBucket; int32_t nBucket;
@ -228,8 +228,7 @@ static int32_t metaRehashCache(SMetaCache* pCache, int8_t expand) {
SMetaCacheEntry** aBucket = (SMetaCacheEntry**)taosMemoryCalloc(nBucket, sizeof(SMetaCacheEntry*)); SMetaCacheEntry** aBucket = (SMetaCacheEntry**)taosMemoryCalloc(nBucket, sizeof(SMetaCacheEntry*));
if (aBucket == NULL) { if (aBucket == NULL) {
code = terrno; return;
goto _exit;
} }
// rehash // rehash
@ -250,9 +249,7 @@ static int32_t metaRehashCache(SMetaCache* pCache, int8_t expand) {
taosMemoryFree(pCache->sEntryCache.aBucket); taosMemoryFree(pCache->sEntryCache.aBucket);
pCache->sEntryCache.nBucket = nBucket; pCache->sEntryCache.nBucket = nBucket;
pCache->sEntryCache.aBucket = aBucket; pCache->sEntryCache.aBucket = aBucket;
return;
_exit:
return code;
} }
int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) { int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
@ -279,7 +276,7 @@ int32_t metaCacheUpsert(SMeta* pMeta, SMetaInfo* pInfo) {
} }
} else { // insert } else { // insert
if (pCache->sEntryCache.nEntry >= pCache->sEntryCache.nBucket) { if (pCache->sEntryCache.nEntry >= pCache->sEntryCache.nBucket) {
TAOS_UNUSED(metaRehashCache(pCache, 1)); metaRehashCache(pCache, 1);
iBucket = TABS(pInfo->uid) % pCache->sEntryCache.nBucket; iBucket = TABS(pInfo->uid) % pCache->sEntryCache.nBucket;
} }
@ -317,7 +314,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid) {
pCache->sEntryCache.nEntry--; pCache->sEntryCache.nEntry--;
if (pCache->sEntryCache.nEntry < pCache->sEntryCache.nBucket / 4 && if (pCache->sEntryCache.nEntry < pCache->sEntryCache.nBucket / 4 &&
pCache->sEntryCache.nBucket > META_CACHE_BASE_BUCKET) { pCache->sEntryCache.nBucket > META_CACHE_BASE_BUCKET) {
TAOS_UNUSED(metaRehashCache(pCache, 0)); metaRehashCache(pCache, 0);
} }
} else { } else {
code = TSDB_CODE_NOT_FOUND; code = TSDB_CODE_NOT_FOUND;
@ -495,7 +492,7 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv
return terrno; return terrno;
} }
} else { } else {
(void)taosLRUCacheRelease(pCache, pRes, false); bool ret = taosLRUCacheRelease(pCache, pRes, false);
} }
} }
@ -562,7 +559,7 @@ int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pK
((double)(*pEntry)->hitTimes) / acc); ((double)(*pEntry)->hitTimes) / acc);
} }
(void)taosLRUCacheRelease(pCache, pHandle, false); bool ret = taosLRUCacheRelease(pCache, pHandle, false);
// unlock meta // unlock meta
(void)taosThreadMutexUnlock(pLock); (void)taosThreadMutexUnlock(pLock);
@ -618,7 +615,7 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL
p->hitTimes = 0; p->hitTimes = 0;
tdListInit(&p->list, keyLen); tdListInit(&p->list, keyLen);
TAOS_CHECK_RETURN(taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES)); TAOS_CHECK_RETURN(taosHashPut(pTableEntry, &suid, sizeof(uint64_t), &p, POINTER_BYTES));
(void)tdListAppend(&p->list, pKey); TAOS_CHECK_RETURN(tdListAppend(&p->list, pKey));
return 0; return 0;
} }
@ -662,7 +659,10 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int
} else { // check if it exists or not } else { // check if it exists or not
size_t size = listNEles(&(*pEntry)->list); size_t size = listNEles(&(*pEntry)->list);
if (size == 0) { if (size == 0) {
(void)tdListAppend(&(*pEntry)->list, pKey); code = tdListAppend(&(*pEntry)->list, pKey);
if (code) {
goto _end;
}
} else { } else {
SListNode* pNode = listHead(&(*pEntry)->list); SListNode* pNode = listHead(&(*pEntry)->list);
uint64_t* p = (uint64_t*)pNode->data; uint64_t* p = (uint64_t*)pNode->data;
@ -671,7 +671,10 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int
(void)taosThreadMutexUnlock(pLock); (void)taosThreadMutexUnlock(pLock);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { // not equal, append it } else { // not equal, append it
(void)tdListAppend(&(*pEntry)->list, pKey); code = tdListAppend(&(*pEntry)->list, pKey);
if (code) {
goto _end;
}
} }
} }
} }
@ -761,7 +764,7 @@ int32_t metaGetCachedTbGroup(void* pVnode, tb_uid_t suid, const uint8_t* pKey, i
((double)(*pEntry)->hitTimes) / acc); ((double)(*pEntry)->hitTimes) / acc);
} }
(void)taosLRUCacheRelease(pCache, pHandle, false); bool ret = taosLRUCacheRelease(pCache, pHandle, false);
// unlock meta // unlock meta
(void)taosThreadMutexUnlock(pLock); (void)taosThreadMutexUnlock(pLock);
@ -839,7 +842,10 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int
} else { // check if it exists or not } else { // check if it exists or not
size_t size = listNEles(&(*pEntry)->list); size_t size = listNEles(&(*pEntry)->list);
if (size == 0) { if (size == 0) {
(void)tdListAppend(&(*pEntry)->list, pKey); code = tdListAppend(&(*pEntry)->list, pKey);
if (code) {
goto _end;
}
} else { } else {
SListNode* pNode = listHead(&(*pEntry)->list); SListNode* pNode = listHead(&(*pEntry)->list);
uint64_t* p = (uint64_t*)pNode->data; uint64_t* p = (uint64_t*)pNode->data;
@ -848,7 +854,10 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int
(void)taosThreadMutexUnlock(pLock); (void)taosThreadMutexUnlock(pLock);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { // not equal, append it } else { // not equal, append it
(void)tdListAppend(&(*pEntry)->list, pKey); code = tdListAppend(&(*pEntry)->list, pKey);
if (code) {
goto _end;
}
} }
} }
} }

View File

@ -66,7 +66,10 @@ int metaPrepareAsyncCommit(SMeta *pMeta) {
int32_t lino; int32_t lino;
metaWLock(pMeta); metaWLock(pMeta);
TAOS_UNUSED(ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn)); int32_t ret = ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn);
if (ret < 0) {
metaError("vgId:%d, failed to flush ttl since %s", TD_VID(pMeta->pVnode), tstrerror(ret));
}
metaULock(pMeta); metaULock(pMeta);
code = tdbCommit(pMeta->pEnv, pMeta->txn); code = tdbCommit(pMeta->pEnv, pMeta->txn);

View File

@ -60,12 +60,13 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
pMeta->path = (char *)&pMeta[1]; pMeta->path = (char *)&pMeta[1];
strcpy(pMeta->path, path); strcpy(pMeta->path, path);
(void)taosRealPath(pMeta->path, NULL, strlen(path) + 1); int32_t ret = taosRealPath(pMeta->path, NULL, strlen(path) + 1);
pMeta->pVnode = pVnode; pMeta->pVnode = pVnode;
// create path if not created yet // create path if not created yet
(void)taosMkDir(pMeta->path); code = taosMkDir(pMeta->path);
TSDB_CHECK_CODE(code, lino, _exit);
// open env // open env
code = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback, code = tdbOpen(pMeta->path, pVnode->config.szPage, pVnode->config.szCache, &pMeta->pEnv, rollback,
@ -97,7 +98,7 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
sprintf(indexFullPath, "%s/%s", pMeta->path, "invert"); sprintf(indexFullPath, "%s/%s", pMeta->path, "invert");
TAOS_UNUSED(taosMkDir(indexFullPath)); ret = taosMkDir(indexFullPath);
SIndexOpts opts = {.cacheSize = 8 * 1024 * 1024}; SIndexOpts opts = {.cacheSize = 8 * 1024 * 1024};
code = indexOpen(&opts, indexFullPath, (SIndex **)&pMeta->pTagIvtIdx); code = indexOpen(&opts, indexFullPath, (SIndex **)&pMeta->pTagIvtIdx);
@ -169,9 +170,9 @@ _exit:
return code; return code;
} }
int metaClose(SMeta **ppMeta) { void metaClose(SMeta **ppMeta) {
metaCleanup(ppMeta); metaCleanup(ppMeta);
return 0; return;
} }
int metaAlterCache(SMeta *pMeta, int32_t nPage) { int metaAlterCache(SMeta *pMeta, int32_t nPage) {

View File

@ -87,7 +87,9 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
if (key.version < pReader->sver // if (key.version < pReader->sver //
|| metaGetInfo(pReader->pMeta, key.uid, &info, NULL) == TSDB_CODE_NOT_FOUND) { || metaGetInfo(pReader->pMeta, key.uid, &info, NULL) == TSDB_CODE_NOT_FOUND) {
(void)tdbTbcMoveToNext(pReader->pTbc); if (tdbTbcMoveToNext(pReader->pTbc) != 0) {
metaTrace("vgId:%d, vnode snapshot meta read data done", TD_VID(pReader->pMeta->pVnode));
}
continue; continue;
} }
@ -110,7 +112,9 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d", metaDebug("vgId:%d, vnode snapshot meta read data, version:%" PRId64 " uid:%" PRId64 " blockLen:%d",
TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData); TD_VID(pReader->pMeta->pVnode), key.version, key.uid, nData);
(void)tdbTbcMoveToNext(pReader->pTbc); if (tdbTbcMoveToNext(pReader->pTbc) != 0) {
metaTrace("vgId:%d, vnode snapshot meta read data done", TD_VID(pReader->pMeta->pVnode));
}
break; break;
} }
@ -233,7 +237,9 @@ static int32_t MoveToSnapShotVersion(SSnapContext* ctx) {
return TAOS_GET_TERRNO(code); return TAOS_GET_TERRNO(code);
} }
if (c < 0) { if (c < 0) {
(void)tdbTbcMoveToPrev((TBC*)ctx->pCur); if (tdbTbcMoveToPrev((TBC*)ctx->pCur) != 0) {
metaTrace("vgId:%d, vnode snapshot move to prev failed", TD_VID(ctx->pMeta->pVnode));
}
} }
return 0; return 0;
} }

View File

@ -22,7 +22,7 @@ static int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, con
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME); static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME);
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME);
static int metaUpdateTtl(SMeta *pMeta, const SMetaEntry *pME); static void metaUpdateTtl(SMeta *pMeta, const SMetaEntry *pME);
static int metaUpdateChangeTime(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs); static int metaUpdateChangeTime(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs);
static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME); static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME);
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME);
@ -285,7 +285,9 @@ static inline void metaTimeSeriesNotifyCheck(SMeta *pMeta) {
int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries; int64_t deltaTS = nTimeSeries - pMeta->pVnode->config.vndStats.numOfReportedTimeSeries;
if (deltaTS > tsTimeSeriesThreshold) { if (deltaTS > tsTimeSeriesThreshold) {
if (0 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) { if (0 == atomic_val_compare_exchange_8(&dmNotifyHdl.state, 1, 2)) {
(void)tsem_post(&dmNotifyHdl.sem); if (tsem_post(&dmNotifyHdl.sem) != 0) {
metaError("vgId:%d, failed to post semaphore, errno:%d", TD_VID(pMeta->pVnode), errno);
}
} }
} }
#endif #endif
@ -1441,8 +1443,8 @@ static int metaBuildNColIdxKey(SNcolIdxKey *ncolKey, const SMetaEntry *pME) {
return 0; return 0;
} }
static int metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) { static void metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) {
if (pME->type != TSDB_CHILD_TABLE && pME->type != TSDB_NORMAL_TABLE) return 0; if (pME->type != TSDB_CHILD_TABLE && pME->type != TSDB_NORMAL_TABLE) return;
STtlDelTtlCtx ctx = {.uid = pME->uid, .pTxn = pMeta->txn}; STtlDelTtlCtx ctx = {.uid = pME->uid, .pTxn = pMeta->txn};
if (pME->type == TSDB_CHILD_TABLE) { if (pME->type == TSDB_CHILD_TABLE) {
@ -1451,7 +1453,12 @@ static int metaDeleteTtl(SMeta *pMeta, const SMetaEntry *pME) {
ctx.ttlDays = pME->ntbEntry.ttlDays; ctx.ttlDays = pME->ntbEntry.ttlDays;
} }
return ttlMgrDeleteTtl(pMeta->pTtlMgr, &ctx); int32_t ret = ttlMgrDeleteTtl(pMeta->pTtlMgr, &ctx);
if (ret < 0) {
metaError("vgId:%d, failed to delete ttl for table:%s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pME->name,
pME->uid, tstrerror(ret));
}
return;
} }
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl) { static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type, tb_uid_t *pSuid, int8_t *pSysTbl) {
@ -1831,12 +1838,19 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
int16_t cid = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].colId; int16_t cid = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].colId;
int8_t col_type = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].type; int8_t col_type = pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1].type;
(void)tsdbCacheNewNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type); int32_t ret = tsdbCacheNewNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, col_type);
if (ret < 0) {
terrno = ret;
goto _err;
}
} }
SSchema *pCol = &pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1]; SSchema *pCol = &pSchema->pSchema[entry.ntbEntry.schemaRow.nCols - 1];
uint32_t compress = pAlterTbReq->action == TSDB_ALTER_TABLE_ADD_COLUMN ? createDefaultColCmprByType(pCol->type) uint32_t compress = pAlterTbReq->action == TSDB_ALTER_TABLE_ADD_COLUMN ? createDefaultColCmprByType(pCol->type)
: pAlterTbReq->compress; : pAlterTbReq->compress;
(void)updataTableColCmpr(&entry.colCmpr, pCol, 1, compress); if (updataTableColCmpr(&entry.colCmpr, pCol, 1, compress) != 0) {
metaError("vgId:%d, failed to update table col cmpr:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name,
entry.uid);
}
freeColCmpr = true; freeColCmpr = true;
if (entry.colCmpr.nCols != pSchema->nCols) { if (entry.colCmpr.nCols != pSchema->nCols) {
if (pNewSchema) taosMemoryFree(pNewSchema); if (pNewSchema) taosMemoryFree(pNewSchema);
@ -1876,10 +1890,16 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
int16_t cid = pColumn->colId; int16_t cid = pColumn->colId;
(void)tsdbCacheDropNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, hasPrimayKey); if (tsdbCacheDropNTableColumn(pMeta->pVnode->pTsdb, entry.uid, cid, hasPrimayKey) != 0) {
metaError("vgId:%d, failed to drop ntable column:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name,
entry.uid);
}
} }
(void)updataTableColCmpr(&entry.colCmpr, &tScheam, 0, 0); if (updataTableColCmpr(&entry.colCmpr, &tScheam, 0, 0) != 0) {
metaError("vgId:%d, failed to update table col cmpr:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name,
entry.uid);
}
if (entry.colCmpr.nCols != pSchema->nCols) { if (entry.colCmpr.nCols != pSchema->nCols) {
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION; terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
goto _err; goto _err;
@ -1928,20 +1948,36 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
// do actual write // do actual write
metaWLock(pMeta); metaWLock(pMeta);
(void)metaDeleteNcolIdx(pMeta, &oldEntry); if (metaDeleteNcolIdx(pMeta, &oldEntry) < 0) {
(void)metaUpdateNcolIdx(pMeta, &entry); metaError("vgId:%d, failed to delete ncol idx:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
if (metaUpdateNcolIdx(pMeta, &entry) < 0) {
metaError("vgId:%d, failed to update ncol idx:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
// save to table db // save to table db
(void)metaSaveToTbDb(pMeta, &entry); if (metaSaveToTbDb(pMeta, &entry) < 0) {
metaError("vgId:%d, failed to save to tb db:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
(void)metaUpdateUidIdx(pMeta, &entry); if (metaUpdateUidIdx(pMeta, &entry) < 0) {
metaError("vgId:%d, failed to update uid idx:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
(void)metaSaveToSkmDb(pMeta, &entry); if (metaSaveToSkmDb(pMeta, &entry) < 0) {
metaError("vgId:%d, failed to save to skm db:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
(void)metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs); if (metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs) < 0) {
metaError("vgId:%d, failed to update change time:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
metaULock(pMeta); metaULock(pMeta);
(void)metaUpdateMetaRsp(uid, pAlterTbReq->tbName, pSchema, pMetaRsp); if (metaUpdateMetaRsp(uid, pAlterTbReq->tbName, pSchema, pMetaRsp) < 0) {
metaError("vgId:%d, failed to update meta rsp:%s uid:%" PRId64, TD_VID(pMeta->pVnode), entry.name, entry.uid);
}
for (int32_t i = 0; i < entry.colCmpr.nCols; i++) { for (int32_t i = 0; i < entry.colCmpr.nCols; i++) {
SColCmpr *p = &entry.colCmpr.pColCmpr[i]; SColCmpr *p = &entry.colCmpr.pColCmpr[i];
pMetaRsp->pSchemaExt[i].colId = p->id; pMetaRsp->pSchemaExt[i].colId = p->id;
@ -1997,14 +2033,18 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
TBC *pUidIdxc = NULL; TBC *pUidIdxc = NULL;
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL)); TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); if (tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c) < 0) {
metaTrace("meta/table: failed to move to uid index, uid:%" PRId64, uid);
}
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c); metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST; return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
} }
(void)tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); if (tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData) != 0) {
metaError("meta/table: failed to get uid index, uid:%" PRId64, uid);
}
oversion = ((SUidIdxVal *)pData)[0].version; oversion = ((SUidIdxVal *)pData)[0].version;
// search table.db // search table.db
@ -2014,7 +2054,9 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
/* get ctbEntry */ /* get ctbEntry */
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL)); TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); if (tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c) != 0) {
metaError("meta/table: failed to move to tb db, uid:%" PRId64, uid);
}
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc); tdbTbcClose(pTbDbc);
@ -2022,29 +2064,43 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST; return terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
} }
(void)tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); if (tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData) != 0) {
metaError("meta/table: failed to get tb db, uid:%" PRId64, uid);
}
if ((ctbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) { if ((ctbEntry.pBuf = taosMemoryMalloc(nData)) == NULL) {
(void)tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
(void)tdbTbcClose(pTbDbc); tdbTbcClose(pTbDbc);
return terrno; return terrno;
} }
memcpy(ctbEntry.pBuf, pData, nData); memcpy(ctbEntry.pBuf, pData, nData);
tDecoderInit(&dc1, ctbEntry.pBuf, nData); tDecoderInit(&dc1, ctbEntry.pBuf, nData);
(void)metaDecodeEntry(&dc1, &ctbEntry); ret = metaDecodeEntry(&dc1, &ctbEntry);
if (ret < 0) {
terrno = ret;
goto _err;
}
/* get stbEntry*/ /* get stbEntry*/
(void)tdbTbGet(pMeta->pUidIdx, &ctbEntry.ctbEntry.suid, sizeof(tb_uid_t), &pVal, &nVal); if (tdbTbGet(pMeta->pUidIdx, &ctbEntry.ctbEntry.suid, sizeof(tb_uid_t), &pVal, &nVal) != 0) {
metaError("meta/table: failed to get uid index, uid:%" PRId64, ctbEntry.ctbEntry.suid);
}
if (!pVal) { if (!pVal) {
terrno = TSDB_CODE_INVALID_MSG; terrno = TSDB_CODE_INVALID_MSG;
goto _err; goto _err;
} }
(void)tdbTbGet(pMeta->pTbDb, &((STbDbKey){.uid = ctbEntry.ctbEntry.suid, .version = ((SUidIdxVal *)pVal)[0].version}), if (tdbTbGet(pMeta->pTbDb, &((STbDbKey){.uid = ctbEntry.ctbEntry.suid, .version = ((SUidIdxVal *)pVal)[0].version}),
sizeof(STbDbKey), (void **)&stbEntry.pBuf, &nVal); sizeof(STbDbKey), (void **)&stbEntry.pBuf, &nVal) != 0) {
metaError("meta/table: failed to get tb db, uid:%" PRId64, ctbEntry.ctbEntry.suid);
}
tdbFree(pVal); tdbFree(pVal);
tDecoderInit(&dc2, stbEntry.pBuf, nVal); tDecoderInit(&dc2, stbEntry.pBuf, nVal);
(void)metaDecodeEntry(&dc2, &stbEntry); ret = metaDecodeEntry(&dc2, &stbEntry);
if (ret < 0) {
terrno = ret;
goto _err;
}
SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag; SSchemaWrapper *pTagSchema = &stbEntry.stbEntry.schemaTag;
SSchema *pColumn = NULL; SSchema *pColumn = NULL;
@ -2122,12 +2178,18 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
metaWLock(pMeta); metaWLock(pMeta);
// save to table.db // save to table.db
(void)metaSaveToTbDb(pMeta, &ctbEntry); if (metaSaveToTbDb(pMeta, &ctbEntry) < 0) {
metaError("meta/table: failed to save to tb db:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
// save to uid.idx // save to uid.idx
(void)metaUpdateUidIdx(pMeta, &ctbEntry); if (metaUpdateUidIdx(pMeta, &ctbEntry) < 0) {
metaError("meta/table: failed to update uid idx:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
(void)metaUpdateTagIdx(pMeta, &ctbEntry); if (metaUpdateTagIdx(pMeta, &ctbEntry) < 0) {
metaError("meta/table: failed to update tag idx:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
if (NULL == ctbEntry.ctbEntry.pTags) { if (NULL == ctbEntry.ctbEntry.pTags) {
metaError("meta/table: null tags, update tag val failed."); metaError("meta/table: null tags, update tag val failed.");
@ -2135,13 +2197,22 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
} }
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid}; SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
(void)tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, if (tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn); ((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn) < 0) {
metaError("meta/table: failed to upsert ctb idx:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
(void)metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid); if (metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid) < 0) {
(void)metaTbGroupCacheClear(pMeta, ctbEntry.ctbEntry.suid); metaError("meta/table: failed to clear uid cache:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
(void)metaUpdateChangeTime(pMeta, ctbEntry.uid, pAlterTbReq->ctimeMs); if (metaTbGroupCacheClear(pMeta, ctbEntry.ctbEntry.suid) < 0) {
metaError("meta/table: failed to clear group cache:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
if (metaUpdateChangeTime(pMeta, ctbEntry.uid, pAlterTbReq->ctimeMs) < 0) {
metaError("meta/table: failed to update change time:%s uid:%" PRId64, ctbEntry.name, ctbEntry.uid);
}
metaULock(pMeta); metaULock(pMeta);
@ -2189,21 +2260,27 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
TBC *pUidIdxc = NULL; TBC *pUidIdxc = NULL;
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL)); TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL));
(void)tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); if (tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c) < 0) {
metaError("meta/table: failed to move to uid index, uid:%" PRId64, uid);
}
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c); metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
(void)tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); if (tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData) < 0) {
metaError("meta/table: failed to get uid index, uid:%" PRId64, uid);
}
oversion = ((SUidIdxVal *)pData)[0].version; oversion = ((SUidIdxVal *)pData)[0].version;
// search table.db // search table.db
TBC *pTbDbc = NULL; TBC *pTbDbc = NULL;
TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL)); TAOS_CHECK_RETURN(tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL));
(void)tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); if (tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c) < 0) {
metaError("meta/table: failed to move to tb db, uid:%" PRId64, uid);
}
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc); tdbTbcClose(pTbDbc);
@ -2211,13 +2288,15 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
(void)tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); if (tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData) < 0) {
metaError("meta/table: failed to get tb db, uid:%" PRId64, uid);
}
// get table entry // get table entry
SDecoder dc = {0}; SDecoder dc = {0};
if ((entry.pBuf = taosMemoryMalloc(nData)) == NULL) { if ((entry.pBuf = taosMemoryMalloc(nData)) == NULL) {
(void)tdbTbcClose(pUidIdxc); tdbTbcClose(pUidIdxc);
(void)tdbTbcClose(pTbDbc); tdbTbcClose(pTbDbc);
return terrno; return terrno;
} }
memcpy(entry.pBuf, pData, nData); memcpy(entry.pBuf, pData, nData);
@ -2236,9 +2315,9 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
// build SMetaEntry // build SMetaEntry
if (entry.type == TSDB_CHILD_TABLE) { if (entry.type == TSDB_CHILD_TABLE) {
if (pAlterTbReq->updateTTL) { if (pAlterTbReq->updateTTL) {
(void)metaDeleteTtl(pMeta, &entry); metaDeleteTtl(pMeta, &entry);
entry.ctbEntry.ttlDays = pAlterTbReq->newTTL; entry.ctbEntry.ttlDays = pAlterTbReq->newTTL;
(void)metaUpdateTtl(pMeta, &entry); metaUpdateTtl(pMeta, &entry);
} }
if (pAlterTbReq->newCommentLen >= 0) { if (pAlterTbReq->newCommentLen >= 0) {
entry.ctbEntry.commentLen = pAlterTbReq->newCommentLen; entry.ctbEntry.commentLen = pAlterTbReq->newCommentLen;
@ -2246,9 +2325,9 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
} }
} else { } else {
if (pAlterTbReq->updateTTL) { if (pAlterTbReq->updateTTL) {
(void)metaDeleteTtl(pMeta, &entry); metaDeleteTtl(pMeta, &entry);
entry.ntbEntry.ttlDays = pAlterTbReq->newTTL; entry.ntbEntry.ttlDays = pAlterTbReq->newTTL;
(void)metaUpdateTtl(pMeta, &entry); metaUpdateTtl(pMeta, &entry);
} }
if (pAlterTbReq->newCommentLen >= 0) { if (pAlterTbReq->newCommentLen >= 0) {
entry.ntbEntry.commentLen = pAlterTbReq->newCommentLen; entry.ntbEntry.commentLen = pAlterTbReq->newCommentLen;
@ -2257,9 +2336,17 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
} }
// save to table db // save to table db
(void)metaSaveToTbDb(pMeta, &entry); if (metaSaveToTbDb(pMeta, &entry) < 0) {
(void)metaUpdateUidIdx(pMeta, &entry); metaError("meta/table: failed to save to tb db:%s uid:%" PRId64, entry.name, entry.uid);
(void)metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs); }
if (metaUpdateUidIdx(pMeta, &entry) < 0) {
metaError("meta/table: failed to update uid idx:%s uid:%" PRId64, entry.name, entry.uid);
}
if (metaUpdateChangeTime(pMeta, entry.uid, pAlterTbReq->ctimeMs) < 0) {
metaError("meta/table: failed to update change time:%s uid:%" PRId64, entry.name, entry.uid);
}
metaULock(pMeta); metaULock(pMeta);
@ -2305,7 +2392,10 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
STbDbKey tbDbKey = {0}; STbDbKey tbDbKey = {0};
tbDbKey.uid = suid; tbDbKey.uid = suid;
tbDbKey.version = ((SUidIdxVal *)pVal)[0].version; tbDbKey.version = ((SUidIdxVal *)pVal)[0].version;
(void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal); ret = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal);
if (ret < 0) {
goto _err;
}
tDecoderInit(&dc, pVal, nVal); tDecoderInit(&dc, pVal, nVal);
ret = metaDecodeEntry(&dc, &stbEntry); ret = metaDecodeEntry(&dc, &stbEntry);
if (ret < 0) { if (ret < 0) {
@ -2384,7 +2474,10 @@ static int metaAddTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTb
tdbTbcClose(pCtbIdxc); tdbTbcClose(pCtbIdxc);
goto _err; goto _err;
} }
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); ret = tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
if (ret < 0) {
metaError("meta/table: failed to upsert tag idx:%s uid:%" PRId64, stbEntry.name, stbEntry.uid);
}
metaDestroyTagIdxKey(pTagIdxKey); metaDestroyTagIdxKey(pTagIdxKey);
pTagIdxKey = NULL; pTagIdxKey = NULL;
} }
@ -2439,7 +2532,10 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
STbDbKey tbDbKey = {0}; STbDbKey tbDbKey = {0};
tbDbKey.uid = suid; tbDbKey.uid = suid;
tbDbKey.version = ((SUidIdxVal *)pVal)[0].version; tbDbKey.version = ((SUidIdxVal *)pVal)[0].version;
(void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal); ret = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pVal, &nVal);
if (ret < 0) {
goto _err;
}
tDecoderInit(&dc, pVal, nVal); tDecoderInit(&dc, pVal, nVal);
ret = metaDecodeEntry(&dc, &stbEntry); ret = metaDecodeEntry(&dc, &stbEntry);
@ -2507,7 +2603,10 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
metaWLock(pMeta); metaWLock(pMeta);
for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) { for (int i = 0; i < taosArrayGetSize(tagIdxList); i++) {
SMetaPair *pair = taosArrayGet(tagIdxList, i); SMetaPair *pair = taosArrayGet(tagIdxList, i);
(void)tdbTbDelete(pMeta->pTagIdx, pair->key, pair->nkey, pMeta->txn); ret = tdbTbDelete(pMeta->pTagIdx, pair->key, pair->nkey, pMeta->txn);
if (ret < 0) {
metaError("meta/table: failed to delete tag idx:%s uid:%" PRId64, stbEntry.name, stbEntry.uid);
}
} }
metaULock(pMeta); metaULock(pMeta);
@ -2594,9 +2693,17 @@ int32_t metaUpdateTableColCompress(SMeta *pMeta, int64_t version, SVAlterTbReq *
tbEntry.version = version; tbEntry.version = version;
metaWLock(pMeta); metaWLock(pMeta);
(void)metaSaveToTbDb(pMeta, &tbEntry); if (metaSaveToTbDb(pMeta, &tbEntry) < 0) {
(void)metaUpdateUidIdx(pMeta, &tbEntry); metaError("meta/table: failed to save to tb db:%s uid:%" PRId64, tbEntry.name, tbEntry.uid);
(void)metaUpdateChangeTime(pMeta, suid, pReq->ctimeMs); }
if (metaUpdateUidIdx(pMeta, &tbEntry) < 0) {
metaError("meta/table: failed to update uid idx:%s uid:%" PRId64, tbEntry.name, tbEntry.uid);
}
if (metaUpdateChangeTime(pMeta, suid, pReq->ctimeMs) < 0) {
metaError("meta/table: failed to update change time:%s uid:%" PRId64, tbEntry.name, tbEntry.uid);
}
metaULock(pMeta); metaULock(pMeta);
@ -2691,7 +2798,10 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
// upsert cache // upsert cache
SMetaInfo info; SMetaInfo info;
metaGetEntryInfo(pME, &info); metaGetEntryInfo(pME, &info);
(void)metaCacheUpsert(pMeta, &info); int32_t ret = metaCacheUpsert(pMeta, &info);
if (ret < 0) {
metaError("vgId:%d, failed to upsert cache, uid: %" PRId64 " %s", TD_VID(pMeta->pVnode), pME->uid, tstrerror(ret));
}
SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer}; SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer};
@ -2706,8 +2816,8 @@ static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
return tdbTbUpsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn); return tdbTbUpsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
} }
static int metaUpdateTtl(SMeta *pMeta, const SMetaEntry *pME) { static void metaUpdateTtl(SMeta *pMeta, const SMetaEntry *pME) {
if (pME->type != TSDB_CHILD_TABLE && pME->type != TSDB_NORMAL_TABLE) return 0; if (pME->type != TSDB_CHILD_TABLE && pME->type != TSDB_NORMAL_TABLE) return;
STtlUpdTtlCtx ctx = {.uid = pME->uid, .pTxn = pMeta->txn}; STtlUpdTtlCtx ctx = {.uid = pME->uid, .pTxn = pMeta->txn};
if (pME->type == TSDB_CHILD_TABLE) { if (pME->type == TSDB_CHILD_TABLE) {
@ -2718,7 +2828,12 @@ static int metaUpdateTtl(SMeta *pMeta, const SMetaEntry *pME) {
ctx.changeTimeMs = pME->ntbEntry.btime; ctx.changeTimeMs = pME->ntbEntry.btime;
} }
return ttlMgrInsertTtl(pMeta->pTtlMgr, &ctx); int32_t ret = ttlMgrInsertTtl(pMeta->pTtlMgr, &ctx);
if (ret < 0) {
metaError("vgId:%d, failed to insert ttl, uid: %" PRId64 " %s", TD_VID(pMeta->pVnode), pME->uid, tstrerror(ret));
}
return;
} }
static int metaUpdateChangeTime(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs) { static int metaUpdateChangeTime(SMeta *pMeta, tb_uid_t uid, int64_t changeTimeMs) {
@ -2806,7 +2921,11 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
} }
tbDbKey.uid = pCtbEntry->ctbEntry.suid; tbDbKey.uid = pCtbEntry->ctbEntry.suid;
tbDbKey.version = ((SUidIdxVal *)pData)[0].version; tbDbKey.version = ((SUidIdxVal *)pData)[0].version;
(void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); ret = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData);
if (ret < 0) {
metaError("vgId:%d, failed to get stable for update. version:%" PRId64, TD_VID(pMeta->pVnode), pCtbEntry->version);
goto end;
}
tDecoderInit(&dc, pData, nData); tDecoderInit(&dc, pData, nData);
ret = metaDecodeEntry(&dc, &stbEntry); ret = metaDecodeEntry(&dc, &stbEntry);
@ -2854,7 +2973,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
ret = -1; ret = -1;
goto end; goto end;
} }
(void)tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); if (tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn) < 0) {
metaError("vgId:%d, failed to update tag index. version:%" PRId64, TD_VID(pMeta->pVnode), pCtbEntry->version);
}
metaDestroyTagIdxKey(pTagIdxKey); metaDestroyTagIdxKey(pTagIdxKey);
pTagIdxKey = NULL; pTagIdxKey = NULL;
} }
@ -2905,7 +3026,11 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
} }
tEncoderInit(&coder, pVal, vLen); tEncoderInit(&coder, pVal, vLen);
(void)tEncodeSSchemaWrapper(&coder, pSW); ret = tEncodeSSchemaWrapper(&coder, pSW);
if (ret < 0) {
rcode = -1;
goto _exit;
}
if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, pMeta->txn) < 0) { if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, pMeta->txn) < 0) {
rcode = -1; rcode = -1;
@ -2966,8 +3091,7 @@ int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
} }
if (pME->type != TSDB_SUPER_TABLE) { if (pME->type != TSDB_SUPER_TABLE) {
code = metaUpdateTtl(pMeta, pME); metaUpdateTtl(pMeta, pME);
VND_CHECK_CODE(code, line, _err);
} }
if (pME->type == TSDB_SUPER_TABLE || pME->type == TSDB_NORMAL_TABLE) { if (pME->type == TSDB_SUPER_TABLE || pME->type == TSDB_NORMAL_TABLE) {
@ -2985,7 +3109,7 @@ _err:
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
int32_t colCompressDebug(SHashObj *pColCmprObj) { static void colCompressDebug(SHashObj *pColCmprObj) {
void *p = taosHashIterate(pColCmprObj, NULL); void *p = taosHashIterate(pColCmprObj, NULL);
while (p) { while (p) {
uint32_t cmprAlg = *(uint32_t *)p; uint32_t cmprAlg = *(uint32_t *)p;
@ -2993,14 +3117,14 @@ int32_t colCompressDebug(SHashObj *pColCmprObj) {
p = taosHashIterate(pColCmprObj, p); p = taosHashIterate(pColCmprObj, p);
uint8_t l1, l2, lvl; uint8_t l1, l2, lvl;
(void)tcompressDebug(cmprAlg, &l1, &l2, &lvl); tcompressDebug(cmprAlg, &l1, &l2, &lvl);
const char *l1str = columnEncodeStr(l1); const char *l1str = columnEncodeStr(l1);
const char *l2str = columnCompressStr(l2); const char *l2str = columnCompressStr(l2);
const char *lvlstr = columnLevelStr(lvl); const char *lvlstr = columnLevelStr(lvl);
metaDebug("colId: %d, encode:%s, compress:%s,level:%s", colId, l1str, l2str, lvlstr); metaDebug("colId: %d, encode:%s, compress:%s,level:%s", colId, l1str, l2str, lvlstr);
} }
return 0; return;
} }
int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) { int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
int rc = 0; int rc = 0;
@ -3063,7 +3187,7 @@ int32_t metaGetColCmpr(SMeta *pMeta, tb_uid_t uid, SHashObj **ppColCmprObj) {
metaULock(pMeta); metaULock(pMeta);
*ppColCmprObj = pColCmprObj; *ppColCmprObj = pColCmprObj;
(void)colCompressDebug(pColCmprObj); colCompressDebug(pColCmprObj);
return 0; return 0;
} }

View File

@ -144,7 +144,7 @@ static void ttlMgrCleanup(STtlManger *pTtlMgr) {
taosMemoryFree(pTtlMgr->logPrefix); taosMemoryFree(pTtlMgr->logPrefix);
taosHashCleanup(pTtlMgr->pTtlCache); taosHashCleanup(pTtlMgr->pTtlCache);
taosHashCleanup(pTtlMgr->pDirtyUids); taosHashCleanup(pTtlMgr->pDirtyUids);
(void)tdbTbClose(pTtlMgr->pTtlIdx); tdbTbClose(pTtlMgr->pTtlIdx);
taosMemoryFree(pTtlMgr); taosMemoryFree(pTtlMgr);
} }
@ -302,7 +302,10 @@ int32_t ttlMgrInsertTtl(STtlManger *pTtlMgr, const STtlUpdTtlCtx *updCtx) {
} }
if (ttlMgrNeedFlush(pTtlMgr)) { if (ttlMgrNeedFlush(pTtlMgr)) {
(void)ttlMgrFlush(pTtlMgr, updCtx->pTxn); int32_t ret = ttlMgrFlush(pTtlMgr, updCtx->pTxn);
if (ret < 0) {
metaError("%s, ttlMgr insert failed to flush since %s", pTtlMgr->logPrefix, tstrerror(ret));
}
} }
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;
@ -326,7 +329,10 @@ int32_t ttlMgrDeleteTtl(STtlManger *pTtlMgr, const STtlDelTtlCtx *delCtx) {
} }
if (ttlMgrNeedFlush(pTtlMgr)) { if (ttlMgrNeedFlush(pTtlMgr)) {
(void)ttlMgrFlush(pTtlMgr, delCtx->pTxn); int32_t ret = ttlMgrFlush(pTtlMgr, delCtx->pTxn);
if (ret < 0) {
metaError("%s, ttlMgr del failed to flush since %s", pTtlMgr->logPrefix, tstrerror(ret));
}
} }
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;
@ -350,7 +356,8 @@ int32_t ttlMgrUpdateChangeTime(STtlManger *pTtlMgr, const STtlUpdCtimeCtx *pUpdC
.changeTimeMsDirty = pUpdCtimeCtx->changeTimeMs}; .changeTimeMsDirty = pUpdCtimeCtx->changeTimeMs};
STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_UPSERT}; STtlDirtyEntry dirtryEntry = {.type = ENTRY_TYPE_UPSERT};
code = taosHashPut(pTtlMgr->pTtlCache, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &cacheEntry, sizeof(cacheEntry)); code =
taosHashPut(pTtlMgr->pTtlCache, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &cacheEntry, sizeof(cacheEntry));
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
metaError("%s, ttlMgr update ctime failed to update cache since %s", pTtlMgr->logPrefix, tstrerror(code)); metaError("%s, ttlMgr update ctime failed to update cache since %s", pTtlMgr->logPrefix, tstrerror(code));
goto _out; goto _out;
@ -359,13 +366,15 @@ int32_t ttlMgrUpdateChangeTime(STtlManger *pTtlMgr, const STtlUpdCtimeCtx *pUpdC
code = taosHashPut(pTtlMgr->pDirtyUids, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &dirtryEntry, code = taosHashPut(pTtlMgr->pDirtyUids, &pUpdCtimeCtx->uid, sizeof(pUpdCtimeCtx->uid), &dirtryEntry,
sizeof(dirtryEntry)); sizeof(dirtryEntry));
if (TSDB_CODE_SUCCESS != code) { if (TSDB_CODE_SUCCESS != code) {
metaError("%s, ttlMgr update ctime failed to update dirty uids since %s", pTtlMgr->logPrefix, metaError("%s, ttlMgr update ctime failed to update dirty uids since %s", pTtlMgr->logPrefix, tstrerror(code));
tstrerror(code));
goto _out; goto _out;
} }
if (ttlMgrNeedFlush(pTtlMgr)) { if (ttlMgrNeedFlush(pTtlMgr)) {
(void)ttlMgrFlush(pTtlMgr, pUpdCtimeCtx->pTxn); int32_t ret = ttlMgrFlush(pTtlMgr, pUpdCtimeCtx->pTxn);
if (ret < 0) {
metaError("%s, ttlMgr update ctime failed to flush since %s", pTtlMgr->logPrefix, tstrerror(ret));
}
} }
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;

View File

@ -171,7 +171,7 @@ _exit:
TAOS_RETURN(code); TAOS_RETURN(code);
} }
int32_t smaClose(SSma *pSma) { void smaClose(SSma *pSma) {
if (pSma) { if (pSma) {
TAOS_UNUSED(smaPreClose(pSma)); TAOS_UNUSED(smaPreClose(pSma));
(void)taosThreadMutexDestroy(&pSma->mutex); (void)taosThreadMutexDestroy(&pSma->mutex);
@ -182,7 +182,7 @@ int32_t smaClose(SSma *pSma) {
if SMA_RSMA_TSDB2 (pSma) tsdbClose(&SMA_RSMA_TSDB2(pSma)); if SMA_RSMA_TSDB2 (pSma) tsdbClose(&SMA_RSMA_TSDB2(pSma));
taosMemoryFreeClear(pSma); taosMemoryFreeClear(pSma);
} }
return 0; return;
} }
/** /**

View File

@ -89,7 +89,7 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
if (pItem->tmrId) { if (pItem->tmrId) {
smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pItem->tmrId, smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pItem->tmrId,
pInfo->suid, i + 1); pInfo->suid, i + 1);
if(!taosTmrStopA(&pItem->tmrId)){ if (!taosTmrStopA(&pItem->tmrId)) {
smaError("vgId:%d, failed to stop fetch timer for table %" PRIi64 " level %d", SMA_VID(pSma), pInfo->suid, smaError("vgId:%d, failed to stop fetch timer for table %" PRIi64 " level %d", SMA_VID(pSma), pInfo->suid,
i + 1); i + 1);
} }
@ -820,7 +820,10 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, int64_t version, const void *p
int64_t nItems = atomic_fetch_add_64(&pRSmaStat->nBufItems, 1); int64_t nItems = atomic_fetch_add_64(&pRSmaStat->nBufItems, 1);
if (atomic_load_8(&pInfo->assigned) == 0) { if (atomic_load_8(&pInfo->assigned) == 0) {
(void)tsem_post(&(pRSmaStat->notEmpty)); if (tsem_post(&(pRSmaStat->notEmpty)) != 0) {
smaError("vgId:%d, failed to post notEmpty semaphore for rsma %" PRIi64 " since %s", SMA_VID(pSma), suid,
tstrerror(terrno));
}
} }
// smoothing consume // smoothing consume
@ -1385,7 +1388,8 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) { if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
bool ret = taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); bool ret = taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
if (!ret) { if (!ret) {
smaWarn("vgId:%d, rsma fetch task not reset for level %" PRIi8 " since tmr reset failed, rsetId:%d refId:%" PRIi64, smaWarn("vgId:%d, rsma fetch task not reset for level %" PRIi8
" since tmr reset failed, rsetId:%d refId:%" PRIi64,
SMA_VID(pSma), pItem->level, smaMgmt.rsetId, pRSmaRef->refId); SMA_VID(pSma), pItem->level, smaMgmt.rsetId, pRSmaRef->refId);
} }
} }
@ -1407,7 +1411,10 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
atomic_store_8(&pItem->fetchLevel, 1); atomic_store_8(&pItem->fetchLevel, 1);
if (atomic_load_8(&pRSmaInfo->assigned) == 0) { if (atomic_load_8(&pRSmaInfo->assigned) == 0) {
(void)tsem_post(&(pStat->notEmpty)); if (tsem_post(&(pStat->notEmpty)) != 0) {
smaError("vgId:%d, rsma fetch task not start for level:%" PRIi8 " suid:%" PRIi64 " since sem post failed",
SMA_VID(pSma), pItem->level, pRSmaInfo->suid);
}
} }
} break; } break;
case TASK_TRIGGER_STAT_INACTIVE: { case TASK_TRIGGER_STAT_INACTIVE: {

View File

@ -127,7 +127,6 @@ int32_t tqMetaSaveOffset(STQ* pTq, STqOffset* pOffset) {
goto END; goto END;
} }
buf = taosMemoryCalloc(1, vlen); buf = taosMemoryCalloc(1, vlen);
if (buf == NULL) { if (buf == NULL) {
code = terrno; code = terrno;
@ -152,7 +151,8 @@ int32_t tqMetaSaveInfo(STQ* pTq, TTB* ttb, const void* key, int32_t kLen, const
int32_t code = TDB_CODE_SUCCESS; int32_t code = TDB_CODE_SUCCESS;
TXN* txn = NULL; TXN* txn = NULL;
TQ_ERR_GO_TO_END(tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED)); TQ_ERR_GO_TO_END(
tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED));
TQ_ERR_GO_TO_END(tdbTbUpsert(ttb, key, kLen, value, vLen, txn)); TQ_ERR_GO_TO_END(tdbTbUpsert(ttb, key, kLen, value, vLen, txn));
TQ_ERR_GO_TO_END(tdbCommit(pTq->pMetaDB, txn)); TQ_ERR_GO_TO_END(tdbCommit(pTq->pMetaDB, txn));
TQ_ERR_GO_TO_END(tdbPostCommit(pTq->pMetaDB, txn)); TQ_ERR_GO_TO_END(tdbPostCommit(pTq->pMetaDB, txn));
@ -168,7 +168,8 @@ int32_t tqMetaDeleteInfo(STQ* pTq, TTB* ttb, const void* key, int32_t kLen) {
int32_t code = TDB_CODE_SUCCESS; int32_t code = TDB_CODE_SUCCESS;
TXN* txn = NULL; TXN* txn = NULL;
TQ_ERR_GO_TO_END(tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED)); TQ_ERR_GO_TO_END(
tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED));
TQ_ERR_GO_TO_END(tdbTbDelete(ttb, key, kLen, txn)); TQ_ERR_GO_TO_END(tdbTbDelete(ttb, key, kLen, txn));
TQ_ERR_GO_TO_END(tdbCommit(pTq->pMetaDB, txn)); TQ_ERR_GO_TO_END(tdbCommit(pTq->pMetaDB, txn));
TQ_ERR_GO_TO_END(tdbPostCommit(pTq->pMetaDB, txn)); TQ_ERR_GO_TO_END(tdbPostCommit(pTq->pMetaDB, txn));
@ -180,7 +181,7 @@ END:
return code; return code;
} }
int32_t tqMetaGetOffset(STQ* pTq, const char* subkey, STqOffset** pOffset){ int32_t tqMetaGetOffset(STQ* pTq, const char* subkey, STqOffset** pOffset) {
void* data = taosHashGet(pTq->pOffset, subkey, strlen(subkey)); void* data = taosHashGet(pTq->pOffset, subkey, strlen(subkey));
if (data == NULL) { if (data == NULL) {
int vLen = 0; int vLen = 0;
@ -203,7 +204,7 @@ int32_t tqMetaGetOffset(STQ* pTq, const char* subkey, STqOffset** pOffset){
tdbFree(data); tdbFree(data);
*pOffset = taosHashGet(pTq->pOffset, subkey, strlen(subkey)); *pOffset = taosHashGet(pTq->pOffset, subkey, strlen(subkey));
if(*pOffset == NULL){ if (*pOffset == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
} else { } else {
@ -266,8 +267,8 @@ static int tqMetaInitHandle(STQ* pTq, STqHandle* handle) {
initStorageAPI(&reader.api); initStorageAPI(&reader.api);
if (handle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { if (handle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
handle->execHandle.task = handle->execHandle.task = qCreateQueueExecTaskInfo(handle->execHandle.execCol.qmsg, &reader, vgId,
qCreateQueueExecTaskInfo(handle->execHandle.execCol.qmsg, &reader, vgId, &handle->execHandle.numOfCols, handle->consumerId); &handle->execHandle.numOfCols, handle->consumerId);
TQ_NULL_GO_TO_END(handle->execHandle.task); TQ_NULL_GO_TO_END(handle->execHandle.task);
void* scanner = NULL; void* scanner = NULL;
qExtractStreamScanner(handle->execHandle.task, &scanner); qExtractStreamScanner(handle->execHandle.task, &scanner);
@ -286,14 +287,15 @@ static int tqMetaInitHandle(STQ* pTq, STqHandle* handle) {
} else if (handle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) { } else if (handle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0); handle->pWalReader = walOpenReader(pVnode->pWal, NULL, 0);
TQ_NULL_GO_TO_END(handle->pWalReader); TQ_NULL_GO_TO_END(handle->pWalReader);
if(handle->execHandle.execTb.qmsg != NULL && strcmp(handle->execHandle.execTb.qmsg, "") != 0) { if (handle->execHandle.execTb.qmsg != NULL && strcmp(handle->execHandle.execTb.qmsg, "") != 0) {
if (nodesStringToNode(handle->execHandle.execTb.qmsg, &handle->execHandle.execTb.node) != 0) { if (nodesStringToNode(handle->execHandle.execTb.qmsg, &handle->execHandle.execTb.node) != 0) {
tqError("nodesStringToNode error in sub stable, since %s", terrstr()); tqError("nodesStringToNode error in sub stable, since %s", terrstr());
return TSDB_CODE_SCH_INTERNAL_ERROR; return TSDB_CODE_SCH_INTERNAL_ERROR;
} }
} }
TQ_ERR_GO_TO_END(buildSnapContext(reader.vnode, reader.version, handle->execHandle.execTb.suid, handle->execHandle.subType, TQ_ERR_GO_TO_END(buildSnapContext(reader.vnode, reader.version, handle->execHandle.execTb.suid,
handle->fetchMeta, (SSnapContext**)(&reader.sContext))); handle->execHandle.subType, handle->fetchMeta,
(SSnapContext**)(&reader.sContext)));
handle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, handle->consumerId); handle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, handle->consumerId);
TQ_NULL_GO_TO_END(handle->execHandle.task); TQ_NULL_GO_TO_END(handle->execHandle.task);
SArray* tbUidList = NULL; SArray* tbUidList = NULL;
@ -341,7 +343,7 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
handle->execHandle.subType = req->subType; handle->execHandle.subType = req->subType;
handle->fetchMeta = req->withMeta; handle->fetchMeta = req->withMeta;
if (req->subType == TOPIC_SUB_TYPE__COLUMN) { if (req->subType == TOPIC_SUB_TYPE__COLUMN) {
void *tmp = taosStrdup(req->qmsg); void* tmp = taosStrdup(req->qmsg);
if (tmp == NULL) { if (tmp == NULL) {
return terrno; return terrno;
} }
@ -349,12 +351,12 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
} else if (req->subType == TOPIC_SUB_TYPE__DB) { } else if (req->subType == TOPIC_SUB_TYPE__DB) {
handle->execHandle.execDb.pFilterOutTbUid = handle->execHandle.execDb.pFilterOutTbUid =
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
if(handle->execHandle.execDb.pFilterOutTbUid == NULL){ if (handle->execHandle.execDb.pFilterOutTbUid == NULL) {
return terrno; return terrno;
} }
}else if(req->subType == TOPIC_SUB_TYPE__TABLE){ } else if (req->subType == TOPIC_SUB_TYPE__TABLE) {
handle->execHandle.execTb.suid = req->suid; handle->execHandle.execTb.suid = req->suid;
void *tmp = taosStrdup(req->qmsg); void* tmp = taosStrdup(req->qmsg);
if (tmp == NULL) { if (tmp == NULL) {
return terrno; return terrno;
} }
@ -364,7 +366,7 @@ int32_t tqMetaCreateHandle(STQ* pTq, SMqRebVgReq* req, STqHandle* handle) {
handle->snapshotVer = walGetCommittedVer(pTq->pVnode->pWal); handle->snapshotVer = walGetCommittedVer(pTq->pVnode->pWal);
int32_t code = tqMetaInitHandle(pTq, handle); int32_t code = tqMetaInitHandle(pTq, handle);
if (code != 0){ if (code != 0) {
return code; return code;
} }
tqInfo("tqMetaCreateHandle %s consumer 0x%" PRIx64 " vgId:%d, snapshotVer:%" PRId64, handle->subKey, tqInfo("tqMetaCreateHandle %s consumer 0x%" PRIx64 " vgId:%d, snapshotVer:%" PRId64, handle->subKey,
@ -437,10 +439,10 @@ END:
return code; return code;
} }
static int32_t replaceTqPath(char** path){ static int32_t replaceTqPath(char** path) {
char* tpath = NULL; char* tpath = NULL;
int32_t code = tqBuildFName(&tpath, *path, TQ_SUBSCRIBE_NAME); int32_t code = tqBuildFName(&tpath, *path, TQ_SUBSCRIBE_NAME);
if (code != 0){ if (code != 0) {
return code; return code;
} }
taosMemoryFree(*path); taosMemoryFree(*path);
@ -488,7 +490,7 @@ int32_t tqMetaOpen(STQ* pTq) {
} }
TQ_ERR_GO_TO_END(tqBuildFName(&offsetNew, pTq->path, TQ_OFFSET_NAME)); TQ_ERR_GO_TO_END(tqBuildFName(&offsetNew, pTq->path, TQ_OFFSET_NAME));
if(taosCheckExistFile(offsetNew)){ if (taosCheckExistFile(offsetNew)) {
TQ_ERR_GO_TO_END(tqOffsetRestoreFromFile(pTq, offsetNew)); TQ_ERR_GO_TO_END(tqOffsetRestoreFromFile(pTq, offsetNew));
TQ_ERR_GO_TO_END(taosRemoveFile(offsetNew)); TQ_ERR_GO_TO_END(taosRemoveFile(offsetNew));
} }
@ -522,7 +524,7 @@ int32_t tqMetaTransform(STQ* pTq) {
TQ_ERR_GO_TO_END(tqBuildFName(&offsetNew, pTq->path, TQ_OFFSET_NAME)); TQ_ERR_GO_TO_END(tqBuildFName(&offsetNew, pTq->path, TQ_OFFSET_NAME));
if(taosCheckExistFile(offset)) { if (taosCheckExistFile(offset)) {
if (taosCopyFile(offset, offsetNew) < 0) { if (taosCopyFile(offset, offsetNew) < 0) {
tqError("copy offset file error"); tqError("copy offset file error");
} else { } else {
@ -534,44 +536,22 @@ END:
taosMemoryFree(offset); taosMemoryFree(offset);
taosMemoryFree(offsetNew); taosMemoryFree(offsetNew);
int32_t ret = tdbTbClose(pExecStore); tdbTbClose(pExecStore);
if (ret != 0) { tdbTbClose(pCheckStore);
tqError("failed to close tb, ret:%d", ret); tdbClose(pMetaDB);
}
ret = tdbTbClose(pCheckStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
ret = tdbClose(pMetaDB);
if (ret != 0) {
tqError("failed to close tdb, ret:%d", ret);
}
return code; return code;
} }
void tqMetaClose(STQ* pTq) { void tqMetaClose(STQ* pTq) {
int32_t ret = 0; int32_t ret = 0;
if (pTq->pExecStore) { if (pTq->pExecStore) {
ret = tdbTbClose(pTq->pExecStore); tdbTbClose(pTq->pExecStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
} }
if (pTq->pCheckStore) { if (pTq->pCheckStore) {
ret = tdbTbClose(pTq->pCheckStore); tdbTbClose(pTq->pCheckStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
} }
if (pTq->pOffsetStore) { if (pTq->pOffsetStore) {
ret = tdbTbClose(pTq->pOffsetStore); tdbTbClose(pTq->pOffsetStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
}
ret = tdbClose(pTq->pMetaDB);
if (ret != 0) {
tqError("failed to close tdb, ret:%d", ret);
} }
tdbClose(pTq->pMetaDB);
} }

View File

@ -137,7 +137,7 @@ NextTbl:
memcpy(pVal, tVal, tLen); memcpy(pVal, tVal, tLen);
vLen = tLen; vLen = tLen;
} }
(void)tdbTbcMoveToNext(pReader->pCur); TAOS_UNUSED(tdbTbcMoveToNext(pReader->pCur));
break; break;
} }
if (except == 1) { if (except == 1) {
@ -147,7 +147,7 @@ NextTbl:
pReader->pos += 1; pReader->pos += 1;
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos); pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
code = tdbTbcOpen(pPair->tbl, &pReader->pCur, NULL); code = tdbTbcOpen(pPair->tbl, &pReader->pCur, NULL);
(void)tdbTbcMoveToFirst(pReader->pCur); TAOS_UNUSED(tdbTbcMoveToFirst(pReader->pCur));
goto NextTbl; goto NextTbl;
} }
@ -210,7 +210,7 @@ int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback, i
streamMetaWLock(pTq->pStreamMeta); streamMetaWLock(pTq->pStreamMeta);
tqDebug("vgId:%d, vnode stream-task snapshot writer closed", TD_VID(pTq->pVnode)); tqDebug("vgId:%d, vnode stream-task snapshot writer closed", TD_VID(pTq->pVnode));
if (rollback) { if (rollback) {
tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn); TAOS_UNUSED(tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn));
} else { } else {
code = tdbCommit(pTq->pStreamMeta->db, pTq->pStreamMeta->txn); code = tdbCommit(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
if (code) goto _err; if (code) goto _err;

View File

@ -3179,7 +3179,7 @@ static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pI
} }
if (!taosArrayAddAll(pInfo->pTombData, pIter->pMemDelData)) { if (!taosArrayAddAll(pInfo->pTombData, pIter->pMemDelData)) {
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _err); TAOS_CHECK_GOTO(terrno, &lino, _err);
} }
size_t delSize = TARRAY_SIZE(pInfo->pTombData); size_t delSize = TARRAY_SIZE(pInfo->pTombData);

View File

@ -199,9 +199,9 @@ _exit:
return code; return code;
} }
static int32_t tsdbCommitCloseReader(SCommitter2 *committer) { static void tsdbCommitCloseReader(SCommitter2 *committer) {
TARRAY2_CLEAR(committer->sttReaderArray, tsdbSttFileReaderClose); TARRAY2_CLEAR(committer->sttReaderArray, tsdbSttFileReaderClose);
return 0; return;
} }
static int32_t tsdbCommitOpenReader(SCommitter2 *committer) { static int32_t tsdbCommitOpenReader(SCommitter2 *committer) {
@ -243,19 +243,19 @@ static int32_t tsdbCommitOpenReader(SCommitter2 *committer) {
_exit: _exit:
if (code) { if (code) {
TAOS_UNUSED(tsdbCommitCloseReader(committer)); tsdbCommitCloseReader(committer);
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(committer->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(committer->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
return code; return code;
} }
static int32_t tsdbCommitCloseIter(SCommitter2 *committer) { static void tsdbCommitCloseIter(SCommitter2 *committer) {
tsdbIterMergerClose(&committer->tombIterMerger); tsdbIterMergerClose(&committer->tombIterMerger);
tsdbIterMergerClose(&committer->dataIterMerger); tsdbIterMergerClose(&committer->dataIterMerger);
TARRAY2_CLEAR(committer->tombIterArray, tsdbIterClose); TARRAY2_CLEAR(committer->tombIterArray, tsdbIterClose);
TARRAY2_CLEAR(committer->dataIterArray, tsdbIterClose); TARRAY2_CLEAR(committer->dataIterArray, tsdbIterClose);
return 0; return;
} }
static int32_t tsdbCommitOpenIter(SCommitter2 *committer) { static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
@ -309,7 +309,7 @@ static int32_t tsdbCommitOpenIter(SCommitter2 *committer) {
_exit: _exit:
if (code) { if (code) {
TAOS_UNUSED(tsdbCommitCloseIter(committer)); tsdbCommitCloseIter(committer);
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(committer->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(committer->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
@ -322,7 +322,7 @@ static int32_t tsdbCommitFileSetBegin(SCommitter2 *committer) {
STsdb *tsdb = committer->tsdb; STsdb *tsdb = committer->tsdb;
// check if can commit // check if can commit
TAOS_UNUSED(tsdbFSCheckCommit(tsdb, committer->ctx->info->fid)); tsdbFSCheckCommit(tsdb, committer->ctx->info->fid);
committer->ctx->expLevel = tsdbFidLevel(committer->ctx->info->fid, &tsdb->keepCfg, committer->now); committer->ctx->expLevel = tsdbFidLevel(committer->ctx->info->fid, &tsdb->keepCfg, committer->now);
tsdbFidKeyRange(committer->ctx->info->fid, committer->minutes, committer->precision, &committer->ctx->minKey, tsdbFidKeyRange(committer->ctx->info->fid, committer->minutes, committer->precision, &committer->ctx->minKey,
@ -355,8 +355,8 @@ static int32_t tsdbCommitFileSetEnd(SCommitter2 *committer) {
int32_t lino = 0; int32_t lino = 0;
TAOS_CHECK_GOTO(tsdbCommitCloseWriter(committer), &lino, _exit); TAOS_CHECK_GOTO(tsdbCommitCloseWriter(committer), &lino, _exit);
TAOS_CHECK_GOTO(tsdbCommitCloseIter(committer), &lino, _exit); tsdbCommitCloseIter(committer);
TAOS_CHECK_GOTO(tsdbCommitCloseReader(committer), &lino, _exit); tsdbCommitCloseReader(committer);
_exit: _exit:
if (code) { if (code) {
@ -409,11 +409,11 @@ static uint32_t tFileSetCommitInfoHash(const void *arg) {
return MurmurHash3_32((const char *)&info->fid, sizeof(info->fid)); return MurmurHash3_32((const char *)&info->fid, sizeof(info->fid));
} }
static int32_t tsdbCommitInfoDestroy(STsdb *pTsdb) { static void tsdbCommitInfoDestroy(STsdb *pTsdb) {
if (pTsdb->commitInfo) { if (pTsdb->commitInfo) {
for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) { for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) {
SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i); SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i);
TAOS_UNUSED(vHashDrop(pTsdb->commitInfo->ht, info)); int32_t ret = vHashDrop(pTsdb->commitInfo->ht, info);
tsdbTFileSetClear(&info->fset); tsdbTFileSetClear(&info->fset);
taosMemoryFree(info); taosMemoryFree(info);
} }
@ -423,7 +423,7 @@ static int32_t tsdbCommitInfoDestroy(STsdb *pTsdb) {
pTsdb->commitInfo->arr = NULL; pTsdb->commitInfo->arr = NULL;
taosMemoryFreeClear(pTsdb->commitInfo); taosMemoryFreeClear(pTsdb->commitInfo);
} }
return 0; return;
} }
static int32_t tsdbCommitInfoInit(STsdb *pTsdb) { static int32_t tsdbCommitInfoInit(STsdb *pTsdb) {
@ -444,7 +444,7 @@ static int32_t tsdbCommitInfoInit(STsdb *pTsdb) {
_exit: _exit:
if (code) { if (code) {
TAOS_UNUSED(tsdbCommitInfoDestroy(pTsdb)); tsdbCommitInfoDestroy(pTsdb);
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(pTsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(pTsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
} }
return code; return code;
@ -514,7 +514,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) {
SFileSetCommitInfo tinfo = { SFileSetCommitInfo tinfo = {
.fid = fid, .fid = fid,
}; };
TAOS_UNUSED(vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info)); int32_t ret = vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info);
if (info == NULL) { if (info == NULL) {
TAOS_CHECK_GOTO(tsdbCommitInfoAdd(tsdb, fid), &lino, _exit); TAOS_CHECK_GOTO(tsdbCommitInfoAdd(tsdb, fid), &lino, _exit);
} }
@ -538,7 +538,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) {
}; };
// check if the file set already on the commit list // check if the file set already on the commit list
TAOS_UNUSED(vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info)); int32_t ret = vHashGet(tsdb->commitInfo->ht, &tinfo, (void **)&info);
if (info != NULL) { if (info != NULL) {
continue; continue;
} }
@ -586,7 +586,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) {
_exit: _exit:
if (code) { if (code) {
TAOS_UNUSED(tsdbCommitInfoDestroy(tsdb)); tsdbCommitInfoDestroy(tsdb);
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code));
} }
return code; return code;
@ -716,7 +716,7 @@ int32_t tsdbCommitCommit(STsdb *tsdb) {
(void)taosThreadMutexUnlock(&tsdb->mutex); (void)taosThreadMutexUnlock(&tsdb->mutex);
TAOS_UNUSED(tsdbCommitInfoDestroy(tsdb)); tsdbCommitInfoDestroy(tsdb);
tsdbUnrefMemTable(pMemTable, NULL, true); tsdbUnrefMemTable(pMemTable, NULL, true);
} }
@ -745,7 +745,7 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) {
} }
} }
(void)taosThreadMutexUnlock(&pTsdb->mutex); (void)taosThreadMutexUnlock(&pTsdb->mutex);
TAOS_UNUSED(tsdbCommitInfoDestroy(pTsdb)); tsdbCommitInfoDestroy(pTsdb);
_exit: _exit:
if (code) { if (code) {

View File

@ -130,7 +130,7 @@ _exit:
tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname); tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname);
} }
taosMemoryFree(pData); taosMemoryFree(pData);
(void)taosCloseFile(&pFD); taosCloseFileWithLog(&pFD);
return code; return code;
} }
@ -300,26 +300,26 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) {
int64_t size; int64_t size;
code = taosFStatFile(pFD, &size, NULL); code = taosFStatFile(pFD, &size, NULL);
if (code != 0) { if (code != 0) {
(void)taosCloseFile(&pFD); taosCloseFileWithLog(&pFD);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} }
pData = taosMemoryMalloc(size); pData = taosMemoryMalloc(size);
if (pData == NULL) { if (pData == NULL) {
code = terrno; code = terrno;
(void)taosCloseFile(&pFD); taosCloseFileWithLog(&pFD);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} }
if (taosReadFile(pFD, pData, size) < 0) { if (taosReadFile(pFD, pData, size) < 0) {
code = terrno; code = terrno;
(void)taosCloseFile(&pFD); taosCloseFileWithLog(&pFD);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} }
if (!taosCheckChecksumWhole(pData, size)) { if (!taosCheckChecksumWhole(pData, size)) {
code = TSDB_CODE_FILE_CORRUPTED; code = TSDB_CODE_FILE_CORRUPTED;
(void)taosCloseFile(&pFD); taosCloseFileWithLog(&pFD);
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} }
@ -331,7 +331,7 @@ _exit:
tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname); tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname);
} }
taosMemoryFree(pData); taosMemoryFree(pData);
(void)taosCloseFile(&pFD); taosCloseFileWithLog(&pFD);
return code; return code;
} }

View File

@ -44,7 +44,12 @@ static int32_t create_fs(STsdb *pTsdb, STFileSystem **fs) {
} }
fs[0]->tsdb = pTsdb; fs[0]->tsdb = pTsdb;
(void)tsem_init(&fs[0]->canEdit, 0, 1); int32_t code = tsem_init(&fs[0]->canEdit, 0, 1);
if (code) {
taosMemoryFree(fs[0]);
return code;
}
fs[0]->fsstate = TSDB_FS_STATE_NORMAL; fs[0]->fsstate = TSDB_FS_STATE_NORMAL;
fs[0]->neid = 0; fs[0]->neid = 0;
TARRAY2_INIT(fs[0]->fSetArr); TARRAY2_INIT(fs[0]->fSetArr);
@ -58,7 +63,9 @@ static void destroy_fs(STFileSystem **fs) {
TARRAY2_DESTROY(fs[0]->fSetArr, NULL); TARRAY2_DESTROY(fs[0]->fSetArr, NULL);
TARRAY2_DESTROY(fs[0]->fSetArrTmp, NULL); TARRAY2_DESTROY(fs[0]->fSetArrTmp, NULL);
(void)tsem_destroy(&fs[0]->canEdit); if (tsem_destroy(&fs[0]->canEdit) != 0) {
tsdbError("failed to destroy semaphore");
}
taosMemoryFree(fs[0]); taosMemoryFree(fs[0]);
fs[0] = NULL; fs[0] = NULL;
} }
@ -100,7 +107,7 @@ _exit:
tsdbError("%s failed at %s:%d since %s", __func__, fname, __LINE__, tstrerror(code)); tsdbError("%s failed at %s:%d since %s", __func__, fname, __LINE__, tstrerror(code));
} }
taosMemoryFree(data); taosMemoryFree(data);
(void)taosCloseFile(&fp); taosCloseFileWithLog(&fp);
return code; return code;
} }
@ -140,7 +147,7 @@ _exit:
tsdbError("%s failed at %s:%d since %s", __func__, fname, __LINE__, tstrerror(code)); tsdbError("%s failed at %s:%d since %s", __func__, fname, __LINE__, tstrerror(code));
json[0] = NULL; json[0] = NULL;
} }
(void)taosCloseFile(&fp); taosCloseFileWithLog(&fp);
taosMemoryFree(data); taosMemoryFree(data);
return code; return code;
} }
@ -803,7 +810,11 @@ void tsdbEnableBgTask(STsdb *pTsdb) {
void tsdbCloseFS(STFileSystem **fs) { void tsdbCloseFS(STFileSystem **fs) {
if (fs[0] == NULL) return; if (fs[0] == NULL) return;
TAOS_UNUSED(tsdbDisableAndCancelAllBgTask((*fs)->tsdb)); int32_t code = tsdbDisableAndCancelAllBgTask((*fs)->tsdb);
if (code) {
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID((*fs)->tsdb->pVnode), __func__, __LINE__,
tstrerror(code));
}
close_file_system(fs[0]); close_file_system(fs[0]);
destroy_fs(fs); destroy_fs(fs);
return; return;
@ -833,7 +844,9 @@ int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT e
current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M); current_fname(fs->tsdb, current_t, TSDB_FCURRENT_M);
} }
(void)tsem_wait(&fs->canEdit); if (tsem_wait(&fs->canEdit) != 0) {
tsdbError("vgId:%d failed to wait semaphore", TD_VID(fs->tsdb->pVnode));
}
fs->etype = etype; fs->etype = etype;
// edit // edit
@ -865,7 +878,7 @@ static void tsdbFSSetBlockCommit(STFileSet *fset, bool block) {
} }
} }
int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) { void tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) {
(void)taosThreadMutexLock(&tsdb->mutex); (void)taosThreadMutexLock(&tsdb->mutex);
STFileSet *fset; STFileSet *fset;
tsdbFSGetFSet(tsdb->pFS, fid, &fset); tsdbFSGetFSet(tsdb->pFS, fid, &fset);
@ -877,7 +890,7 @@ int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) {
} }
} }
(void)taosThreadMutexUnlock(&tsdb->mutex); (void)taosThreadMutexUnlock(&tsdb->mutex);
return 0; return;
} }
// IMPORTANT: the caller must hold fs->tsdb->mutex // IMPORTANT: the caller must hold fs->tsdb->mutex
@ -939,13 +952,17 @@ _exit:
} else { } else {
tsdbInfo("vgId:%d %s done, etype:%d", TD_VID(fs->tsdb->pVnode), __func__, fs->etype); tsdbInfo("vgId:%d %s done, etype:%d", TD_VID(fs->tsdb->pVnode), __func__, fs->etype);
} }
(void)tsem_post(&fs->canEdit); if (tsem_post(&fs->canEdit) != 0) {
tsdbError("vgId:%d failed to post semaphore", TD_VID(fs->tsdb->pVnode));
}
return code; return code;
} }
int32_t tsdbFSEditAbort(STFileSystem *fs) { int32_t tsdbFSEditAbort(STFileSystem *fs) {
int32_t code = abort_edit(fs); int32_t code = abort_edit(fs);
(void)tsem_post(&fs->canEdit); if (tsem_post(&fs->canEdit) != 0) {
tsdbError("vgId:%d failed to post semaphore", TD_VID(fs->tsdb->pVnode));
}
return code; return code;
} }

View File

@ -60,7 +60,7 @@ int32_t tsdbFSEditCommit(STFileSystem *fs);
int32_t tsdbFSEditAbort(STFileSystem *fs); int32_t tsdbFSEditAbort(STFileSystem *fs);
// other // other
void tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset); void tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset);
int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid); void tsdbFSCheckCommit(STsdb *tsdb, int32_t fid);
void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset); void tsdbBeginTaskOnFileSet(STsdb *tsdb, int32_t fid, STFileSet **fset);
void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid); void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid);
// utils // utils

View File

@ -102,7 +102,7 @@ _exit:
return code; return code;
} }
int32_t tsdbClose(STsdb **pTsdb) { void tsdbClose(STsdb **pTsdb) {
if (*pTsdb) { if (*pTsdb) {
STsdb *pdb = *pTsdb; STsdb *pdb = *pTsdb;
tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d, keepTimeOffset:%d", TD_VID(pdb->pVnode), pdb->path, tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d, keepTimeOffset:%d", TD_VID(pdb->pVnode), pdb->path,
@ -121,5 +121,5 @@ int32_t tsdbClose(STsdb **pTsdb) {
(void)taosThreadMutexDestroy(&(*pTsdb)->mutex); (void)taosThreadMutexDestroy(&(*pTsdb)->mutex);
taosMemoryFreeClear(*pTsdb); taosMemoryFreeClear(*pTsdb);
} }
return 0; return;
} }

View File

@ -299,7 +299,7 @@ static int32_t filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader, bo
pReader->status.pLDataIterArray = taosArrayInit(4, POINTER_BYTES); pReader->status.pLDataIterArray = taosArrayInit(4, POINTER_BYTES);
if (pReader->status.pLDataIterArray == NULL) { if (pReader->status.pLDataIterArray == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
// check file the time range of coverage // check file the time range of coverage
@ -556,7 +556,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, void
pReader->idStr = (idstr != NULL) ? taosStrdup(idstr) : NULL; pReader->idStr = (idstr != NULL) ? taosStrdup(idstr) : NULL;
if (idstr != NULL && pReader->idStr == NULL) { if (idstr != NULL && pReader->idStr == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto _end; goto _end;
} }
@ -2918,7 +2918,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, int32_t orde
} else { } else {
void* p1 = taosArrayAddAll(pSource, pBlockScanInfo->pMemDelData); void* p1 = taosArrayAddAll(pSource, pBlockScanInfo->pMemDelData);
if (p1 == NULL) { if (p1 == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
} }

View File

@ -436,7 +436,7 @@ static int32_t tsdbReadFileS3(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64
code = tsdbCacheGetPageS3(pFD->pTsdb->pgCache, pFD, pgno, &handle); code = tsdbCacheGetPageS3(pFD->pTsdb->pgCache, pFD, pgno, &handle);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
if (handle) { if (handle) {
(void)tsdbCacheRelease(pFD->pTsdb->pgCache, handle); tsdbCacheRelease(pFD->pTsdb->pgCache, handle);
} }
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} }
@ -447,7 +447,7 @@ static int32_t tsdbReadFileS3(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64
uint8_t *pPage = (uint8_t *)taosLRUCacheValue(pFD->pTsdb->pgCache, handle); uint8_t *pPage = (uint8_t *)taosLRUCacheValue(pFD->pTsdb->pgCache, handle);
memcpy(pFD->pBuf, pPage, pFD->szPage); memcpy(pFD->pBuf, pPage, pFD->szPage);
(void)tsdbCacheRelease(pFD->pTsdb->pgCache, handle); tsdbCacheRelease(pFD->pTsdb->pgCache, handle);
// check // check
if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) { if (pgno > 1 && !taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {

View File

@ -99,8 +99,12 @@ _exit:
tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
(void)taosCloseFile(&fdFrom); if (taosCloseFile(&fdFrom) != 0) {
(void)taosCloseFile(&fdTo); tsdbError("vgId:%d, failed to close file %s", TD_VID(rtner->tsdb->pVnode), fname_from);
}
if (taosCloseFile(&fdTo) != 0) {
tsdbError("vgId:%d, failed to close file %s", TD_VID(rtner->tsdb->pVnode), fname_to);
}
return code; return code;
} }
@ -136,8 +140,12 @@ _exit:
tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d, %s failed at %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
(void)taosCloseFile(&fdFrom); if (taosCloseFile(&fdFrom) != 0) {
(void)taosCloseFile(&fdTo); tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
if (taosCloseFile(&fdTo) != 0) {
tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
return code; return code;
} }
@ -441,7 +449,9 @@ _exit:
tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
(void)taosCloseFile(&fdFrom); if (taosCloseFile(&fdFrom) != 0) {
tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
return code; return code;
} }
@ -541,8 +551,13 @@ _exit:
tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
(void)taosCloseFile(&fdFrom); if (taosCloseFile(&fdFrom) != 0) {
(void)taosCloseFile(&fdTo); tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
if (taosCloseFile(&fdTo) != 0) {
tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
return code; return code;
} }
@ -639,8 +654,12 @@ _exit:
tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino, tsdbError("vgId:%d %s failed at line %s:%d since %s", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, lino,
tstrerror(code)); tstrerror(code));
} }
(void)taosCloseFile(&fdFrom); if (taosCloseFile(&fdFrom) != 0) {
(void)taosCloseFile(&fdTo); tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
if (taosCloseFile(&fdTo) != 0) {
tsdbTrace("vgId:%d, failed to close file", TD_VID(rtner->tsdb->pVnode));
}
return code; return code;
} }
@ -699,7 +718,9 @@ static int32_t tsdbDoS3Migrate(SRTNer *rtner) {
if (taosCheckExistFile(fname1)) { if (taosCheckExistFile(fname1)) {
int32_t mtime = 0; int32_t mtime = 0;
int64_t size = 0; int64_t size = 0;
(void)taosStatFile(fname1, &size, &mtime, NULL); if (taosStatFile(fname1, &size, &mtime, NULL) != 0) {
tsdbError("vgId:%d, %s failed at %s:%d ", TD_VID(rtner->tsdb->pVnode), __func__, __FILE__, __LINE__);
}
if (size > chunksize && mtime < rtner->now - tsS3UploadDelaySec) { if (size > chunksize && mtime < rtner->now - tsS3UploadDelaySec) {
TAOS_CHECK_GOTO(tsdbMigrateDataFileLCS3(rtner, fobj, size, chunksize), &lino, _exit); TAOS_CHECK_GOTO(tsdbMigrateDataFileLCS3(rtner, fobj, size, chunksize), &lino, _exit);
} }

View File

@ -57,10 +57,10 @@ struct STsdbSnapReader {
STombBlock tombBlock[1]; STombBlock tombBlock[1];
}; };
static int32_t tsdbSnapReadFileSetCloseReader(STsdbSnapReader* reader) { static void tsdbSnapReadFileSetCloseReader(STsdbSnapReader* reader) {
TARRAY2_CLEAR(reader->sttReaderArr, tsdbSttFileReaderClose); TARRAY2_CLEAR(reader->sttReaderArr, tsdbSttFileReaderClose);
tsdbDataFileReaderClose(&reader->dataReader); tsdbDataFileReaderClose(&reader->dataReader);
return 0; return;
} }
static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) { static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) {
@ -112,7 +112,7 @@ static int32_t tsdbSnapReadFileSetOpenReader(STsdbSnapReader* reader) {
_exit: _exit:
if (code) { if (code) {
TAOS_UNUSED(tsdbSnapReadFileSetCloseReader(reader)); tsdbSnapReadFileSetCloseReader(reader);
TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino); TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino);
} }
return code; return code;
@ -190,12 +190,12 @@ _exit:
return code; return code;
} }
static int32_t tsdbSnapReadFileSetCloseIter(STsdbSnapReader* reader) { static void tsdbSnapReadFileSetCloseIter(STsdbSnapReader* reader) {
tsdbIterMergerClose(&reader->dataIterMerger); tsdbIterMergerClose(&reader->dataIterMerger);
tsdbIterMergerClose(&reader->tombIterMerger); tsdbIterMergerClose(&reader->tombIterMerger);
TARRAY2_CLEAR(reader->dataIterArr, tsdbIterClose); TARRAY2_CLEAR(reader->dataIterArr, tsdbIterClose);
TARRAY2_CLEAR(reader->tombIterArr, tsdbIterClose); TARRAY2_CLEAR(reader->tombIterArr, tsdbIterClose);
return 0; return;
} }
static int32_t tsdbSnapReadRangeBegin(STsdbSnapReader* reader) { static int32_t tsdbSnapReadRangeBegin(STsdbSnapReader* reader) {
@ -222,8 +222,8 @@ _exit:
} }
static int32_t tsdbSnapReadRangeEnd(STsdbSnapReader* reader) { static int32_t tsdbSnapReadRangeEnd(STsdbSnapReader* reader) {
TAOS_UNUSED(tsdbSnapReadFileSetCloseIter(reader)); tsdbSnapReadFileSetCloseIter(reader);
TAOS_UNUSED(tsdbSnapReadFileSetCloseReader(reader)); tsdbSnapReadFileSetCloseReader(reader);
reader->ctx->fsr = NULL; reader->ctx->fsr = NULL;
return 0; return 0;
} }
@ -373,7 +373,7 @@ static int32_t tsdbSnapReadTombData(STsdbSnapReader* reader, uint8_t** data) {
int32_t lino = 0; int32_t lino = 0;
SMetaInfo info; SMetaInfo info;
TAOS_UNUSED(tTombBlockClear(reader->tombBlock)); tTombBlockClear(reader->tombBlock);
TABLEID tbid[1] = {0}; TABLEID tbid[1] = {0};
for (STombRecord* record; (record = tsdbIterMergerGetTombRecord(reader->tombIterMerger)) != NULL;) { for (STombRecord* record; (record = tsdbIterMergerGetTombRecord(reader->tombIterMerger)) != NULL;) {
@ -463,7 +463,7 @@ void tsdbSnapReaderClose(STsdbSnapReader** reader) {
tDestroyTSchema(reader[0]->skmTb->pTSchema); tDestroyTSchema(reader[0]->skmTb->pTSchema);
for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(reader[0]->buffers); ++i) {
TAOS_UNUSED(tBufferDestroy(reader[0]->buffers + i)); tBufferDestroy(reader[0]->buffers + i);
} }
taosMemoryFree(reader[0]); taosMemoryFree(reader[0]);
@ -1000,7 +1000,7 @@ static int32_t tsdbSnapWriteDecmprTombBlock(SSnapDataHdr* hdr, STombBlock* tombB
int32_t code = 0; int32_t code = 0;
int32_t lino = 0; int32_t lino = 0;
TAOS_UNUSED(tTombBlockClear(tombBlock)); tTombBlockClear(tombBlock);
int64_t size = hdr->size; int64_t size = hdr->size;
size = size / TOMB_RECORD_ELEM_NUM; size = size / TOMB_RECORD_ELEM_NUM;

View File

@ -415,7 +415,7 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta
&lino, _exit); &lino, _exit);
// decode data // decode data
TAOS_UNUSED(tStatisBlockClear(statisBlock)); tStatisBlockClear(statisBlock);
statisBlock->numOfPKs = statisBlk->numOfPKs; statisBlock->numOfPKs = statisBlk->numOfPKs;
statisBlock->numOfRecords = statisBlk->numRec; statisBlock->numOfRecords = statisBlk->numRec;
SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0);
@ -654,7 +654,7 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
TAOS_CHECK_GOTO(TARRAY2_APPEND_PTR(writer->statisBlkArray, &statisBlk), &lino, _exit); TAOS_CHECK_GOTO(TARRAY2_APPEND_PTR(writer->statisBlkArray, &statisBlk), &lino, _exit);
TAOS_UNUSED(tStatisBlockClear(writer->staticBlock)); tStatisBlockClear(writer->staticBlock);
_exit: _exit:
if (code) { if (code) {

View File

@ -609,7 +609,10 @@ void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *
SValue value; SValue value;
if (pRow->type == TSDBROW_ROW_FMT) { if (pRow->type == TSDBROW_ROW_FMT) {
(void)tRowGet(pRow->pTSRow, pTSchema, iCol, pColVal); int32_t ret = tRowGet(pRow->pTSRow, pTSchema, iCol, pColVal);
if (ret != 0) {
tsdbError("failed to get column value, code:%d", ret);
}
} else if (pRow->type == TSDBROW_COL_FMT) { } else if (pRow->type == TSDBROW_COL_FMT) {
if (iCol == 0) { if (iCol == 0) {
*pColVal = *pColVal =

View File

@ -93,25 +93,25 @@ void tStatisBlockDestroy(STbStatisBlock *statisBlock) {
statisBlock->numOfPKs = 0; statisBlock->numOfPKs = 0;
statisBlock->numOfRecords = 0; statisBlock->numOfRecords = 0;
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
TAOS_UNUSED(tBufferDestroy(&statisBlock->buffers[i])); tBufferDestroy(&statisBlock->buffers[i]);
} }
for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
TAOS_UNUSED(tValueColumnDestroy(&statisBlock->firstKeyPKs[i])); tValueColumnDestroy(&statisBlock->firstKeyPKs[i]);
TAOS_UNUSED(tValueColumnDestroy(&statisBlock->lastKeyPKs[i])); tValueColumnDestroy(&statisBlock->lastKeyPKs[i]);
} }
} }
int32_t tStatisBlockClear(STbStatisBlock *statisBlock) { void tStatisBlockClear(STbStatisBlock *statisBlock) {
statisBlock->numOfPKs = 0; statisBlock->numOfPKs = 0;
statisBlock->numOfRecords = 0; statisBlock->numOfRecords = 0;
for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) {
TAOS_UNUSED(tBufferClear(&statisBlock->buffers[i])); tBufferClear(&statisBlock->buffers[i]);
} }
for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
tValueColumnClear(&statisBlock->firstKeyPKs[i]); tValueColumnClear(&statisBlock->firstKeyPKs[i]);
tValueColumnClear(&statisBlock->lastKeyPKs[i]); tValueColumnClear(&statisBlock->lastKeyPKs[i]);
} }
return 0; return;
} }
static int32_t tStatisBlockAppend(STbStatisBlock *block, SRowInfo *row) { static int32_t tStatisBlockAppend(STbStatisBlock *block, SRowInfo *row) {
@ -252,11 +252,11 @@ void tBrinBlockDestroy(SBrinBlock *brinBlock) {
brinBlock->numOfPKs = 0; brinBlock->numOfPKs = 0;
brinBlock->numOfRecords = 0; brinBlock->numOfRecords = 0;
for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
TAOS_UNUSED(tBufferDestroy(&brinBlock->buffers[i])); tBufferDestroy(&brinBlock->buffers[i]);
} }
for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
TAOS_UNUSED(tValueColumnDestroy(&brinBlock->firstKeyPKs[i])); tValueColumnDestroy(&brinBlock->firstKeyPKs[i]);
TAOS_UNUSED(tValueColumnDestroy(&brinBlock->lastKeyPKs[i])); tValueColumnDestroy(&brinBlock->lastKeyPKs[i]);
} }
} }
@ -264,7 +264,7 @@ void tBrinBlockClear(SBrinBlock *brinBlock) {
brinBlock->numOfPKs = 0; brinBlock->numOfPKs = 0;
brinBlock->numOfRecords = 0; brinBlock->numOfRecords = 0;
for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) {
TAOS_UNUSED(tBufferClear(&brinBlock->buffers[i])); tBufferClear(&brinBlock->buffers[i]);
} }
for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) {
tValueColumnClear(&brinBlock->firstKeyPKs[i]); tValueColumnClear(&brinBlock->firstKeyPKs[i]);

View File

@ -113,7 +113,7 @@ typedef struct {
int32_t tStatisBlockInit(STbStatisBlock *statisBlock); int32_t tStatisBlockInit(STbStatisBlock *statisBlock);
void tStatisBlockDestroy(STbStatisBlock *statisBlock); void tStatisBlockDestroy(STbStatisBlock *statisBlock);
int32_t tStatisBlockClear(STbStatisBlock *statisBlock); void tStatisBlockClear(STbStatisBlock *statisBlock);
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, SRowInfo *row, int32_t maxRecords); int32_t tStatisBlockPut(STbStatisBlock *statisBlock, SRowInfo *row, int32_t maxRecords);
int32_t tStatisBlockGet(STbStatisBlock *statisBlock, int32_t idx, STbStatisRecord *record); int32_t tStatisBlockGet(STbStatisBlock *statisBlock, int32_t idx, STbStatisRecord *record);

View File

@ -187,10 +187,12 @@ static void vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) {
task->prev->next = task->next; task->prev->next = task->next;
task->next->prev = task->prev; task->next->prev = task->prev;
if (task->cancel) { if (task->cancel) {
TAOS_UNUSED(taosArrayPush(cancelArray, &(SVATaskCancelInfo){ if (taosArrayPush(cancelArray, &(SVATaskCancelInfo){
.cancel = task->cancel, .cancel = task->cancel,
.arg = task->arg, .arg = task->arg,
})); }) == NULL) {
vError("failed to push cancel task into array");
};
} }
vnodeAsyncTaskDone(async, task); vnodeAsyncTaskDone(async, task);
} }
@ -430,7 +432,7 @@ static void vnodeAsyncLaunchWorker(SVAsync *async) {
if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) { if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) {
continue; continue;
} else if (async->workers[i].state == EVA_WORKER_STATE_STOP) { } else if (async->workers[i].state == EVA_WORKER_STATE_STOP) {
TAOS_UNUSED(taosThreadJoin(async->workers[i].thread, NULL)); int32_t ret = taosThreadJoin(async->workers[i].thread, NULL);
async->workers[i].state = EVA_WORKER_STATE_UINIT; async->workers[i].state = EVA_WORKER_STATE_UINIT;
} }
@ -748,10 +750,12 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
task->prev->next = task->next; task->prev->next = task->next;
task->next->prev = task->prev; task->next->prev = task->prev;
if (task->cancel) { if (task->cancel) {
TAOS_UNUSED(taosArrayPush(cancelArray, &(SVATaskCancelInfo){ if (taosArrayPush(cancelArray, &(SVATaskCancelInfo){
.cancel = task->cancel, .cancel = task->cancel,
.arg = task->arg, .arg = task->arg,
})); }) == NULL) {
vError("failed to push cancel info");
};
} }
vnodeAsyncTaskDone(async, task); vnodeAsyncTaskDone(async, task);
} }
@ -763,10 +767,12 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
channel->scheduled->prev->next = channel->scheduled->next; channel->scheduled->prev->next = channel->scheduled->next;
channel->scheduled->next->prev = channel->scheduled->prev; channel->scheduled->next->prev = channel->scheduled->prev;
if (channel->scheduled->cancel) { if (channel->scheduled->cancel) {
TAOS_UNUSED(taosArrayPush(cancelArray, &(SVATaskCancelInfo){ if (taosArrayPush(cancelArray, &(SVATaskCancelInfo){
.cancel = channel->scheduled->cancel, .cancel = channel->scheduled->cancel,
.arg = channel->scheduled->arg, .arg = channel->scheduled->arg,
})); }) == NULL) {
vError("failed to push cancel info");
}
} }
vnodeAsyncTaskDone(async, channel->scheduled); vnodeAsyncTaskDone(async, channel->scheduled);
} }

View File

@ -91,7 +91,9 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
struct timeval tv; struct timeval tv;
struct timespec ts; struct timespec ts;
(void)taosGetTimeOfDay(&tv); if (taosGetTimeOfDay(&tv) != 0) {
continue;
}
ts.tv_nsec = tv.tv_usec * 1000 + WAIT_TIME_MILI_SEC * 1000000; ts.tv_nsec = tv.tv_usec * 1000 + WAIT_TIME_MILI_SEC * 1000000;
if (ts.tv_nsec > 999999999l) { if (ts.tv_nsec > 999999999l) {
ts.tv_sec = tv.tv_sec + 1; ts.tv_sec = tv.tv_sec + 1;
@ -199,7 +201,9 @@ _exit:
vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d selfIndex:%d changeVersion:%d", pInfo->config.vgId, fname, vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d selfIndex:%d changeVersion:%d", pInfo->config.vgId, fname,
pInfo->config.syncCfg.replicaNum, pInfo->config.syncCfg.myIndex, pInfo->config.syncCfg.changeVersion); pInfo->config.syncCfg.replicaNum, pInfo->config.syncCfg.myIndex, pInfo->config.syncCfg.changeVersion);
} }
(void)taosCloseFile(&pFile); if (taosCloseFile(&pFile) != 0) {
vError("vgId:%d, failed to close file", pInfo->config.vgId);
}
taosMemoryFree(data); taosMemoryFree(data);
return code; return code;
} }
@ -261,7 +265,9 @@ _exit:
} }
} }
taosMemoryFree(pData); taosMemoryFree(pData);
(void)taosCloseFile(&pFile); if (taosCloseFile(&pFile) != 0) {
vError("vgId:%d, failed to close file", pInfo->config.vgId);
}
return code; return code;
} }
@ -494,7 +500,9 @@ void vnodeRollback(SVnode *pVnode) {
offset = strlen(tFName); offset = strlen(tFName);
snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP); snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP);
TAOS_UNUSED(taosRemoveFile(tFName)); if (taosRemoveFile(tFName) != 0) {
vError("vgId:%d, failed to remove file %s since %s", TD_VID(pVnode), tFName, tstrerror(terrno));
}
} }
static int vnodeEncodeState(const void *pObj, SJson *pJson) { static int vnodeEncodeState(const void *pObj, SJson *pJson) {

View File

@ -24,10 +24,10 @@ struct SVHashEntry {
void* obj; void* obj;
}; };
static int32_t vHashRehash(SVHashTable* ht, uint32_t newNumBuckets) { static void vHashRehash(SVHashTable* ht, uint32_t newNumBuckets) {
SVHashEntry** newBuckets = (SVHashEntry**)taosMemoryCalloc(newNumBuckets, sizeof(SVHashEntry*)); SVHashEntry** newBuckets = (SVHashEntry**)taosMemoryCalloc(newNumBuckets, sizeof(SVHashEntry*));
if (newBuckets == NULL) { if (newBuckets == NULL) {
return terrno; return;
} }
for (int32_t i = 0; i < ht->numBuckets; i++) { for (int32_t i = 0; i < ht->numBuckets; i++) {
@ -45,7 +45,7 @@ static int32_t vHashRehash(SVHashTable* ht, uint32_t newNumBuckets) {
ht->buckets = newBuckets; ht->buckets = newBuckets;
ht->numBuckets = newNumBuckets; ht->numBuckets = newNumBuckets;
return 0; return;
} }
int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*compare)(const void*, const void*)) { int32_t vHashInit(SVHashTable** ht, uint32_t (*hash)(const void*), int32_t (*compare)(const void*, const void*)) {
@ -96,7 +96,7 @@ int32_t vHashPut(SVHashTable* ht, void* obj) {
} }
if (ht->numEntries >= ht->numBuckets) { if (ht->numEntries >= ht->numBuckets) {
(void)vHashRehash(ht, ht->numBuckets * 2); vHashRehash(ht, ht->numBuckets * 2);
bucketIndex = ht->hash(obj) % ht->numBuckets; bucketIndex = ht->hash(obj) % ht->numBuckets;
} }
@ -142,7 +142,7 @@ int32_t vHashDrop(SVHashTable* ht, const void* obj) {
taosMemoryFree(tmp); taosMemoryFree(tmp);
ht->numEntries--; ht->numEntries--;
if (ht->numBuckets > VNODE_HASH_DEFAULT_NUM_BUCKETS && ht->numEntries < ht->numBuckets / 4) { if (ht->numBuckets > VNODE_HASH_DEFAULT_NUM_BUCKETS && ht->numEntries < ht->numBuckets / 4) {
(void)vHashRehash(ht, ht->numBuckets / 2); vHashRehash(ht, ht->numBuckets / 2);
} }
return 0; return 0;
} }

View File

@ -108,7 +108,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
pNode->nodePort = pReq->replicas[i].port; pNode->nodePort = pReq->replicas[i].port;
tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn));
pNode->nodeRole = TAOS_SYNC_ROLE_VOTER; pNode->nodeRole = TAOS_SYNC_ROLE_VOTER;
(void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); bool ret = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId); vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId);
pCfg->replicaNum++; pCfg->replicaNum++;
} }
@ -121,7 +121,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
pNode->nodePort = pReq->learnerReplicas[pCfg->totalReplicaNum].port; pNode->nodePort = pReq->learnerReplicas[pCfg->totalReplicaNum].port;
pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER; pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER;
tstrncpy(pNode->nodeFqdn, pReq->learnerReplicas[pCfg->totalReplicaNum].fqdn, sizeof(pNode->nodeFqdn)); tstrncpy(pNode->nodeFqdn, pReq->learnerReplicas[pCfg->totalReplicaNum].fqdn, sizeof(pNode->nodeFqdn));
(void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); bool ret = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId); vInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId);
pCfg->totalReplicaNum++; pCfg->totalReplicaNum++;
} }
@ -176,8 +176,10 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
int32_t prefixLen = strlen(tsdbFilePrefix); int32_t prefixLen = strlen(tsdbFilePrefix);
STfsDir *tsdbDir = NULL; STfsDir *tsdbDir = NULL;
(void)tfsOpendir(pTfs, tsdbPath, &tsdbDir); int32_t tret = tfsOpendir(pTfs, tsdbPath, &tsdbDir);
if (tsdbDir == NULL) return 0; if (tsdbDir == NULL) {
return 0;
}
while (1) { while (1) {
const STfsFile *tsdbFile = tfsReaddir(tsdbDir); const STfsFile *tsdbFile = tfsReaddir(tsdbDir);
@ -248,7 +250,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
SNodeInfo *pNode = &pCfg->nodeInfo[0]; SNodeInfo *pNode = &pCfg->nodeInfo[0];
pNode->nodePort = tsServerPort; pNode->nodePort = tsServerPort;
tstrncpy(pNode->nodeFqdn, tsLocalFqdn, TSDB_FQDN_LEN); tstrncpy(pNode->nodeFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
(void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); bool ret1 = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort);
vInfo("vgId:%d, ep:%s:%u dnode:%d", pReq->srcVgId, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId); vInfo("vgId:%d, ep:%s:%u dnode:%d", pReq->srcVgId, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId);
info.config.syncCfg = *pCfg; info.config.syncCfg = *pCfg;
@ -317,7 +319,9 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId) { void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId) {
vInfo("path:%s is removed while destroy vnode", path); vInfo("path:%s is removed while destroy vnode", path);
(void)tfsRmdir(pTfs, path); if (tfsRmdir(pTfs, path) < 0) {
vError("failed to remove path:%s since %s", path, tstrerror(terrno));
}
// int32_t nlevel = tfsGetLevel(pTfs); // int32_t nlevel = tfsGetLevel(pTfs);
if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) { if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) {
@ -378,8 +382,13 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
} }
if (updated) { if (updated) {
vInfo("vgId:%d, save vnode info since dnode info changed", info.config.vgId); vInfo("vgId:%d, save vnode info since dnode info changed", info.config.vgId);
(void)vnodeSaveInfo(dir, &info); if (vnodeSaveInfo(dir, &info) < 0) {
(void)vnodeCommitInfo(dir); vError("vgId:%d, failed to save vnode info since %s", info.config.vgId, tstrerror(terrno));
}
if (vnodeCommitInfo(dir) < 0) {
vError("vgId:%d, failed to commit vnode info since %s", info.config.vgId, tstrerror(terrno));
}
} }
// create handle // create handle
@ -405,7 +414,10 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
pVnode->blocked = false; pVnode->blocked = false;
pVnode->disableWrite = false; pVnode->disableWrite = false;
(void)tsem_init(&pVnode->syncSem, 0, 0); if (tsem_init(&pVnode->syncSem, 0, 0) != 0) {
vError("vgId:%d, failed to init semaphore", TD_VID(pVnode));
goto _err;
}
(void)taosThreadMutexInit(&pVnode->mutex, NULL); (void)taosThreadMutexInit(&pVnode->mutex, NULL);
(void)taosThreadCondInit(&pVnode->poolNotEmpty, NULL); (void)taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
@ -499,9 +511,9 @@ _err:
if (pVnode->pQuery) vnodeQueryClose(pVnode); if (pVnode->pQuery) vnodeQueryClose(pVnode);
if (pVnode->pTq) tqClose(pVnode->pTq); if (pVnode->pTq) tqClose(pVnode->pTq);
if (pVnode->pWal) walClose(pVnode->pWal); if (pVnode->pWal) walClose(pVnode->pWal);
if (pVnode->pTsdb) (void)tsdbClose(&pVnode->pTsdb); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
if (pVnode->pSma) (void)smaClose(pVnode->pSma); if (pVnode->pSma) smaClose(pVnode->pSma);
if (pVnode->pMeta) (void)metaClose(&pVnode->pMeta); if (pVnode->pMeta) metaClose(&pVnode->pMeta);
if (pVnode->freeList) vnodeCloseBufPool(pVnode); if (pVnode->freeList) vnodeCloseBufPool(pVnode);
taosMemoryFree(pVnode); taosMemoryFree(pVnode);
@ -518,13 +530,16 @@ void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); }
void vnodeClose(SVnode *pVnode) { void vnodeClose(SVnode *pVnode) {
if (pVnode) { if (pVnode) {
vnodeAWait(&pVnode->commitTask); vnodeAWait(&pVnode->commitTask);
(void)vnodeAChannelDestroy(&pVnode->commitChannel, true); if (vnodeAChannelDestroy(&pVnode->commitChannel, true) != 0) {
vError("vgId:%d, failed to destroy commit channel", TD_VID(pVnode));
}
vnodeSyncClose(pVnode); vnodeSyncClose(pVnode);
vnodeQueryClose(pVnode); vnodeQueryClose(pVnode);
tqClose(pVnode->pTq); tqClose(pVnode->pTq);
walClose(pVnode->pWal); walClose(pVnode->pWal);
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
(void)smaClose(pVnode->pSma); smaClose(pVnode->pSma);
if (pVnode->pMeta) metaClose(&pVnode->pMeta); if (pVnode->pMeta) metaClose(&pVnode->pMeta);
vnodeCloseBufPool(pVnode); vnodeCloseBufPool(pVnode);

View File

@ -274,13 +274,17 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
int64_t size; int64_t size;
code = taosFStatFile(pFile, &size, NULL); code = taosFStatFile(pFile, &size, NULL);
if (code != 0) { if (code != 0) {
(void)taosCloseFile(&pFile); if (taosCloseFile(&pFile) != 0) {
vError("vgId:%d, failed to close file", vgId);
}
TSDB_CHECK_CODE(code, lino, _exit); TSDB_CHECK_CODE(code, lino, _exit);
} }
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1); *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1);
if (*ppData == NULL) { if (*ppData == NULL) {
(void)taosCloseFile(&pFile); if (taosCloseFile(&pFile) != 0) {
vError("vgId:%d, failed to close file", vgId);
}
TSDB_CHECK_CODE(code = terrno, lino, _exit); TSDB_CHECK_CODE(code = terrno, lino, _exit);
} }
((SSnapDataHdr *)(*ppData))->type = SNAP_DATA_CFG; ((SSnapDataHdr *)(*ppData))->type = SNAP_DATA_CFG;
@ -289,11 +293,15 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) { if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) {
taosMemoryFree(*ppData); taosMemoryFree(*ppData);
(void)taosCloseFile(&pFile); if (taosCloseFile(&pFile) != 0) {
vError("vgId:%d, failed to close file", vgId);
}
TSDB_CHECK_CODE(code = terrno, lino, _exit); TSDB_CHECK_CODE(code = terrno, lino, _exit);
} }
(void)taosCloseFile(&pFile); if (taosCloseFile(&pFile) != 0) {
vError("vgId:%d, failed to close file", vgId);
}
pReader->cfgDone = 1; pReader->cfgDone = 1;
goto _exit; goto _exit;

View File

@ -466,7 +466,11 @@ static int32_t vnodePreProcessArbCheckSyncMsg(SVnode *pVnode, SRpcMsg *pMsg) {
return TSDB_CODE_INVALID_MSG; return TSDB_CODE_INVALID_MSG;
} }
(void)vnodePreCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token); int32_t ret = vnodePreCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token);
if (ret != 0) {
vError("vgId:%d, failed to preprocess arb check sync request since %s", TD_VID(pVnode), tstrerror(ret));
}
int32_t code = terrno; int32_t code = terrno;
tFreeSVArbCheckSyncReq(&syncReq); tFreeSVArbCheckSyncReq(&syncReq);
@ -710,7 +714,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
vTrace("vgId:%d, process %s request, code:0x%x index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), pRsp->code, vTrace("vgId:%d, process %s request, code:0x%x index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), pRsp->code,
ver); ver);
(void)walApplyVer(pVnode->pWal, ver); walApplyVer(pVnode->pWal, ver);
code = tqPushMsg(pVnode->pTq, pMsg->msgType); code = tqPushMsg(pVnode->pTq, pMsg->msgType);
if (code) { if (code) {
@ -881,7 +885,10 @@ int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo)
} }
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
(void)tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); int32_t code = tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
if (code) {
vError("failed to process sma result since %s", tstrerror(code));
}
} }
void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) { void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
@ -957,7 +964,10 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t ver, void *pReq,
int32_t code = metaDropTables(pVnode->pMeta, ttlReq.pTbUids); int32_t code = metaDropTables(pVnode->pMeta, ttlReq.pTbUids);
if (code) return code; if (code) return code;
(void)tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false); code = tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false);
if (code) {
vError("vgId:%d, failed to update tbUid list since %s", TD_VID(pVnode), tstrerror(code));
}
} }
end: end:
@ -1160,7 +1170,9 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
} }
} else { } else {
cRsp.code = TSDB_CODE_SUCCESS; cRsp.code = TSDB_CODE_SUCCESS;
(void)tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); if (tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid) < 0) {
vError("vgId:%d, failed to fetch tbUid list", TD_VID(pVnode));
}
if (taosArrayPush(tbUids, &pCreateReq->uid) == NULL) { if (taosArrayPush(tbUids, &pCreateReq->uid) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
rcode = -1; rcode = -1;
@ -1177,11 +1189,13 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
} }
vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids)); vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids));
(void)tqUpdateTbUidList(pVnode->pTq, tbUids, true); if (tqUpdateTbUidList(pVnode->pTq, tbUids, true) < 0) {
vError("vgId:%d, failed to update tbUid list since %s", TD_VID(pVnode), tstrerror(terrno));
}
if (tdUpdateTbUidList(pVnode->pSma, pStore, true) < 0) { if (tdUpdateTbUidList(pVnode->pSma, pStore, true) < 0) {
goto _exit; goto _exit;
} }
(void)tdUidStoreFree(pStore); pStore = tdUidStoreFree(pStore);
// prepare rsp // prepare rsp
int32_t ret = 0; int32_t ret = 0;
@ -1193,7 +1207,9 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
goto _exit; goto _exit;
} }
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
(void)tEncodeSVCreateTbBatchRsp(&encoder, &rsp); if (tEncodeSVCreateTbBatchRsp(&encoder, &rsp) != 0) {
vError("vgId:%d, failed to encode create table batch response", TD_VID(pVnode));
}
if (tsEnableAudit && tsEnableAuditCreateTable) { if (tsEnableAudit && tsEnableAuditCreateTable) {
int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId;
@ -1347,7 +1363,9 @@ _exit:
tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret); tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret);
pRsp->pCont = rpcMallocCont(pRsp->contLen); pRsp->pCont = rpcMallocCont(pRsp->contLen);
tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); tEncoderInit(&ec, pRsp->pCont, pRsp->contLen);
(void)tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp); if (tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp) != 0) {
vError("vgId:%d, failed to encode alter table response", TD_VID(pVnode));
}
tEncoderClear(&ec); tEncoderClear(&ec);
if (vMetaRsp.pSchemas) { if (vMetaRsp.pSchemas) {
taosMemoryFree(vMetaRsp.pSchemas); taosMemoryFree(vMetaRsp.pSchemas);
@ -1402,7 +1420,11 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
} }
} else { } else {
dropTbRsp.code = TSDB_CODE_SUCCESS; dropTbRsp.code = TSDB_CODE_SUCCESS;
if (tbUid > 0) (void)tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid); if (tbUid > 0) {
if (tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid) < 0) {
vError("vgId:%d, failed to fetch tbUid list", TD_VID(pVnode));
}
}
} }
if (taosArrayPush(rsp.pArray, &dropTbRsp) == NULL) { if (taosArrayPush(rsp.pArray, &dropTbRsp) == NULL) {
@ -1426,14 +1448,21 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
} }
} }
(void)tqUpdateTbUidList(pVnode->pTq, tbUids, false); if (tqUpdateTbUidList(pVnode->pTq, tbUids, false) < 0) {
(void)tdUpdateTbUidList(pVnode->pSma, pStore, false); vError("vgId:%d, failed to update tbUid list since %s", TD_VID(pVnode), tstrerror(terrno));
}
if (tdUpdateTbUidList(pVnode->pSma, pStore, false) < 0) {
goto _exit;
}
if (tsEnableAuditCreateTable) { if (tsEnableAuditCreateTable) {
int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId;
SName name = {0}; SName name = {0};
(void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); if (tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB) != 0) {
vError("vgId:%d, failed to get name from string", TD_VID(pVnode));
}
SStringBuilder sb = {0}; SStringBuilder sb = {0};
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
@ -1457,12 +1486,14 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
_exit: _exit:
taosArrayDestroy(tbUids); taosArrayDestroy(tbUids);
(void)tdUidStoreFree(pStore); pStore = tdUidStoreFree(pStore);
tDecoderClear(&decoder); tDecoderClear(&decoder);
tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret); tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret);
pRsp->pCont = rpcMallocCont(pRsp->contLen); pRsp->pCont = rpcMallocCont(pRsp->contLen);
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
(void)tEncodeSVDropTbBatchRsp(&encoder, &rsp); if (tEncodeSVDropTbBatchRsp(&encoder, &rsp) != 0) {
vError("vgId:%d, failed to encode drop table batch response", TD_VID(pVnode));
}
tEncoderClear(&encoder); tEncoderClear(&encoder);
taosArrayDestroy(rsp.pArray); taosArrayDestroy(rsp.pArray);
taosArrayDestroy(tbNames); taosArrayDestroy(tbNames);
@ -1802,7 +1833,9 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
} }
if (info.suid) { if (info.suid) {
(void)metaGetInfo(pVnode->pMeta, info.suid, &info, NULL); if (metaGetInfo(pVnode->pMeta, info.suid, &info, NULL) != 0) {
vWarn("vgId:%d, table uid:%" PRId64 " not exists", TD_VID(pVnode), info.suid);
}
} }
if (pSubmitTbData->sver != info.skmVer) { if (pSubmitTbData->sver != info.skmVer) {
@ -1898,7 +1931,9 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
if (taosArrayGetSize(newTbUids) > 0) { if (taosArrayGetSize(newTbUids) > 0) {
vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode), vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode),
(int32_t)taosArrayGetSize(newTbUids)); (int32_t)taosArrayGetSize(newTbUids));
(void)tqUpdateTbUidList(pVnode->pTq, newTbUids, true); if (tqUpdateTbUidList(pVnode->pTq, newTbUids, true) != 0) {
vError("vgId:%d, failed to update tbUid list", TD_VID(pVnode));
}
} }
_exit: _exit:
@ -1924,7 +1959,7 @@ _exit:
pVnode->monitor.strVgId, pVnode->monitor.strVgId,
pOriginalMsg->info.conn.user, pOriginalMsg->info.conn.user,
"Success"}; "Success"};
(void)taos_counter_add(tsInsertCounter, pSubmitRsp->affectedRows, sample_labels); int tv = taos_counter_add(tsInsertCounter, pSubmitRsp->affectedRows, sample_labels);
} }
if (code == 0) { if (code == 0) {
@ -2149,7 +2184,12 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
pVnode->config.sttTrigger = req.sttTrigger; pVnode->config.sttTrigger = req.sttTrigger;
} else { } else {
vnodeAWait(&pVnode->commitTask); vnodeAWait(&pVnode->commitTask);
(void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
int32_t ret = tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
if (ret != 0) {
vError("vgId:%d, failed to disable bg task since %s", TD_VID(pVnode), tstrerror(errno));
}
pVnode->config.sttTrigger = req.sttTrigger; pVnode->config.sttTrigger = req.sttTrigger;
tsdbEnableBgTask(pVnode->pTsdb); tsdbEnableBgTask(pVnode->pTsdb);
} }
@ -2167,7 +2207,9 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
} }
if (walChanged) { if (walChanged) {
(void)walAlter(pVnode->pWal, &pVnode->config.walCfg); if (walAlter(pVnode->pWal, &pVnode->config.walCfg) != 0) {
vError("vgId:%d, failed to alter wal config since %s", TD_VID(pVnode), tstrerror(errno));
}
} }
if (tsdbChanged) { if (tsdbChanged) {
@ -2351,7 +2393,9 @@ static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t ver, void *pR
} }
static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) { static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) {
(void)syncCheckMember(pVnode->sync); if (syncCheckMember(pVnode->sync) != 0) {
vError("vgId:%d, failed to check member", TD_VID(pVnode));
}
pRsp->msgType = TDMT_SYNC_CONFIG_CHANGE_RSP; pRsp->msgType = TDMT_SYNC_CONFIG_CHANGE_RSP;
pRsp->code = TSDB_CODE_SUCCESS; pRsp->code = TSDB_CODE_SUCCESS;
@ -2411,7 +2455,9 @@ static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t l
syncRsp.member1Token = syncReq.member1Token; syncRsp.member1Token = syncReq.member1Token;
syncRsp.vgId = TD_VID(pVnode); syncRsp.vgId = TD_VID(pVnode);
(void)vnodeCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token); if (vnodeCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token) != 0) {
vError("vgId:%d, failed to check assigned log syncd", TD_VID(pVnode));
}
syncRsp.errCode = terrno; syncRsp.errCode = terrno;
if (vnodeUpdateArbTerm(pVnode, syncReq.arbTerm) != 0) { if (vnodeUpdateArbTerm(pVnode, syncReq.arbTerm) != 0) {

View File

@ -28,7 +28,9 @@ static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
const STraceId *trace = &pMsg->info.traceId; const STraceId *trace = &pMsg->info.traceId;
vGTrace("vgId:%d, msg:%p wait block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg, vGTrace("vgId:%d, msg:%p wait block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg,
TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq); TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq);
(void)tsem_wait(&pVnode->syncSem); if (tsem_wait(&pVnode->syncSem) != 0) {
vError("vgId:%d, failed to wait sem", pVnode->config.vgId);
}
} }
static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
@ -41,7 +43,9 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
pVnode->blocked = false; pVnode->blocked = false;
pVnode->blockSec = 0; pVnode->blockSec = 0;
pVnode->blockSeq = 0; pVnode->blockSeq = 0;
(void)tsem_post(&pVnode->syncSem); if (tsem_post(&pVnode->syncSem) != 0) {
vError("vgId:%d, failed to post sem", pVnode->config.vgId);
}
} }
(void)taosThreadMutexUnlock(&pVnode->lock); (void)taosThreadMutexUnlock(&pVnode->lock);
} }
@ -69,7 +73,9 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) {
if (rsp.pCont == NULL) { if (rsp.pCont == NULL) {
pMsg->code = TSDB_CODE_OUT_OF_MEMORY; pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
} else { } else {
(void)tSerializeSEpSet(rsp.pCont, contLen, &newEpSet); if (tSerializeSEpSet(rsp.pCont, contLen, &newEpSet) != 0) {
vError("vgId:%d, failed to serialize ep set", pVnode->config.vgId);
}
rsp.contLen = contLen; rsp.contLen = contLen;
} }
@ -163,7 +169,9 @@ void vnodeProposeCommitOnNeed(SVnode *pVnode, bool atExit) {
rpcFreeCont(rpcMsg.pCont); rpcFreeCont(rpcMsg.pCont);
rpcMsg.pCont = NULL; rpcMsg.pCont = NULL;
} else { } else {
(void)tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg); if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
vTrace("vgId:%d, failed to put vnode commit to queue since %s", pVnode->config.vgId, terrstr());
}
} }
} }
@ -560,7 +568,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx)
} }
} while (true); } while (true);
(void)walApplyVer(pVnode->pWal, commitIdx); walApplyVer(pVnode->pWal, commitIdx);
pVnode->restored = true; pVnode->restored = true;
SStreamMeta *pMeta = pVnode->pTq->pStreamMeta; SStreamMeta *pMeta = pVnode->pTq->pStreamMeta;
@ -609,13 +617,17 @@ static void vnodeBecomeFollower(const SSyncFSM *pFsm) {
if (pVnode->blocked) { if (pVnode->blocked) {
pVnode->blocked = false; pVnode->blocked = false;
vDebug("vgId:%d, become follower and post block", pVnode->config.vgId); vDebug("vgId:%d, become follower and post block", pVnode->config.vgId);
(void)tsem_post(&pVnode->syncSem); if (tsem_post(&pVnode->syncSem) != 0) {
vError("vgId:%d, failed to post sync semaphore", pVnode->config.vgId);
}
} }
(void)taosThreadMutexUnlock(&pVnode->lock); (void)taosThreadMutexUnlock(&pVnode->lock);
if (pVnode->pTq) { if (pVnode->pTq) {
tqUpdateNodeStage(pVnode->pTq, false); tqUpdateNodeStage(pVnode->pTq, false);
(void)tqStopStreamTasksAsync(pVnode->pTq); if (tqStopStreamTasksAsync(pVnode->pTq) != 0) {
vError("vgId:%d, failed to stop stream tasks", pVnode->config.vgId);
}
} }
} }
@ -627,7 +639,9 @@ static void vnodeBecomeLearner(const SSyncFSM *pFsm) {
if (pVnode->blocked) { if (pVnode->blocked) {
pVnode->blocked = false; pVnode->blocked = false;
vDebug("vgId:%d, become learner and post block", pVnode->config.vgId); vDebug("vgId:%d, become learner and post block", pVnode->config.vgId);
(void)tsem_post(&pVnode->syncSem); if (tsem_post(&pVnode->syncSem) != 0) {
vError("vgId:%d, failed to post sync semaphore", pVnode->config.vgId);
}
} }
(void)taosThreadMutexUnlock(&pVnode->lock); (void)taosThreadMutexUnlock(&pVnode->lock);
} }
@ -750,14 +764,19 @@ int32_t vnodeSyncStart(SVnode *pVnode) {
void vnodeSyncPreClose(SVnode *pVnode) { void vnodeSyncPreClose(SVnode *pVnode) {
vInfo("vgId:%d, sync pre close", pVnode->config.vgId); vInfo("vgId:%d, sync pre close", pVnode->config.vgId);
(void)syncLeaderTransfer(pVnode->sync); int32_t code = syncLeaderTransfer(pVnode->sync);
if (code) {
vError("vgId:%d, failed to transfer leader since %s", pVnode->config.vgId, tstrerror(code));
}
syncPreStop(pVnode->sync); syncPreStop(pVnode->sync);
(void)taosThreadMutexLock(&pVnode->lock); (void)taosThreadMutexLock(&pVnode->lock);
if (pVnode->blocked) { if (pVnode->blocked) {
vInfo("vgId:%d, post block after close sync", pVnode->config.vgId); vInfo("vgId:%d, post block after close sync", pVnode->config.vgId);
pVnode->blocked = false; pVnode->blocked = false;
(void)tsem_post(&pVnode->syncSem); if (tsem_post(&pVnode->syncSem) != 0) {
vError("vgId:%d, failed to post block", pVnode->config.vgId);
}
} }
(void)taosThreadMutexUnlock(&pVnode->lock); (void)taosThreadMutexUnlock(&pVnode->lock);
} }
@ -792,7 +811,9 @@ void vnodeSyncCheckTimeout(SVnode *pVnode) {
pVnode->blocked = false; pVnode->blocked = false;
pVnode->blockSec = 0; pVnode->blockSec = 0;
pVnode->blockSeq = 0; pVnode->blockSeq = 0;
(void)tsem_post(&pVnode->syncSem); if (tsem_post(&pVnode->syncSem) != 0) {
vError("vgId:%d, failed to post block", pVnode->config.vgId);
}
} }
} }
(void)taosThreadMutexUnlock(&pVnode->lock); (void)taosThreadMutexUnlock(&pVnode->lock);

View File

@ -1461,7 +1461,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalo
pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES); pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES);
if (NULL == pRsp->pTableMeta) { if (NULL == pRsp->pTableMeta) {
ctgError("taosArrayInit %d failed", tbNum); ctgError("taosArrayInit %d failed", tbNum);
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_JRET(terrno);
} }
for (int32_t i = 0; i < tbNum; ++i) { for (int32_t i = 0; i < tbNum; ++i) {
@ -1476,7 +1476,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalo
if (NULL == taosArrayPush(pRsp->pTableMeta, &pTableMeta)) { if (NULL == taosArrayPush(pRsp->pTableMeta, &pTableMeta)) {
ctgError("taosArrayPush failed, idx:%d", i); ctgError("taosArrayPush failed, idx:%d", i);
taosMemoryFreeClear(pTableMeta); taosMemoryFreeClear(pTableMeta);
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); CTG_ERR_JRET(terrno);
} }
} }
} }

View File

@ -236,7 +236,7 @@ static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
taosArrayRemove(pExchangeInfo->pResultBlockList, 0); taosArrayRemove(pExchangeInfo->pResultBlockList, 0);
void* tmp = taosArrayPush(pExchangeInfo->pRecycledBlocks, &p); void* tmp = taosArrayPush(pExchangeInfo->pRecycledBlocks, &p);
if (!tmp) { if (!tmp) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
pTaskInfo->code = code; pTaskInfo->code = code;
T_LONG_JMP(pTaskInfo->env, code); T_LONG_JMP(pTaskInfo->env, code);
@ -590,7 +590,7 @@ int32_t buildTableScanOperatorParam(SOperatorParam** ppRes, SArray* pUidList, in
if (NULL == pScan->pUidList) { if (NULL == pScan->pUidList) {
taosMemoryFree(pScan); taosMemoryFree(pScan);
taosMemoryFreeClear(*ppRes); taosMemoryFreeClear(*ppRes);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
pScan->tableSeq = tableSeq; pScan->tableSeq = tableSeq;

View File

@ -73,7 +73,7 @@ int32_t doCreateTask(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC
p->schemaInfos = taosArrayInit(1, sizeof(SSchemaInfo)); p->schemaInfos = taosArrayInit(1, sizeof(SSchemaInfo));
if (p->id.str == NULL || p->schemaInfos == NULL) { if (p->id.str == NULL || p->schemaInfos == NULL) {
doDestroyTask(p); doDestroyTask(p);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
*pTaskInfo = p; *pTaskInfo = p;

View File

@ -437,41 +437,36 @@ int32_t tsortAddSource(SSortHandle* pSortHandle, void* pSource) {
static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSources, SSDataBlock* pBlock, static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSources, SSDataBlock* pBlock,
int32_t* sourceId, SArray* pPageIdList) { int32_t* sourceId, SArray* pPageIdList) {
int32_t code = 0;
int32_t lino = 0;
SSortSource* pSource = taosMemoryCalloc(1, sizeof(SSortSource)); SSortSource* pSource = taosMemoryCalloc(1, sizeof(SSortSource));
if (pSource == NULL) { QUERY_CHECK_NULL(pSource, code, lino, _err, terrno);
taosArrayDestroy(pPageIdList);
return terrno;
}
pSource->src.pBlock = pBlock; pSource->src.pBlock = pBlock;
pSource->pageIdList = pPageIdList; pSource->pageIdList = pPageIdList;
void* p = taosArrayPush(pAllSources, &pSource); SSortSource** p = taosArrayPush(pAllSources, &pSource);
if (p == NULL) { QUERY_CHECK_NULL(p, code, lino, _err, terrno);
taosArrayDestroy(pPageIdList); pSource = NULL;
return terrno;
}
(*sourceId) += 1; (*sourceId) += 1;
int32_t rowSize = blockDataGetSerialRowSize(pSource->src.pBlock); int32_t rowSize = blockDataGetSerialRowSize((*p)->src.pBlock);
// The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation // The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation
int32_t numOfRows = int32_t numOfRows =
(getBufPageSize(pBuf) - blockDataGetSerialMetaSize(taosArrayGetSize(pBlock->pDataBlock))) / rowSize; (getBufPageSize(pBuf) - blockDataGetSerialMetaSize(taosArrayGetSize(pBlock->pDataBlock))) / rowSize;
if (numOfRows <= 0) { QUERY_CHECK_CONDITION((numOfRows > 0), code, lino, _err, TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR);
qError("sort failed at: %s:%d", __func__, __LINE__);
taosArrayDestroy(pPageIdList);
return TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
}
int32_t code = blockDataEnsureCapacity(pSource->src.pBlock, numOfRows); code = blockDataEnsureCapacity((*p)->src.pBlock, numOfRows);
if (code != 0) { QUERY_CHECK_CODE(code, lino, _err);
qError("sort failed at: %s:%d", __func__, __LINE__);
taosArrayDestroy(pPageIdList);
}
return code; return code;
_err:
if (pSource) taosMemoryFree(pSource);
qError("sort failed at %s:%d since %s", __func__, lino, tstrerror(code));
return code;
} }
static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
@ -554,7 +549,12 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
return code; return code;
} }
return doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId, pPageIdList); code = doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId, pPageIdList);
if (code) {
blockDataDestroy(pBlock);
taosArrayDestroy(pPageIdList);
}
return code;
} }
static void setCurrentSourceDone(SSortSource* pSource, SSortHandle* pHandle) { static void setCurrentSourceDone(SSortSource* pSource, SSortHandle* pHandle) {
@ -1023,6 +1023,9 @@ static int32_t doSortForEachGroup(SSortHandle* pHandle, int32_t sortTimes, int32
QUERY_CHECK_CODE(code, lino, _err); QUERY_CHECK_CODE(code, lino, _err);
code = doAddNewExternalMemSource(pHandle->pBuf, pResList, pBlock, &pHandle->sourceId, pPageIdList); code = doAddNewExternalMemSource(pHandle->pBuf, pResList, pBlock, &pHandle->sourceId, pPageIdList);
if (code != TSDB_CODE_SUCCESS) {
blockDataDestroy(pBlock);
}
QUERY_CHECK_CODE(code, lino, _err); QUERY_CHECK_CODE(code, lino, _err);
} }
@ -2144,6 +2147,10 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray*
if (code) goto _error; if (code) goto _error;
code = doAddNewExternalMemSource(pHandle->pBuf, aExtSrc, pMemSrcBlk, &pHandle->sourceId, aPgId); code = doAddNewExternalMemSource(pHandle->pBuf, aExtSrc, pMemSrcBlk, &pHandle->sourceId, aPgId);
if (code != TSDB_CODE_SUCCESS) {
blockDataDestroy(pMemSrcBlk);
goto _error;
}
cleanupMergeSup(&sup); cleanupMergeSup(&sup);
tMergeTreeDestroy(&pTree); tMergeTreeDestroy(&pTree);
@ -2306,9 +2313,15 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
} }
code = tSimpleHashPut(mUidBlk, &pBlk->info.id.uid, sizeof(pBlk->info.id.uid), &tBlk, POINTER_BYTES); code = tSimpleHashPut(mUidBlk, &pBlk->info.id.uid, sizeof(pBlk->info.id.uid), &tBlk, POINTER_BYTES);
if (code != TSDB_CODE_SUCCESS) {
blockDataDestroy(tBlk);
}
QUERY_CHECK_CODE(code, lino, _err); QUERY_CHECK_CODE(code, lino, _err);
void* px = taosArrayPush(aBlkSort, &tBlk); void* px = taosArrayPush(aBlkSort, &tBlk);
if (px == NULL) {
blockDataDestroy(tBlk);
}
QUERY_CHECK_NULL(px, code, lino, _err, terrno); QUERY_CHECK_NULL(px, code, lino, _err, terrno);
} }
} }

View File

@ -80,6 +80,10 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe
IndexCache* pCache = mem->pCache; IndexCache* pCache = mem->pCache;
CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm));
if (pCt == NULL) {
return terrno;
}
pCt->colVal = term->colVal; pCt->colVal = term->colVal;
pCt->version = atomic_load_64(&pCache->version); pCt->version = atomic_load_64(&pCache->version);
@ -290,6 +294,10 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
IndexCache* pCache = mem->pCache; IndexCache* pCache = mem->pCache;
CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm)); CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm));
if (pCt == NULL) {
return terrno;
}
pCt->colVal = term->colVal; pCt->colVal = term->colVal;
pCt->version = atomic_load_64(&pCache->version); pCt->version = atomic_load_64(&pCache->version);
@ -539,6 +547,10 @@ int idxCacheSchedToMerge(IndexCache* pCache, bool notify) {
schedMsg.ahandle = pCache; schedMsg.ahandle = pCache;
if (notify) { if (notify) {
schedMsg.thandle = taosMemoryMalloc(1); schedMsg.thandle = taosMemoryMalloc(1);
if (schedMsg.thandle == NULL) {
indexError("fail to schedule merge task");
return terrno;
}
} }
schedMsg.msg = NULL; schedMsg.msg = NULL;
idxAcquireRef(pCache->index->refId); idxAcquireRef(pCache->index->refId);

View File

@ -260,6 +260,9 @@ char* idxPackJsonData(SIndexTerm* itm) {
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1; int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
char* buf = (char*)taosMemoryCalloc(1, sz); char* buf = (char*)taosMemoryCalloc(1, sz);
if (buf == NULL) {
return NULL;
}
char* p = buf; char* p = buf;
memcpy(p, itm->colName, itm->nColName); memcpy(p, itm->colName, itm->nColName);
@ -288,6 +291,9 @@ char* idxPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip) {
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1; int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
char* buf = (char*)taosMemoryCalloc(1, sz); char* buf = (char*)taosMemoryCalloc(1, sz);
if (buf == NULL) {
return NULL;
}
char* p = buf; char* p = buf;
memcpy(p, itm->colName, itm->nColName); memcpy(p, itm->colName, itm->nColName);
@ -315,6 +321,10 @@ char* idxPackJsonDataPrefixNoType(SIndexTerm* itm, int32_t* skip) {
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1; int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
char* buf = (char*)taosMemoryCalloc(1, sz); char* buf = (char*)taosMemoryCalloc(1, sz);
if (buf == NULL) {
return NULL;
}
char* p = buf; char* p = buf;
memcpy(p, itm->colName, itm->nColName); memcpy(p, itm->colName, itm->nColName);

View File

@ -57,9 +57,17 @@ void fstUnFinishedNodesDestroy(FstUnFinishedNodes* nodes) {
void fstUnFinishedNodesPushEmpty(FstUnFinishedNodes* nodes, bool isFinal) { void fstUnFinishedNodesPushEmpty(FstUnFinishedNodes* nodes, bool isFinal) {
FstBuilderNode* node = taosMemoryMalloc(sizeof(FstBuilderNode)); FstBuilderNode* node = taosMemoryMalloc(sizeof(FstBuilderNode));
if (node == NULL) {
return;
}
node->isFinal = isFinal; node->isFinal = isFinal;
node->finalOutput = 0; node->finalOutput = 0;
node->trans = taosArrayInit(16, sizeof(FstTransition)); node->trans = taosArrayInit(16, sizeof(FstTransition));
if (node->trans == NULL) {
taosMemoryFree(node);
return;
}
FstBuilderNodeUnfinished un = {.node = node, .last = NULL}; FstBuilderNodeUnfinished un = {.node = node, .last = NULL};
if (taosArrayPush(nodes->stack, &un) == NULL) { if (taosArrayPush(nodes->stack, &un) == NULL) {
@ -112,6 +120,9 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes* nodes, FstSlice bs, Output
for (uint64_t i = 1; i < len; i++) { for (uint64_t i = 1; i < len; i++) {
FstBuilderNode* n = taosMemoryMalloc(sizeof(FstBuilderNode)); FstBuilderNode* n = taosMemoryMalloc(sizeof(FstBuilderNode));
if (n == NULL) {
return;
}
n->isFinal = false; n->isFinal = false;
n->finalOutput = 0; n->finalOutput = 0;
n->trans = taosArrayInit(16, sizeof(FstTransition)); n->trans = taosArrayInit(16, sizeof(FstTransition));
@ -295,6 +306,9 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode
if (sz > TRANS_INDEX_THRESHOLD) { if (sz > TRANS_INDEX_THRESHOLD) {
// A value of 255 indicates that no transition exists for the byte at that idx // A value of 255 indicates that no transition exists for the byte at that idx
uint8_t* index = (uint8_t*)taosMemoryMalloc(sizeof(uint8_t) * 256); uint8_t* index = (uint8_t*)taosMemoryMalloc(sizeof(uint8_t) * 256);
if (index == NULL) {
return;
}
memset(index, 255, sizeof(uint8_t) * 256); memset(index, 255, sizeof(uint8_t) * 256);
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
FstTransition* t = taosArrayGet(node->trans, i); FstTransition* t = taosArrayGet(node->trans, i);
@ -973,6 +987,10 @@ Fst* fstCreate(FstSlice* slice) {
fst->meta->checkSum = checkSum; fst->meta->checkSum = checkSum;
FstSlice* s = taosMemoryCalloc(1, sizeof(FstSlice)); FstSlice* s = taosMemoryCalloc(1, sizeof(FstSlice));
if (s == NULL) {
goto FST_CREAT_FAILED;
}
*s = fstSliceCopy(slice, 0, FST_SLICE_LEN(slice) - 1); *s = fstSliceCopy(slice, 0, FST_SLICE_LEN(slice) - 1);
fst->data = s; fst->data = s;
@ -1326,6 +1344,9 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) {
int32_t isz = taosArrayGetSize(sws->inp); int32_t isz = taosArrayGetSize(sws->inp);
uint8_t* buf = (uint8_t*)taosMemoryMalloc(isz * sizeof(uint8_t)); uint8_t* buf = (uint8_t*)taosMemoryMalloc(isz * sizeof(uint8_t));
if (buf == NULL) {
return NULL;
}
for (uint32_t i = 0; i < isz; i++) { for (uint32_t i = 0; i < isz; i++) {
buf[i] = *(uint8_t*)taosArrayGet(sws->inp, i); buf[i] = *(uint8_t*)taosArrayGet(sws->inp, i);
} }

View File

@ -28,6 +28,11 @@ StartWithStateValue* startWithStateValueCreate(StartWithStateKind kind, ValueTyp
} else if (ty == FST_CHAR) { } else if (ty == FST_CHAR) {
size_t len = strlen((char*)val); size_t len = strlen((char*)val);
sv->ptr = (char*)taosMemoryCalloc(1, len + 1); sv->ptr = (char*)taosMemoryCalloc(1, len + 1);
if (sv->ptr == NULL) {
taosMemoryFree(sv);
return NULL;
}
memcpy(sv->ptr, val, len); memcpy(sv->ptr, val, len);
} else if (ty == FST_ARRAY) { } else if (ty == FST_ARRAY) {
// TODO, // TODO,
@ -63,6 +68,11 @@ StartWithStateValue* startWithStateValueDump(StartWithStateValue* sv) {
} else if (nsv->type == FST_CHAR) { } else if (nsv->type == FST_CHAR) {
size_t len = strlen(sv->ptr); size_t len = strlen(sv->ptr);
nsv->ptr = (char*)taosMemoryCalloc(1, len + 1); nsv->ptr = (char*)taosMemoryCalloc(1, len + 1);
if (nsv->ptr == NULL) {
taosMemoryFree(nsv);
return NULL;
}
memcpy(nsv->ptr, sv->ptr, len); memcpy(nsv->ptr, sv->ptr, len);
} else if (nsv->type == FST_ARRAY) { } else if (nsv->type == FST_ARRAY) {
// //

View File

@ -134,6 +134,9 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
int32_t cacheMemSize = sizeof(SDataBlock) + kBlockSize; int32_t cacheMemSize = sizeof(SDataBlock) + kBlockSize;
SDataBlock* blk = taosMemoryCalloc(1, cacheMemSize); SDataBlock* blk = taosMemoryCalloc(1, cacheMemSize);
if (blk == NULL) {
return terrno;
}
blk->blockId = blkId; blk->blockId = blkId;
blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize); blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize);
if (blk->nread < kBlockSize && blk->nread < len) { if (blk->nread < kBlockSize && blk->nread < len) {
@ -211,6 +214,10 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int
ctx->file.wBufOffset = 0; ctx->file.wBufOffset = 0;
ctx->file.wBufCap = kBlockSize * 4; ctx->file.wBufCap = kBlockSize * 4;
ctx->file.wBuf = taosMemoryCalloc(1, ctx->file.wBufCap); ctx->file.wBuf = taosMemoryCalloc(1, ctx->file.wBufCap);
if (ctx->file.wBuf == NULL) {
indexError("failed to allocate memory for write buffer");
goto END;
}
} else { } else {
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ); ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
code = taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL); code = taosFStatFile(ctx->file.pFile, &ctx->file.size, NULL);
@ -228,6 +235,11 @@ IFileCtx* idxFileCtxCreate(WriterType type, const char* path, bool readOnly, int
} }
} else if (ctx->type == TMEMORY) { } else if (ctx->type == TMEMORY) {
ctx->mem.buf = taosMemoryCalloc(1, sizeof(char) * capacity); ctx->mem.buf = taosMemoryCalloc(1, sizeof(char) * capacity);
if (ctx->mem.buf == NULL) {
indexError("failed to allocate memory for memory buffer");
goto END;
}
ctx->mem.cap = capacity; ctx->mem.cap = capacity;
} }
@ -325,6 +337,10 @@ int idxFileFlush(IdxFstFile* write) {
void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) { void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) {
uint8_t* buf = taosMemoryCalloc(8, sizeof(uint8_t)); uint8_t* buf = taosMemoryCalloc(8, sizeof(uint8_t));
if (buf == NULL) {
indexError("failed to allocate memory for packing uint");
return;
}
for (uint8_t i = 0; i < nBytes; i++) { for (uint8_t i = 0; i < nBytes; i++) {
buf[i] = (uint8_t)n; buf[i] = (uint8_t)n;
n = n >> 8; n = n >> 8;

View File

@ -80,6 +80,10 @@ FstSlice fstSliceCreate(uint8_t* data, uint64_t len) {
str->ref = 1; str->ref = 1;
str->len = len; str->len = len;
str->data = taosMemoryMalloc(len * sizeof(uint8_t)); str->data = taosMemoryMalloc(len * sizeof(uint8_t));
if (str == NULL || str->data == NULL) {
taosMemoryFree(str);
return (FstSlice){.str = NULL, .start = 0, .end = 0};
}
if (data != NULL && str->data != NULL) { if (data != NULL && str->data != NULL) {
memcpy(str->data, data, len); memcpy(str->data, data, len);

View File

@ -799,6 +799,10 @@ static bool tfileIteratorNext(Iterate* iiter) {
int32_t sz = 0; int32_t sz = 0;
char* ch = (char*)fstSliceData(&rt->data, &sz); char* ch = (char*)fstSliceData(&rt->data, &sz);
colVal = taosMemoryCalloc(1, sz + 1); colVal = taosMemoryCalloc(1, sz + 1);
if (colVal == NULL) {
return false;
}
memcpy(colVal, ch, sz); memcpy(colVal, ch, sz);
offset = (uint64_t)(rt->out.out); offset = (uint64_t)(rt->out.out);
@ -835,6 +839,10 @@ Iterate* tfileIteratorCreate(TFileReader* reader) {
} }
Iterate* iter = taosMemoryCalloc(1, sizeof(Iterate)); Iterate* iter = taosMemoryCalloc(1, sizeof(Iterate));
if (iter == NULL) {
return NULL;
}
iter->iter = tfileFstIteratorCreate(reader); iter->iter = tfileFstIteratorCreate(reader);
if (iter->iter == NULL) { if (iter->iter == NULL) {
taosMemoryFree(iter); taosMemoryFree(iter);
@ -843,6 +851,11 @@ Iterate* tfileIteratorCreate(TFileReader* reader) {
iter->next = tfileIteratorNext; iter->next = tfileIteratorNext;
iter->getValue = tifileIterateGetValue; iter->getValue = tifileIterateGetValue;
iter->val.val = taosArrayInit(1, sizeof(uint64_t)); iter->val.val = taosArrayInit(1, sizeof(uint64_t));
if (iter->val.val == NULL) {
tfileIteratorDestroy(iter);
return NULL;
}
iter->val.colVal = NULL; iter->val.colVal = NULL;
return iter; return iter;
} }

View File

@ -90,6 +90,10 @@ int32_t iUnion(SArray *in, SArray *out) {
} }
MergeIndex *mi = taosMemoryCalloc(sz, sizeof(MergeIndex)); MergeIndex *mi = taosMemoryCalloc(sz, sizeof(MergeIndex));
if (mi == NULL) {
return terrno;
}
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
SArray *t = taosArrayGetP(in, i); SArray *t = taosArrayGetP(in, i);
mi[i].len = (int32_t)taosArrayGetSize(t); mi[i].len = (int32_t)taosArrayGetSize(t);

View File

@ -46,7 +46,7 @@ int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData) {
} }
pNew->aCol = taosArrayDup(pDataBlock->pData->aCol, NULL); pNew->aCol = taosArrayDup(pDataBlock->pData->aCol, NULL);
if (!pNew->aCol) { if (!pNew->aCol) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
taosMemoryFreeClear(*pData); taosMemoryFreeClear(*pData);
return code; return code;
} }
@ -951,7 +951,7 @@ int32_t qResetStmtColumns(SArray* pCols, bool deepClear) {
SColData* pCol = (SColData*)taosArrayGet(pCols, i); SColData* pCol = (SColData*)taosArrayGet(pCols, i);
if (pCol == NULL) { if (pCol == NULL) {
qError("qResetStmtColumns column is NULL"); qError("qResetStmtColumns column is NULL");
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
if (deepClear) { if (deepClear) {
tColDataDeepClear(pCol); tColDataDeepClear(pCol);
@ -971,7 +971,7 @@ int32_t qResetStmtDataBlock(STableDataCxt* block, bool deepClear) {
SColData* pCol = (SColData*)taosArrayGet(pBlock->pData->aCol, i); SColData* pCol = (SColData*)taosArrayGet(pBlock->pData->aCol, i);
if (pCol == NULL) { if (pCol == NULL) {
qError("qResetStmtDataBlock column is NULL"); qError("qResetStmtDataBlock column is NULL");
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
if (deepClear) { if (deepClear) {
tColDataDeepClear(pCol); tColDataDeepClear(pCol);
@ -1033,7 +1033,7 @@ int32_t qCloneStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, bool rese
pNewTb->aCol = taosArrayDup(pCxt->pData->aCol, NULL); pNewTb->aCol = taosArrayDup(pCxt->pData->aCol, NULL);
if (NULL == pNewTb->aCol) { if (NULL == pNewTb->aCol) {
insDestroyTableDataCxt(*pDst); insDestroyTableDataCxt(*pDst);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
pNewCxt->pData = pNewTb; pNewCxt->pData = pNewTb;

View File

@ -856,7 +856,7 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList,
code = buildSubmitReq(src->vgId, src->pData, &dst->pData, &dst->size); code = buildSubmitReq(src->vgId, src->pData, &dst->pData, &dst->size);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = (NULL == taosArrayPush(pDataBlocks, &dst) ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS); code = (NULL == taosArrayPush(pDataBlocks, &dst) ? terrno : TSDB_CODE_SUCCESS);
} }
} }

View File

@ -522,7 +522,7 @@ static int32_t rewriteDropTableWithMetaCache(STranslateContext* pCxt) {
if (!pMetaCache->pTableMeta && if (!pMetaCache->pTableMeta &&
!(pMetaCache->pTableMeta = !(pMetaCache->pTableMeta =
taosHashInit(tbMetaExSize, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK))) { taosHashInit(tbMetaExSize, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK))) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
SMetaRes** ppMetaRes = NULL; SMetaRes** ppMetaRes = NULL;
@ -2087,7 +2087,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
pVal->datum.p = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE); pVal->datum.p = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
if (NULL == pVal->datum.p) { if (NULL == pVal->datum.p) {
if (isHexChar) taosMemoryFree(data); if (isHexChar) taosMemoryFree(data);
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); return generateDealNodeErrMsg(pCxt, terrno);
} }
varDataSetLen(pVal->datum.p, size); varDataSetLen(pVal->datum.p, size);
memcpy(varDataVal(pVal->datum.p), data, size); memcpy(varDataVal(pVal->datum.p), data, size);
@ -2103,7 +2103,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, vlen); int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, vlen);
pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1); pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1);
if (NULL == pVal->datum.p) { if (NULL == pVal->datum.p) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); return generateDealNodeErrMsg(pCxt, terrno);
} }
varDataSetLen(pVal->datum.p, len); varDataSetLen(pVal->datum.p, len);
strncpy(varDataVal(pVal->datum.p), pVal->literal, len); strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
@ -2119,7 +2119,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1); pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
if (NULL == pVal->datum.p) { if (NULL == pVal->datum.p) {
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); return generateDealNodeErrMsg(pCxt, terrno);
} }
int32_t len = 0; int32_t len = 0;
@ -6264,7 +6264,7 @@ static int32_t unionEqualCondTbnamesOfSameTable(SArray* aTableTbnames, SEqCondTb
SEqCondTbNameTableInfo* info = taosArrayGet(aTableTbnames, i); SEqCondTbNameTableInfo* info = taosArrayGet(aTableTbnames, i);
if (info->pRealTable == pInfo->pRealTable) { if (info->pRealTable == pInfo->pRealTable) {
if (NULL == taosArrayAddAll(info->aTbnames, pInfo->aTbnames)) { if (NULL == taosArrayAddAll(info->aTbnames, pInfo->aTbnames)) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
break; break;
} }
taosArrayDestroy(pInfo->aTbnames); taosArrayDestroy(pInfo->aTbnames);

View File

@ -1124,7 +1124,7 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
if (TSDB_CODE_SUCCESS == code && NULL != pVgList) { if (TSDB_CODE_SUCCESS == code && NULL != pVgList) {
*pVgInfo = taosArrayDup(pVgList, NULL); *pVgInfo = taosArrayDup(pVgList, NULL);
if (NULL == *pVgInfo) { if (NULL == *pVgInfo) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
} }
} }
return code; return code;
@ -1439,7 +1439,7 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
*pDnodes = taosArrayDup((SArray*)pRes->pRes, NULL); *pDnodes = taosArrayDup((SArray*)pRes->pRes, NULL);
if (NULL == *pDnodes) { if (NULL == *pDnodes) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -427,7 +427,7 @@ void cleanDir(const char* pPath, const char* id) {
if (taosIsDir(pPath)) { if (taosIsDir(pPath)) {
taosRemoveDir(pPath); taosRemoveDir(pPath);
(void)taosMkDir(pPath); TAOS_UNUSED(taosMkDir(pPath));
stInfo("%s clear dir:%s, succ", id, pPath); stInfo("%s clear dir:%s, succ", id, pPath);
} }
} }
@ -533,7 +533,7 @@ int32_t rebuildFromRemoteChkp_s3(const char* key, char* chkpPath, int64_t chkpId
_EXIT: _EXIT:
if (code != 0) { if (code != 0) {
if (rename) { if (rename) {
(void)taosRenameFile(defaultTmp, defaultPath); TAOS_UNUSED(taosRenameFile(defaultTmp, defaultPath));
} }
} }
@ -653,13 +653,13 @@ int32_t backendFileCopyFilesImpl(const char* src, const char* dst) {
taosMemoryFreeClear(srcName); taosMemoryFreeClear(srcName);
taosMemoryFreeClear(dstName); taosMemoryFreeClear(dstName);
(void)taosCloseDir(&pDir); TAOS_UNUSED(taosCloseDir(&pDir));
return code; return code;
_ERROR: _ERROR:
taosMemoryFreeClear(srcName); taosMemoryFreeClear(srcName);
taosMemoryFreeClear(dstName); taosMemoryFreeClear(dstName);
(void)taosCloseDir(&pDir); TAOS_UNUSED(taosCloseDir(&pDir));
return code; return code;
} }
@ -833,9 +833,8 @@ int32_t streamBackendInit(const char* streamPath, int64_t chkpId, int32_t vgId,
pHandle->list = tdListNew(sizeof(SCfComparator)); pHandle->list = tdListNew(sizeof(SCfComparator));
TSDB_CHECK_NULL(pHandle->list, code, lino, _EXIT, terrno); TSDB_CHECK_NULL(pHandle->list, code, lino, _EXIT, terrno);
(void)taosThreadMutexInit(&pHandle->mutex, NULL); TAOS_UNUSED(taosThreadMutexInit(&pHandle->mutex, NULL));
(void)taosThreadMutexInit(&pHandle->cfMutex, NULL); TAOS_UNUSED(taosThreadMutexInit(&pHandle->cfMutex, NULL));
pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
TSDB_CHECK_NULL(pHandle->cfInst, code, lino, _EXIT, terrno); TSDB_CHECK_NULL(pHandle->cfInst, code, lino, _EXIT, terrno);
@ -948,11 +947,11 @@ void streamBackendCleanup(void* arg) {
void streamBackendHandleCleanup(void* arg) { void streamBackendHandleCleanup(void* arg) {
SBackendCfWrapper* wrapper = arg; SBackendCfWrapper* wrapper = arg;
bool remove = wrapper->remove; bool remove = wrapper->remove;
(void)taosThreadRwlockWrlock(&wrapper->rwLock); TAOS_UNUSED(taosThreadRwlockWrlock(&wrapper->rwLock));
stDebug("start to do-close backendwrapper %p, %s", wrapper, wrapper->idstr); stDebug("start to do-close backendwrapper %p, %s", wrapper, wrapper->idstr);
if (wrapper->rocksdb == NULL) { if (wrapper->rocksdb == NULL) {
(void)taosThreadRwlockUnlock(&wrapper->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&wrapper->rwLock));
return; return;
} }
@ -1003,9 +1002,9 @@ void streamBackendHandleCleanup(void* arg) {
wrapper->readOpts = NULL; wrapper->readOpts = NULL;
taosMemoryFreeClear(wrapper->cfOpts); taosMemoryFreeClear(wrapper->cfOpts);
taosMemoryFreeClear(wrapper->param); taosMemoryFreeClear(wrapper->param);
(void)taosThreadRwlockUnlock(&wrapper->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&wrapper->rwLock));
(void)taosThreadRwlockDestroy(&wrapper->rwLock); TAOS_UNUSED(taosThreadRwlockDestroy(&wrapper->rwLock));
wrapper->rocksdb = NULL; wrapper->rocksdb = NULL;
// taosReleaseRef(streamBackendId, wrapper->backendId); // taosReleaseRef(streamBackendId, wrapper->backendId);
@ -1099,7 +1098,7 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
int32_t code = 0; int32_t code = 0;
STaskDbWrapper* pBackend = arg; STaskDbWrapper* pBackend = arg;
SArray * chkpDel = NULL, *chkpDup = NULL; SArray * chkpDel = NULL, *chkpDup = NULL;
(void)taosThreadRwlockWrlock(&pBackend->chkpDirLock); TAOS_UNUSED(taosThreadRwlockWrlock(&pBackend->chkpDirLock));
if (taosArrayPush(pBackend->chkpSaved, &chkpId) == NULL) { if (taosArrayPush(pBackend->chkpSaved, &chkpId) == NULL) {
TAOS_CHECK_GOTO(terrno, NULL, _exception); TAOS_CHECK_GOTO(terrno, NULL, _exception);
@ -1152,7 +1151,7 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
taosArrayDestroy(pBackend->chkpSaved); taosArrayDestroy(pBackend->chkpSaved);
pBackend->chkpSaved = chkpDup; pBackend->chkpSaved = chkpDup;
(void)taosThreadRwlockUnlock(&pBackend->chkpDirLock); TAOS_UNUSED(taosThreadRwlockUnlock(&pBackend->chkpDirLock));
for (int i = 0; i < taosArrayGetSize(chkpDel); i++) { for (int i = 0; i < taosArrayGetSize(chkpDel); i++) {
int64_t id = *(int64_t*)taosArrayGet(chkpDel, i); int64_t id = *(int64_t*)taosArrayGet(chkpDel, i);
@ -1169,7 +1168,7 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
_exception: _exception:
taosArrayDestroy(chkpDup); taosArrayDestroy(chkpDup);
taosArrayDestroy(chkpDel); taosArrayDestroy(chkpDel);
(void)taosThreadRwlockUnlock(&pBackend->chkpDirLock); TAOS_UNUSED(taosThreadRwlockUnlock(&pBackend->chkpDirLock));
return code; return code;
} }
@ -1315,12 +1314,12 @@ int32_t taskDbLoadChkpInfo(STaskDbWrapper* pBackend) {
taosArraySort(pBackend->chkpSaved, chkpIdComp); taosArraySort(pBackend->chkpSaved, chkpIdComp);
taosMemoryFree(pChkpDir); taosMemoryFree(pChkpDir);
(void)taosCloseDir(&pDir); TAOS_UNUSED(taosCloseDir(&pDir));
return 0; return 0;
_exception: _exception:
taosMemoryFree(pChkpDir); taosMemoryFree(pChkpDir);
(void)taosCloseDir(&pDir); TAOS_UNUSED(taosCloseDir(&pDir));
return code; return code;
} }
int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_handle_t*** ppHandle) { int32_t chkpGetAllDbCfHandle2(STaskDbWrapper* pBackend, rocksdb_column_family_handle_t*** ppHandle) {
@ -1561,7 +1560,7 @@ void* taskAcquireDb(int64_t refId) {
} }
void taskReleaseDb(int64_t refId) { void taskReleaseDb(int64_t refId) {
// release // release
(void)taosReleaseRef(taskDbWrapperId, refId); TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
} }
int64_t taskGetDBRef(void* arg) { int64_t taskGetDBRef(void* arg) {
@ -1622,7 +1621,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId)
code = 0; code = 0;
_EXIT: _EXIT:
taosMemoryFree(pDst); taosMemoryFree(pDst);
(void)taosCloseFile(&pFile); TAOS_UNUSED(taosCloseFile(&pFile));
return code; return code;
} }
int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) { int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
@ -1677,7 +1676,7 @@ int32_t chkpAddExtraInfo(char* pChkpIdDir, int64_t chkpId, int64_t processId) {
code = 0; code = 0;
_EXIT: _EXIT:
(void)taosCloseFile(&pFile); TAOS_UNUSED(taosCloseFile(&pFile));
taosMemoryFree(pDst); taosMemoryFree(pDst);
return code; return code;
} }
@ -1735,7 +1734,7 @@ int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId, int64_t processId) {
goto _EXIT; goto _EXIT;
} }
(void)atomic_store_64(&pTaskDb->dataWritten, 0); TAOS_UNUSED(atomic_store_64(&pTaskDb->dataWritten, 0));
pTaskDb->chkpId = chkpId; pTaskDb->chkpId = chkpId;
_EXIT: _EXIT:
@ -1743,13 +1742,13 @@ _EXIT:
// clear checkpoint dir if failed // clear checkpoint dir if failed
if (code != 0 && pChkpDir != NULL) { if (code != 0 && pChkpDir != NULL) {
if (taosDirExist(pChkpIdDir)) { if (taosDirExist(pChkpIdDir)) {
(void)taosRemoveDir(pChkpIdDir); TAOS_UNUSED(taosRemoveDir(pChkpIdDir));
} }
} }
taosMemoryFree(pChkpIdDir); taosMemoryFree(pChkpIdDir);
taosMemoryFree(pChkpDir); taosMemoryFree(pChkpDir);
(void)taosReleaseRef(taskDbWrapperId, refId); TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
taosMemoryFree(ppCf); taosMemoryFree(ppCf);
return code; return code;
} }
@ -1822,7 +1821,7 @@ int defaultKeyComp(void* state, const char* aBuf, size_t aLen, const char* bBuf,
} }
int streamStateValueIsStale(char* v) { int streamStateValueIsStale(char* v) {
int64_t ts = 0; int64_t ts = 0;
(void)taosDecodeFixedI64(v, &ts); TAOS_UNUSED(taosDecodeFixedI64(v, &ts));
return (ts != 0 && ts < taosGetTimestampMs()) ? 1 : 0; return (ts != 0 && ts < taosGetTimestampMs()) ? 1 : 0;
} }
int iterValueIsStale(rocksdb_iterator_t* iter) { int iterValueIsStale(rocksdb_iterator_t* iter) {
@ -1865,8 +1864,8 @@ int stateKeyDBComp(void* state, const char* aBuf, size_t aLen, const char* bBuf,
p1 = taosDecodeFixedI64(p1, &key1.key.ts); p1 = taosDecodeFixedI64(p1, &key1.key.ts);
p2 = taosDecodeFixedI64(p2, &key2.key.ts); p2 = taosDecodeFixedI64(p2, &key2.key.ts);
(void)taosDecodeFixedI64(p1, &key1.opNum); TAOS_UNUSED(taosDecodeFixedI64(p1, &key1.opNum));
(void)taosDecodeFixedI64(p2, &key2.opNum); TAOS_UNUSED(taosDecodeFixedI64(p2, &key2.opNum));
return stateKeyCmpr(&key1, sizeof(key1), &key2, sizeof(key2)); return stateKeyCmpr(&key1, sizeof(key1), &key2, sizeof(key2));
} }
@ -2062,8 +2061,8 @@ int parKeyDBComp(void* state, const char* aBuf, size_t aLen, const char* bBuf, s
char* p1 = (char*)aBuf; char* p1 = (char*)aBuf;
char* p2 = (char*)bBuf; char* p2 = (char*)bBuf;
(void)taosDecodeFixedI64(p1, &w1); TAOS_UNUSED(taosDecodeFixedI64(p1, &w1));
(void)taosDecodeFixedI64(p2, &w2); TAOS_UNUSED(taosDecodeFixedI64(p2, &w2));
if (w1 == w2) { if (w1 == w2) {
return 0; return 0;
} else { } else {
@ -2107,7 +2106,7 @@ int32_t valueIsStale(void* k, int64_t ts) {
} }
void destroyCompare(void* arg) { void destroyCompare(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return; return;
} }
@ -2190,7 +2189,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
// compatiable with previous data // compatiable with previous data
p = taosDecodeBinary(p, (void**)&pOutput, key.len); p = taosDecodeBinary(p, (void**)&pOutput, key.len);
if (p == NULL) { if (p == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto _EXCEPT; goto _EXCEPT;
} }
@ -2205,7 +2204,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
if (key.compress == 1) { if (key.compress == 1) {
p = taosDecodeBinary(p, (void**)&pCompressData, key.len); p = taosDecodeBinary(p, (void**)&pCompressData, key.len);
if (p == NULL) { if (p == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto _EXCEPT; goto _EXCEPT;
} }
pOutput = taosMemoryCalloc(1, key.rawLen); pOutput = taosMemoryCalloc(1, key.rawLen);
@ -2224,7 +2223,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
} else { } else {
p = taosDecodeBinary(p, (void**)&pOutput, key.len); p = taosDecodeBinary(p, (void**)&pOutput, key.len);
if (p == NULL) { if (p == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto _EXCEPT; goto _EXCEPT;
} }
} }
@ -2251,31 +2250,28 @@ _EXCEPT:
} }
const char* compareDefaultName(void* arg) { const char* compareDefaultName(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return ginitDict[0].key; return ginitDict[0].key;
} }
const char* compareStateName(void* arg) { const char* compareStateName(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return ginitDict[1].key; return ginitDict[1].key;
} }
const char* compareWinKeyName(void* arg) { const char* compareWinKeyName(void* arg) { return ginitDict[2].key; }
(void)arg;
return ginitDict[2].key;
}
const char* compareSessionKeyName(void* arg) { const char* compareSessionKeyName(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return ginitDict[3].key; return ginitDict[3].key;
} }
const char* compareFuncKeyName(void* arg) { const char* compareFuncKeyName(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return ginitDict[4].key; return ginitDict[4].key;
} }
const char* compareParKeyName(void* arg) { const char* compareParKeyName(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return ginitDict[5].key; return ginitDict[5].key;
} }
const char* comparePartagKeyName(void* arg) { const char* comparePartagKeyName(void* arg) {
(void)arg; TAOS_UNUSED(arg);
return ginitDict[6].key; return ginitDict[6].key;
} }
@ -2303,7 +2299,7 @@ const char* compactFilteFactoryNameFunc(void* arg) {
return "stream_compact_factory_filter_func"; return "stream_compact_factory_filter_func";
} }
void destroyCompactFilte(void* arg) { (void)arg; } void destroyCompactFilte(void* arg) { TAOS_UNUSED(arg); }
unsigned char compactFilte(void* arg, int level, const char* key, size_t klen, const char* val, size_t vlen, unsigned char compactFilte(void* arg, int level, const char* key, size_t klen, const char* val, size_t vlen,
char** newval, size_t* newvlen, unsigned char* value_changed) { char** newval, size_t* newvlen, unsigned char* value_changed) {
return streamStateValueIsStale((char*)val) ? 1 : 0; return streamStateValueIsStale((char*)val) ? 1 : 0;
@ -2416,7 +2412,7 @@ void taskDbRemoveRef(void* pTaskDb) {
} }
STaskDbWrapper* pBackend = pTaskDb; STaskDbWrapper* pBackend = pTaskDb;
(void)taosReleaseRef(taskDbWrapperId, pBackend->refId); TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, pBackend->refId));
} }
void taskDbSetClearFileFlag(void* pTaskDb) { void taskDbSetClearFileFlag(void* pTaskDb) {
@ -2491,24 +2487,24 @@ void taskDbInitChkpOpt(STaskDbWrapper* pTaskDb) {
pTaskDb->chkpId = -1; pTaskDb->chkpId = -1;
pTaskDb->chkpCap = 4; pTaskDb->chkpCap = 4;
pTaskDb->chkpSaved = taosArrayInit(4, sizeof(int64_t)); pTaskDb->chkpSaved = taosArrayInit(4, sizeof(int64_t));
(void)taskDbLoadChkpInfo(pTaskDb); TAOS_UNUSED(taskDbLoadChkpInfo(pTaskDb));
pTaskDb->chkpInUse = taosArrayInit(4, sizeof(int64_t)); pTaskDb->chkpInUse = taosArrayInit(4, sizeof(int64_t));
(void)taosThreadRwlockInit(&pTaskDb->chkpDirLock, NULL); TAOS_UNUSED(taosThreadRwlockInit(&pTaskDb->chkpDirLock, NULL));
} }
void taskDbRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) { void taskDbRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
(void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock); TAOS_UNUSED(taosThreadRwlockWrlock(&pTaskDb->chkpDirLock));
if (taosArrayPush(pTaskDb->chkpInUse, &chkp) == NULL) { if (taosArrayPush(pTaskDb->chkpInUse, &chkp) == NULL) {
stError("failed to push chkp: %" PRIi64 " into inuse", chkp); stError("failed to push chkp: %" PRIi64 " into inuse", chkp);
} }
taosArraySort(pTaskDb->chkpInUse, chkpIdComp); taosArraySort(pTaskDb->chkpInUse, chkpIdComp);
(void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock); TAOS_UNUSED(taosThreadRwlockUnlock(&pTaskDb->chkpDirLock));
} }
void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) { void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
(void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock); TAOS_UNUSED(taosThreadRwlockWrlock(&pTaskDb->chkpDirLock));
int32_t size = taosArrayGetSize(pTaskDb->chkpInUse); int32_t size = taosArrayGetSize(pTaskDb->chkpInUse);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
int64_t* p = taosArrayGet(pTaskDb->chkpInUse, i); int64_t* p = taosArrayGet(pTaskDb->chkpInUse, i);
@ -2517,13 +2513,13 @@ void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
break; break;
} }
} }
(void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock); TAOS_UNUSED(taosThreadRwlockUnlock(&pTaskDb->chkpDirLock));
} }
void taskDbDestroyChkpOpt(STaskDbWrapper* pTaskDb) { void taskDbDestroyChkpOpt(STaskDbWrapper* pTaskDb) {
taosArrayDestroy(pTaskDb->chkpSaved); taosArrayDestroy(pTaskDb->chkpSaved);
taosArrayDestroy(pTaskDb->chkpInUse); taosArrayDestroy(pTaskDb->chkpInUse);
(void)taosThreadRwlockDestroy(&pTaskDb->chkpDirLock); TAOS_UNUSED(taosThreadRwlockDestroy(&pTaskDb->chkpDirLock));
} }
int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** stateFullPath) { int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** stateFullPath) {
@ -2569,9 +2565,9 @@ int32_t taskDbBuildFullPath(char* path, char* key, char** dbFullPath, char** sta
void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId) { void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId) {
STaskDbWrapper* p = pTaskDb; STaskDbWrapper* p = pTaskDb;
(void)streamMutexLock(&p->mutex); TAOS_UNUSED(streamMutexLock(&p->mutex));
p->chkpId = chkpId; p->chkpId = chkpId;
(void)streamMutexUnlock(&p->mutex); TAOS_UNUSED(streamMutexUnlock(&p->mutex));
} }
STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) { STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) {
@ -2587,7 +2583,7 @@ STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) {
pTaskDb->idstr = key ? taosStrdup(key) : NULL; pTaskDb->idstr = key ? taosStrdup(key) : NULL;
pTaskDb->path = statePath ? taosStrdup(statePath) : NULL; pTaskDb->path = statePath ? taosStrdup(statePath) : NULL;
(void)taosThreadMutexInit(&pTaskDb->mutex, NULL); TAOS_UNUSED(taosThreadMutexInit(&pTaskDb->mutex, NULL));
taskDbInitChkpOpt(pTaskDb); taskDbInitChkpOpt(pTaskDb);
taskDbInitOpt(pTaskDb); taskDbInitOpt(pTaskDb);
@ -2772,7 +2768,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
char* buf = taosMemoryCalloc(1, cap); char* buf = taosMemoryCalloc(1, cap);
if (buf == NULL) { if (buf == NULL) {
(void)taosReleaseRef(taskDbWrapperId, refId); TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
return terrno; return terrno;
} }
@ -2780,7 +2776,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
snprintf(buf, cap, "%s%s%s%s%s%" PRId64 "", pDb->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, "checkpoint", chkpId); snprintf(buf, cap, "%s%s%s%s%s%" PRId64 "", pDb->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, "checkpoint", chkpId);
if (nBytes <= 0 || nBytes >= cap) { if (nBytes <= 0 || nBytes >= cap) {
taosMemoryFree(buf); taosMemoryFree(buf);
(void)taosReleaseRef(taskDbWrapperId, refId); TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
return TSDB_CODE_OUT_OF_RANGE; return TSDB_CODE_OUT_OF_RANGE;
} }
@ -2791,7 +2787,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
taosMemoryFree(buf); taosMemoryFree(buf);
} }
(void)taosReleaseRef(taskDbWrapperId, refId); TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
return code; return code;
} }
@ -3028,7 +3024,7 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t
inst->dbOpt = handle->dbOpt; inst->dbOpt = handle->dbOpt;
rocksdb_writeoptions_disable_WAL(inst->wOpt, 1); rocksdb_writeoptions_disable_WAL(inst->wOpt, 1);
(void)taosHashPut(handle->cfInst, idstr, strlen(idstr) + 1, &inst, sizeof(void*)); TAOS_UNUSED(taosHashPut(handle->cfInst, idstr, strlen(idstr) + 1, &inst, sizeof(void*)));
} else { } else {
inst = *pInst; inst = *pInst;
} }
@ -3269,9 +3265,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
break; \ break; \
} \ } \
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); \ TAOS_UNUSED(atomic_add_fetch_64(&wrapper->dataWritten, 1)); \
char toString[128] = {0}; \ char toString[128] = {0}; \
if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \ if (stDebugFlag & DEBUG_TRACE) TAOS_UNUSED((ginitDict[i].toStrFunc((void*)key, toString))); \
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \ int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \ rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
rocksdb_writeoptions_t* opts = wrapper->writeOpt; \ rocksdb_writeoptions_t* opts = wrapper->writeOpt; \
@ -3303,7 +3299,7 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
} \ } \
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
char toString[128] = {0}; \ char toString[128] = {0}; \
if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \ if (stDebugFlag & DEBUG_TRACE) TAOS_UNUSED((ginitDict[i].toStrFunc((void*)key, toString))); \
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \ int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \ rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
rocksdb_t* db = wrapper->db; \ rocksdb_t* db = wrapper->db; \
@ -3346,9 +3342,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
break; \ break; \
} \ } \
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \ STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; \
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); \ TAOS_UNUSED(atomic_add_fetch_64(&wrapper->dataWritten, 1)); \
char toString[128] = {0}; \ char toString[128] = {0}; \
if (stDebugFlag & DEBUG_TRACE) (void)(ginitDict[i].toStrFunc((void*)key, toString)); \ if (stDebugFlag & DEBUG_TRACE) TAOS_UNUSED(ginitDict[i].toStrFunc((void*)key, toString)); \
int32_t klen = ginitDict[i].enFunc((void*)key, buf); \ int32_t klen = ginitDict[i].enFunc((void*)key, buf); \
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \ rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
rocksdb_t* db = wrapper->db; \ rocksdb_t* db = wrapper->db; \
@ -3387,7 +3383,7 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) {
stDebug("streamStateClear_rocksdb"); stDebug("streamStateClear_rocksdb");
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); TAOS_UNUSED(atomic_add_fetch_64(&wrapper->dataWritten, 1));
char sKeyStr[128] = {0}; char sKeyStr[128] = {0};
char eKeyStr[128] = {0}; char eKeyStr[128] = {0};
@ -3403,8 +3399,8 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) {
if (err != NULL) { if (err != NULL) {
char toStringStart[128] = {0}; char toStringStart[128] = {0};
char toStringEnd[128] = {0}; char toStringEnd[128] = {0};
(void)stateKeyToString(&sKey, toStringStart); TAOS_UNUSED(stateKeyToString(&sKey, toStringStart));
(void)stateKeyToString(&eKey, toStringEnd); TAOS_UNUSED(stateKeyToString(&eKey, toStringEnd));
stWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err); stWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err);
taosMemoryFree(err); taosMemoryFree(err);
@ -3464,7 +3460,7 @@ int32_t streamStateAddIfNotExist_rocksdb(SStreamState* pState, const SWinKey* ke
} }
*pVal = taosMemoryMalloc(size); *pVal = taosMemoryMalloc(size);
if (*pVal == NULL) { if (*pVal == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
memset(*pVal, 0, size); memset(*pVal, 0, size);
return 0; return 0;
@ -3482,7 +3478,7 @@ int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, cons
if (rocksdb_iter_valid(pCur->iter) && !iterValueIsStale(pCur->iter)) { if (rocksdb_iter_valid(pCur->iter) && !iterValueIsStale(pCur->iter)) {
size_t tlen; size_t tlen;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &tlen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &tlen);
(void)stateKeyDecode((void*)pKtmp, keyStr); TAOS_UNUSED(stateKeyDecode((void*)pKtmp, keyStr));
if (pKtmp->opNum != pCur->number) { if (pKtmp->opNum != pCur->number) {
return -1; return -1;
} }
@ -3535,7 +3531,7 @@ SStreamStateCur* streamStateSeekKeyNext_rocksdb(SStreamState* pState, const SWin
SStateKey curKey; SStateKey curKey;
size_t kLen; size_t kLen;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
(void)stateKeyDecode((void*)&curKey, keyStr); TAOS_UNUSED(stateKeyDecode((void*)&curKey, keyStr));
if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) { if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) {
return pCur; return pCur;
} }
@ -3557,7 +3553,7 @@ SStreamStateCur* streamStateSeekToLast_rocksdb(SStreamState* pState) {
{ {
char tbuf[256] = {0}; char tbuf[256] = {0};
(void)stateKeyToString((void*)&maxStateKey, tbuf); TAOS_UNUSED(stateKeyToString((void*)&maxStateKey, tbuf));
stDebug("seek to last:%s", tbuf); stDebug("seek to last:%s", tbuf);
} }
@ -3607,7 +3603,7 @@ SStreamStateCur* streamStateGetCur_rocksdb(SStreamState* pState, const SWinKey*
SStateKey curKey; SStateKey curKey;
size_t kLen = 0; size_t kLen = 0;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
(void)stateKeyDecode((void*)&curKey, keyStr); TAOS_UNUSED(stateKeyDecode((void*)&curKey, keyStr));
if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) == 0) { if (stateKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) == 0) {
pCur->number = pState->number; pCur->number = pState->number;
@ -3755,7 +3751,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pSta
size_t klen; size_t klen;
const char* iKey = rocksdb_iter_key(pCur->iter, &klen); const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
SStateSessionKey curKey = {0}; SStateSessionKey curKey = {0};
(void)stateSessionKeyDecode(&curKey, (char*)iKey); TAOS_UNUSED(stateSessionKeyDecode(&curKey, (char*)iKey));
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) >= 0) return pCur; if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) >= 0) return pCur;
rocksdb_iter_prev(pCur->iter); rocksdb_iter_prev(pCur->iter);
@ -3792,7 +3788,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pSta
size_t klen; size_t klen;
const char* iKey = rocksdb_iter_key(pCur->iter, &klen); const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
SStateSessionKey curKey = {0}; SStateSessionKey curKey = {0};
(void)stateSessionKeyDecode(&curKey, (char*)iKey); TAOS_UNUSED(stateSessionKeyDecode(&curKey, (char*)iKey));
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) <= 0) return pCur; if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) <= 0) return pCur;
rocksdb_iter_next(pCur->iter); rocksdb_iter_next(pCur->iter);
@ -3832,7 +3828,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, con
size_t klen; size_t klen;
const char* iKey = rocksdb_iter_key(pCur->iter, &klen); const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
SStateSessionKey curKey = {0}; SStateSessionKey curKey = {0};
(void)stateSessionKeyDecode(&curKey, (char*)iKey); TAOS_UNUSED(stateSessionKeyDecode(&curKey, (char*)iKey));
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) < 0) return pCur; if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) < 0) return pCur;
rocksdb_iter_next(pCur->iter); rocksdb_iter_next(pCur->iter);
@ -3872,7 +3868,7 @@ SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, con
size_t klen; size_t klen;
const char* iKey = rocksdb_iter_key(pCur->iter, &klen); const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
SStateSessionKey curKey = {0}; SStateSessionKey curKey = {0};
(void)stateSessionKeyDecode(&curKey, (char*)iKey); TAOS_UNUSED(stateSessionKeyDecode(&curKey, (char*)iKey));
if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur; if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur;
rocksdb_iter_prev(pCur->iter); rocksdb_iter_prev(pCur->iter);
@ -3894,7 +3890,7 @@ int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey*
return -1; return -1;
} }
const char* curKey = rocksdb_iter_key(pCur->iter, (size_t*)&kLen); const char* curKey = rocksdb_iter_key(pCur->iter, (size_t*)&kLen);
(void)stateSessionKeyDecode((void*)&ktmp, (char*)curKey); TAOS_UNUSED(stateSessionKeyDecode((void*)&ktmp, (char*)curKey));
if (pVal != NULL) *pVal = NULL; if (pVal != NULL) *pVal = NULL;
if (pVLen != NULL) *pVLen = 0; if (pVLen != NULL) *pVLen = 0;
@ -3973,7 +3969,7 @@ SStreamStateCur* streamStateFillGetCur_rocksdb(SStreamState* pState, const SWinK
size_t kLen; size_t kLen;
SWinKey curKey; SWinKey curKey;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
(void)winKeyDecode((void*)&curKey, keyStr); TAOS_UNUSED(winKeyDecode((void*)&curKey, keyStr));
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) == 0) { if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) == 0) {
return pCur; return pCur;
} }
@ -3992,7 +3988,7 @@ int32_t streamStateFillGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey,
} }
size_t klen, vlen; size_t klen, vlen;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &klen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &klen);
(void)winKeyDecode(&winKey, keyStr); TAOS_UNUSED(winKeyDecode(&winKey, keyStr));
const char* valStr = rocksdb_iter_value(pCur->iter, &vlen); const char* valStr = rocksdb_iter_value(pCur->iter, &vlen);
int32_t len = valueDecode((void*)valStr, vlen, NULL, (char**)pVal); int32_t len = valueDecode((void*)valStr, vlen, NULL, (char**)pVal);
@ -4033,7 +4029,7 @@ SStreamStateCur* streamStateFillSeekKeyNext_rocksdb(SStreamState* pState, const
SWinKey curKey; SWinKey curKey;
size_t kLen = 0; size_t kLen = 0;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
(void)winKeyDecode((void*)&curKey, keyStr); TAOS_UNUSED(winKeyDecode((void*)&curKey, keyStr));
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) < 0) { if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) < 0) {
return pCur; return pCur;
} }
@ -4070,7 +4066,7 @@ SStreamStateCur* streamStateFillSeekKeyPrev_rocksdb(SStreamState* pState, const
SWinKey curKey; SWinKey curKey;
size_t kLen = 0; size_t kLen = 0;
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen); char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &kLen);
(void)winKeyDecode((void*)&curKey, keyStr); TAOS_UNUSED(winKeyDecode((void*)&curKey, keyStr));
if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) > 0) { if (winKeyCmpr(key, sizeof(*key), &curKey, sizeof(curKey)) > 0) {
return pCur; return pCur;
} }
@ -4154,7 +4150,7 @@ int32_t streamStateSessionAddIfNotExist_rocksdb(SStreamState* pState, SSessionKe
void* tmp = taosMemoryMalloc(valSize); void* tmp = taosMemoryMalloc(valSize);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev_rocksdb(pState, key); SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev_rocksdb(pState, key);
@ -4206,7 +4202,7 @@ void streamStateSessionClear_rocksdb(SStreamState* pState) {
if (code == 0 && size > 0) { if (code == 0 && size > 0) {
memset(buf, 0, size); memset(buf, 0, size);
// refactor later // refactor later
(void)streamStateSessionPut_rocksdb(pState, &delKey, buf, size); TAOS_UNUSED(streamStateSessionPut_rocksdb(pState, &delKey, buf, size));
} else { } else {
taosMemoryFreeClear(buf); taosMemoryFreeClear(buf);
break; break;
@ -4419,7 +4415,7 @@ void streamStateDestroyBatch(void* pBatch) { rocksdb_writebatch_destroy((rock
int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb_writebatch_t* pBatch, void* key, int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb_writebatch_t* pBatch, void* key,
void* val, int32_t vlen, int64_t ttl) { void* val, int32_t vlen, int64_t ttl) {
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); TAOS_UNUSED(atomic_add_fetch_64(&wrapper->dataWritten, 1));
int i = streamStateGetCfIdx(pState, cfKeyName); int i = streamStateGetCfIdx(pState, cfKeyName);
if (i < 0) { if (i < 0) {
@ -4439,7 +4435,7 @@ int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb
{ {
char tbuf[256] = {0}; char tbuf[256] = {0};
(void)(ginitDict[i].toStrFunc((void*)key, tbuf)); TAOS_UNUSED(ginitDict[i].toStrFunc((void*)key, tbuf));
stTrace("streamState str: %s succ to write to %s_%s, len: %d", tbuf, wrapper->idstr, ginitDict[i].key, vlen); stTrace("streamState str: %s succ to write to %s_%s, len: %d", tbuf, wrapper->idstr, ginitDict[i].key, vlen);
} }
return 0; return 0;
@ -4454,7 +4450,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); TAOS_UNUSED(atomic_add_fetch_64(&wrapper->dataWritten, 1));
rocksdb_column_family_handle_t* pCf = wrapper->pCf[ginitDict[cfIdx].idx]; rocksdb_column_family_handle_t* pCf = wrapper->pCf[ginitDict[cfIdx].idx];
rocksdb_writebatch_put_cf((rocksdb_writebatch_t*)pBatch, pCf, buf, (size_t)klen, ttlV, (size_t)ttlVLen); rocksdb_writebatch_put_cf((rocksdb_writebatch_t*)pBatch, pCf, buf, (size_t)klen, ttlV, (size_t)ttlVLen);
@ -4465,7 +4461,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
{ {
char tbuf[256] = {0}; char tbuf[256] = {0};
(void)(ginitDict[cfIdx].toStrFunc((void*)key, tbuf)); TAOS_UNUSED(ginitDict[cfIdx].toStrFunc((void*)key, tbuf));
stTrace("streamState str: %s succ to write to %s_%s", tbuf, wrapper->idstr, ginitDict[cfIdx].key); stTrace("streamState str: %s succ to write to %s_%s", tbuf, wrapper->idstr, ginitDict[cfIdx].key);
} }
return 0; return 0;
@ -4473,7 +4469,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch) { int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch) {
char* err = NULL; char* err = NULL;
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
(void)atomic_add_fetch_64(&wrapper->dataWritten, 1); TAOS_UNUSED(atomic_add_fetch_64(&wrapper->dataWritten, 1));
rocksdb_write(wrapper->db, wrapper->writeOpt, (rocksdb_writebatch_t*)pBatch, &err); rocksdb_write(wrapper->db, wrapper->writeOpt, (rocksdb_writebatch_t*)pBatch, &err);
if (err != NULL) { if (err != NULL) {
stError("streamState failed to write batch, err:%s", err); stError("streamState failed to write batch, err:%s", err);
@ -4562,7 +4558,7 @@ int32_t compareHashTableImpl(SHashObj* p1, SHashObj* p2, SArray* diff) {
if (fname == NULL) { if (fname == NULL) {
return terrno; return terrno;
} }
(void)strncpy(fname, name, len); TAOS_UNUSED(strncpy(fname, name, len));
if (taosArrayPush(diff, &fname) == NULL) { if (taosArrayPush(diff, &fname) == NULL) {
taosMemoryFree(fname); taosMemoryFree(fname);
return terrno; return terrno;
@ -4642,7 +4638,7 @@ void dbChkpDebugInfo(SDbChkp* pDb) {
int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
int32_t code = 0; int32_t code = 0;
int32_t nBytes; int32_t nBytes;
(void)taosThreadRwlockWrlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockWrlock(&p->rwLock));
p->preCkptId = p->curChkpId; p->preCkptId = p->curChkpId;
p->curChkpId = chkpId; p->curChkpId = chkpId;
@ -4660,7 +4656,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
nBytes = nBytes =
snprintf(p->buf, p->len, "%s%s%s%scheckpoint%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId); snprintf(p->buf, p->len, "%s%s%s%scheckpoint%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
if (nBytes <= 0 || nBytes >= p->len) { if (nBytes <= 0 || nBytes >= p->len) {
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return TSDB_CODE_OUT_OF_RANGE; return TSDB_CODE_OUT_OF_RANGE;
} }
@ -4670,7 +4666,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
TdDirPtr pDir = taosOpenDir(p->buf); TdDirPtr pDir = taosOpenDir(p->buf);
if (pDir == NULL) { if (pDir == NULL) {
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return terrno; return terrno;
} }
@ -4706,9 +4702,9 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
continue; continue;
} }
} }
(void)taosCloseDir(&pDir); TAOS_UNUSED(taosCloseDir(&pDir));
if (code != 0) { if (code != 0) {
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return code; return code;
} }
@ -4720,14 +4716,14 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
if (name != NULL && !isBkdDataMeta(name, len)) { if (name != NULL && !isBkdDataMeta(name, len)) {
char* fname = taosMemoryCalloc(1, len + 1); char* fname = taosMemoryCalloc(1, len + 1);
if (fname == NULL) { if (fname == NULL) {
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return terrno; return terrno;
} }
(void)strncpy(fname, name, len); TAOS_UNUSED(strncpy(fname, name, len));
if (taosArrayPush(p->pAdd, &fname) == NULL) { if (taosArrayPush(p->pAdd, &fname) == NULL) {
taosMemoryFree(fname); taosMemoryFree(fname);
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return terrno; return terrno;
} }
} }
@ -4761,7 +4757,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
p->idx = 1 - p->idx; p->idx = 1 - p->idx;
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return code; return code;
} }
@ -4819,7 +4815,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) {
} }
p->update = 0; p->update = 0;
(void)taosThreadRwlockInit(&p->rwLock, NULL); TAOS_UNUSED(taosThreadRwlockInit(&p->rwLock, NULL));
SArray* list = NULL; SArray* list = NULL;
code = dbChkpGetDelta(p, initChkpId, list); code = dbChkpGetDelta(p, initChkpId, list);
@ -4860,7 +4856,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
static char* chkpMeta = "META"; static char* chkpMeta = "META";
int32_t code = 0; int32_t code = 0;
(void)taosThreadRwlockRdlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockRdlock(&p->rwLock));
int32_t cap = p->len + 128; int32_t cap = p->len + 128;
@ -5003,7 +4999,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
if (nBytes <= 0 || nBytes >= sizeof(content)) { if (nBytes <= 0 || nBytes >= sizeof(content)) {
code = TSDB_CODE_OUT_OF_RANGE; code = TSDB_CODE_OUT_OF_RANGE;
stError("chkp failed to format meta file: %s, reason: invalid msg", dstDir); stError("chkp failed to format meta file: %s, reason: invalid msg", dstDir);
(void)taosCloseFile(&pFile); TAOS_UNUSED(taosCloseFile(&pFile));
goto _ERROR; goto _ERROR;
} }
@ -5011,10 +5007,10 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
if (nBytes != strlen(content)) { if (nBytes != strlen(content)) {
code = terrno; code = terrno;
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code)); stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
(void)taosCloseFile(&pFile); TAOS_UNUSED(taosCloseFile(&pFile));
goto _ERROR; goto _ERROR;
} }
(void)taosCloseFile(&pFile); TAOS_UNUSED(taosCloseFile(&pFile));
// clear delta data buf // clear delta data buf
taosArrayClearP(p->pAdd, taosMemoryFree); taosArrayClearP(p->pAdd, taosMemoryFree);
@ -5023,7 +5019,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
_ERROR: _ERROR:
taosMemoryFree(buffer); taosMemoryFree(buffer);
(void)taosThreadRwlockUnlock(&p->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
return code; return code;
} }
@ -5068,7 +5064,7 @@ void bkdMgtDestroy(SBkdMgt* bm) {
pIter = taosHashIterate(bm->pDbChkpTbl, pIter); pIter = taosHashIterate(bm->pDbChkpTbl, pIter);
} }
(void)taosThreadRwlockDestroy(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockDestroy(&bm->rwLock));
taosMemoryFree(bm->path); taosMemoryFree(bm->path);
taosHashCleanup(bm->pDbChkpTbl); taosHashCleanup(bm->pDbChkpTbl);
@ -5076,7 +5072,7 @@ void bkdMgtDestroy(SBkdMgt* bm) {
} }
int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* dname) { int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* dname) {
int32_t code = 0; int32_t code = 0;
(void)taosThreadRwlockWrlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockWrlock(&bm->rwLock));
SDbChkp** ppChkp = taosHashGet(bm->pDbChkpTbl, taskId, strlen(taskId)); SDbChkp** ppChkp = taosHashGet(bm->pDbChkpTbl, taskId, strlen(taskId));
SDbChkp* pChkp = ppChkp != NULL ? *ppChkp : NULL; SDbChkp* pChkp = ppChkp != NULL ? *ppChkp : NULL;
@ -5084,14 +5080,14 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
int32_t cap = strlen(bm->path) + 64; int32_t cap = strlen(bm->path) + 64;
char* path = taosMemoryCalloc(1, cap); char* path = taosMemoryCalloc(1, cap);
if (path == NULL) { if (path == NULL) {
(void)taosThreadRwlockUnlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
return terrno; return terrno;
} }
int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId); int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
if (nBytes <= 0 || nBytes >= cap) { if (nBytes <= 0 || nBytes >= cap) {
taosMemoryFree(path); taosMemoryFree(path);
(void)taosThreadRwlockUnlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
code = TSDB_CODE_OUT_OF_RANGE; code = TSDB_CODE_OUT_OF_RANGE;
return code; return code;
} }
@ -5100,20 +5096,20 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
code = dbChkpCreate(path, chkpId, &p); code = dbChkpCreate(path, chkpId, &p);
if (code != 0) { if (code != 0) {
taosMemoryFree(path); taosMemoryFree(path);
(void)taosThreadRwlockUnlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
return code; return code;
} }
if (taosHashPut(bm->pDbChkpTbl, taskId, strlen(taskId), &p, sizeof(void*)) != 0) { if (taosHashPut(bm->pDbChkpTbl, taskId, strlen(taskId), &p, sizeof(void*)) != 0) {
dbChkpDestroy(p); dbChkpDestroy(p);
(void)taosThreadRwlockUnlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
code = terrno; code = terrno;
return code; return code;
} }
pChkp = p; pChkp = p;
code = dbChkpDumpTo(pChkp, dname, list); code = dbChkpDumpTo(pChkp, dname, list);
(void)taosThreadRwlockUnlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
return code; return code;
} else { } else {
code = dbChkpGetDelta(pChkp, chkpId, NULL); code = dbChkpGetDelta(pChkp, chkpId, NULL);
@ -5122,7 +5118,7 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
} }
} }
(void)taosThreadRwlockUnlock(&bm->rwLock); TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
return code; return code;
} }

View File

@ -62,7 +62,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6
if (pChkpoint->blocks == NULL) { if (pChkpoint->blocks == NULL) {
taosMemoryFree(pBlock); taosMemoryFree(pBlock);
taosFreeQitem(pChkpoint); taosFreeQitem(pChkpoint);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
void* p = taosArrayPush(pChkpoint->blocks, pBlock); void* p = taosArrayPush(pChkpoint->blocks, pBlock);
@ -70,7 +70,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6
taosArrayDestroy(pChkpoint->blocks); taosArrayDestroy(pChkpoint->blocks);
taosMemoryFree(pBlock); taosMemoryFree(pBlock);
taosFreeQitem(pChkpoint); taosFreeQitem(pChkpoint);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
*pRes = pChkpoint; *pRes = pChkpoint;
@ -740,7 +740,7 @@ int32_t uploadCheckpointData(SStreamTask* pTask, int64_t checkpointId, int64_t d
SArray* toDelFiles = taosArrayInit(4, POINTER_BYTES); SArray* toDelFiles = taosArrayInit(4, POINTER_BYTES);
if (toDelFiles == NULL) { if (toDelFiles == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
if ((code = taskDbGenChkpUploadData(pTask->pBackend, pMeta->bkdChkptMgt, checkpointId, type, &path, toDelFiles, if ((code = taskDbGenChkpUploadData(pTask->pBackend, pMeta->bkdChkptMgt, checkpointId, type, &path, toDelFiles,
@ -1077,7 +1077,7 @@ int32_t doSendRetrieveTriggerMsg(SStreamTask* pTask, SArray* pNotSendList) {
SRetrieveChkptTriggerReq* pReq = rpcMallocCont(sizeof(SRetrieveChkptTriggerReq)); SRetrieveChkptTriggerReq* pReq = rpcMallocCont(sizeof(SRetrieveChkptTriggerReq));
if (pReq == NULL) { if (pReq == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
stError("vgId:%d failed to create msg to retrieve trigger msg for task:%s exec, code:out of memory", vgId, pId); stError("vgId:%d failed to create msg to retrieve trigger msg for task:%s exec, code:out of memory", vgId, pId);
continue; continue;
} }

View File

@ -191,7 +191,7 @@ int32_t streamMergedSubmitNew(SStreamMergedSubmit** pSubmit) {
if ((*pSubmit)->submits == NULL) { if ((*pSubmit)->submits == NULL) {
taosFreeQitem(*pSubmit); taosFreeQitem(*pSubmit);
*pSubmit = NULL; *pSubmit = NULL;
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
(*pSubmit)->type = STREAM_INPUT__MERGED_SUBMIT; (*pSubmit)->type = STREAM_INPUT__MERGED_SUBMIT;

View File

@ -73,7 +73,7 @@ static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTas
if (pReq->data == NULL || pReq->dataLen == NULL) { if (pReq->data == NULL || pReq->dataLen == NULL) {
taosArrayDestroyP(pReq->data, taosMemoryFree); taosArrayDestroyP(pReq->data, taosMemoryFree);
taosArrayDestroy(pReq->dataLen); taosArrayDestroy(pReq->dataLen);
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -110,7 +110,7 @@ int32_t streamTaskBroadcastRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* r
buf = rpcMallocCont(sizeof(SMsgHead) + len); buf = rpcMallocCont(sizeof(SMsgHead) + len);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId); ((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId);
@ -209,7 +209,7 @@ int32_t streamSendCheckMsg(SStreamTask* pTask, const SStreamTaskCheckReq* pReq,
buf = rpcMallocCont(sizeof(SMsgHead) + tlen); buf = rpcMallocCont(sizeof(SMsgHead) + tlen);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
((SMsgHead*)buf)->vgId = htonl(nodeId); ((SMsgHead*)buf)->vgId = htonl(nodeId);

View File

@ -476,23 +476,14 @@ _err:
if (pMeta->pTasksMap) taosHashCleanup(pMeta->pTasksMap); if (pMeta->pTasksMap) taosHashCleanup(pMeta->pTasksMap);
if (pMeta->pTaskList) taosArrayDestroy(pMeta->pTaskList); if (pMeta->pTaskList) taosArrayDestroy(pMeta->pTaskList);
if (pMeta->pTaskDb) { if (pMeta->pTaskDb) {
int32_t ret = tdbTbClose(pMeta->pTaskDb); tdbTbClose(pMeta->pTaskDb);
if (ret) {
stError("vgId:%d tdb failed close task db, code:%s", pMeta->vgId, tstrerror(ret));
}
pMeta->pTaskDb = NULL; pMeta->pTaskDb = NULL;
} }
if (pMeta->pCheckpointDb) { if (pMeta->pCheckpointDb) {
int32_t ret = tdbTbClose(pMeta->pCheckpointDb); tdbTbClose(pMeta->pCheckpointDb);
if (ret) {
stError("vgId:%d tdb failed close task checkpointDb, code:%s", pMeta->vgId, tstrerror(ret));
}
} }
if (pMeta->db) { if (pMeta->db) {
int32_t ret = tdbClose(pMeta->db); tdbClose(pMeta->db);
if (ret) {
stError("vgId:%d tdb failed close meta db, code:%s", pMeta->vgId, tstrerror(ret));
}
} }
if (pMeta->pHbInfo) taosMemoryFreeClear(pMeta->pHbInfo); if (pMeta->pHbInfo) taosMemoryFreeClear(pMeta->pHbInfo);
@ -598,18 +589,9 @@ void streamMetaCloseImpl(void* arg) {
// already log the error, ignore here // already log the error, ignore here
tdbAbort(pMeta->db, pMeta->txn); tdbAbort(pMeta->db, pMeta->txn);
code = tdbTbClose(pMeta->pTaskDb); tdbTbClose(pMeta->pTaskDb);
if (code) { tdbTbClose(pMeta->pCheckpointDb);
stError("vgId:%d failed to close taskDb, code:%s", vgId, tstrerror(code)); tdbClose(pMeta->db);
}
code = tdbTbClose(pMeta->pCheckpointDb);
if (code) {
stError("vgId:%d failed to close checkpointDb, code:%s", vgId, tstrerror(code));
}
code = tdbClose(pMeta->db);
if (code) {
stError("vgId:%d failed to close db, code:%s", vgId, tstrerror(code));
}
taosArrayDestroy(pMeta->pTaskList); taosArrayDestroy(pMeta->pTaskList);
taosArrayDestroy(pMeta->chkpSaved); taosArrayDestroy(pMeta->chkpSaved);

View File

@ -34,7 +34,7 @@ typedef struct STxn TXN;
// TDB // TDB
int32_t tdbOpen(const char *dbname, int szPage, int pages, TDB **ppDb, int8_t rollback, int32_t encryptAlgorithm, int32_t tdbOpen(const char *dbname, int szPage, int pages, TDB **ppDb, int8_t rollback, int32_t encryptAlgorithm,
char *encryptKey); char *encryptKey);
int32_t tdbClose(TDB *pDb); void tdbClose(TDB *pDb);
int32_t tdbBegin(TDB *pDb, TXN **pTxn, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg, int32_t tdbBegin(TDB *pDb, TXN **pTxn, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg,
int flags); int flags);
int32_t tdbCommit(TDB *pDb, TXN *pTxn); int32_t tdbCommit(TDB *pDb, TXN *pTxn);
@ -46,7 +46,7 @@ int32_t tdbAlter(TDB *pDb, int pages);
// TTB // TTB
int32_t tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprFn, TDB *pEnv, TTB **ppTb, int32_t tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprFn, TDB *pEnv, TTB **ppTb,
int8_t rollback); int8_t rollback);
int32_t tdbTbClose(TTB *pTb); void tdbTbClose(TTB *pTb);
bool tdbTbExist(const char *tbname, TDB *pEnv); bool tdbTbExist(const char *tbname, TDB *pEnv);
int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN *pTxn); int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN *pTxn);
int32_t tdbTbDrop(TTB *pTb); int32_t tdbTbDrop(TTB *pTb);

View File

@ -90,7 +90,7 @@ int32_t tdbOpen(const char *dbname, int32_t szPage, int32_t pages, TDB **ppDb, i
return 0; return 0;
} }
int tdbClose(TDB *pDb) { void tdbClose(TDB *pDb) {
SPager *pPager; SPager *pPager;
if (pDb) { if (pDb) {
@ -109,7 +109,7 @@ int tdbClose(TDB *pDb) {
tdbOsFree(pDb); tdbOsFree(pDb);
} }
return 0; return;
} }
int32_t tdbAlter(TDB *pDb, int pages) { return tdbPCacheAlter(pDb->pCache, pages); } int32_t tdbAlter(TDB *pDb, int pages) { return tdbPCacheAlter(pDb->pCache, pages); }

View File

@ -130,12 +130,12 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
return 0; return 0;
} }
int tdbTbClose(TTB *pTb) { void tdbTbClose(TTB *pTb) {
if (pTb) { if (pTb) {
tdbBtreeClose(pTb->pBt); tdbBtreeClose(pTb->pBt);
tdbOsFree(pTb); tdbOsFree(pTb);
} }
return 0; return;
} }
bool tdbTbExist(const char *tbname, TDB *pEnv) { bool tdbTbExist(const char *tbname, TDB *pEnv) {

View File

@ -197,8 +197,7 @@ static void insertOfp(void) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(TdbOVFLPagesTest, DISABLED_TbInsertTest) { // TEST(TdbOVFLPagesTest, DISABLED_TbInsertTest) {
@ -247,8 +246,7 @@ TEST(TdbOVFLPagesTest, TbGetTest) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(TdbOVFLPagesTest, DISABLED_TbDeleteTest) { // TEST(TdbOVFLPagesTest, DISABLED_TbDeleteTest) {
@ -357,8 +355,7 @@ tdbBegin(pEnv, &txn);
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(tdb_test, DISABLED_simple_insert1) { // TEST(tdb_test, DISABLED_simple_insert1) {
@ -492,6 +489,5 @@ TEST(tdb_test, simple_insert1) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }

View File

@ -468,8 +468,7 @@ TEST(TdbPageDefragmentTest, DISABLED_simple_insert1) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(TdbPageDefragmentTest, DISABLED_seq_insert) { // TEST(TdbPageDefragmentTest, DISABLED_seq_insert) {
@ -551,8 +550,7 @@ TEST(TdbPageDefragmentTest, seq_insert) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(TdbPageDefragmentTest, DISABLED_seq_delete) { // TEST(TdbPageDefragmentTest, DISABLED_seq_delete) {
@ -635,8 +633,7 @@ TEST(TdbPageDefragmentTest, seq_delete) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(TdbPageDefragmentTest, DISABLED_defragment_insert) { // TEST(TdbPageDefragmentTest, DISABLED_defragment_insert) {
@ -717,6 +714,5 @@ TEST(TdbPageDefragmentTest, defragment_insert) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }

View File

@ -123,7 +123,7 @@ static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, in
static TDB *openEnv(char const *envName, int const pageSize, int const pageNum) { static TDB *openEnv(char const *envName, int const pageSize, int const pageNum) {
TDB *pEnv = NULL; TDB *pEnv = NULL;
int ret = tdbOpen(envName, pageSize, pageNum, &pEnv, 0 , 0, NULL); int ret = tdbOpen(envName, pageSize, pageNum, &pEnv, 0, 0, NULL);
if (ret) { if (ret) {
pEnv = NULL; pEnv = NULL;
} }
@ -187,8 +187,7 @@ static void insertOfp(void) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
static void clearDb(char const *db) { taosRemoveDir(db); } static void clearDb(char const *db) { taosRemoveDir(db); }
@ -471,8 +470,7 @@ TEST(TdbPageRecycleTest, DISABLED_simple_insert1) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
static void insertDb(int nData) { static void insertDb(int nData) {
@ -537,8 +535,7 @@ static void insertDb(int nData) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
system("ls -l ./tdb"); system("ls -l ./tdb");
} }
@ -607,8 +604,7 @@ static void deleteDb(int nData) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
system("ls -l ./tdb"); system("ls -l ./tdb");
} }
@ -675,8 +671,7 @@ static void deleteOfp(void) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
// TEST(TdbPageRecycleTest, DISABLED_seq_delete_ofp) { // TEST(TdbPageRecycleTest, DISABLED_seq_delete_ofp) {
@ -761,8 +756,7 @@ TEST(TdbPageRecycleTest, recycly_seq_insert_ofp_nocommit) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
system("ls -l ./tdb"); system("ls -l ./tdb");
} }
@ -828,8 +822,7 @@ TEST(TdbPageRecycleTest, recycly_delete_interior_ofp_nocommit) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
system("ls -l ./tdb"); system("ls -l ./tdb");
} }

View File

@ -231,8 +231,7 @@ TEST(tdb_test, DISABLED_simple_insert1) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
TEST(tdb_test, DISABLED_simple_insert2) { TEST(tdb_test, DISABLED_simple_insert2) {
@ -315,8 +314,7 @@ TEST(tdb_test, DISABLED_simple_insert2) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
TEST(tdb_test, DISABLED_simple_delete1) { TEST(tdb_test, DISABLED_simple_delete1) {
@ -620,8 +618,7 @@ TEST(tdb_test, multi_thread_query) {
tdbTbClose(pDb); tdbTbClose(pDb);
// Close Env // Close Env
ret = tdbClose(pEnv); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
} }
TEST(tdb_test, DISABLED_multi_thread1) { TEST(tdb_test, DISABLED_multi_thread1) {
@ -745,7 +742,6 @@ TEST(tdb_test, DISABLED_multi_thread1) {
tdbTbClose(pTb); tdbTbClose(pTb);
// Close Env // Close Env
ret = tdbClose(pDb); tdbClose(pEnv);
GTEST_ASSERT_EQ(ret, 0);
#endif #endif
} }

View File

@ -295,7 +295,7 @@ int32_t tfsMkdirRecurAt(STfs *pTfs, const char *rname, SDiskID diskId) {
// https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dirname.3.html // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dirname.3.html
if ((dir = taosStrdup(taosDirName(s))) == NULL) { if ((dir = taosStrdup(taosDirName(s))) == NULL) {
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); TAOS_CHECK_GOTO(terrno, &lino, _exit);
} }
if (strlen(dir) >= strlen(rname)) { // TODO: check if it is necessary for equal length if (strlen(dir) >= strlen(rname)) { // TODO: check if it is necessary for equal length

View File

@ -236,7 +236,7 @@ static FORCE_INLINE int32_t taosBuildDstAddr(const char* server, uint16_t port,
static void* httpThread(void* arg) { static void* httpThread(void* arg) {
SHttpModule* http = (SHttpModule*)arg; SHttpModule* http = (SHttpModule*)arg;
setThreadName("http-cli-send-thread"); setThreadName("http-cli-send-thread");
(void)uv_run(http->loop, UV_RUN_DEFAULT); TAOS_UNUSED(uv_run(http->loop, UV_RUN_DEFAULT));
return NULL; return NULL;
} }
@ -352,7 +352,7 @@ static void httpAsyncCb(uv_async_t* handle) {
static int32_t BATCH_SIZE = 20; static int32_t BATCH_SIZE = 20;
int32_t count = 0; int32_t count = 0;
(void)taosThreadMutexLock(&item->mtx); TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
httpMayDiscardMsg(http, item); httpMayDiscardMsg(http, item);
while (!QUEUE_IS_EMPTY(&item->qmsg) && count++ < BATCH_SIZE) { while (!QUEUE_IS_EMPTY(&item->qmsg) && count++ < BATCH_SIZE) {
@ -360,7 +360,7 @@ static void httpAsyncCb(uv_async_t* handle) {
QUEUE_REMOVE(h); QUEUE_REMOVE(h);
QUEUE_PUSH(&wq, h); QUEUE_PUSH(&wq, h);
} }
(void)taosThreadMutexUnlock(&item->mtx); TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
httpTrace(&wq); httpTrace(&wq);
@ -393,7 +393,7 @@ static FORCE_INLINE void clientCloseCb(uv_handle_t* handle) {
SHttpModule* http = taosAcquireRef(httpRefMgt, cli->chanId); SHttpModule* http = taosAcquireRef(httpRefMgt, cli->chanId);
if (http != NULL) { if (http != NULL) {
http->connNum -= 1; http->connNum -= 1;
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
} }
destroyHttpClient(cli); destroyHttpClient(cli);
@ -453,7 +453,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { if (!uv_is_closing((uv_handle_t*)&cli->tcp)) {
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
} }
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
} }
http->connNum += 1; http->connNum += 1;
@ -468,7 +468,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
} }
} }
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
} }
int32_t httpSendQuit(SHttpModule* http, int64_t chanId) { int32_t httpSendQuit(SHttpModule* http, int64_t chanId) {
@ -514,7 +514,7 @@ static void httpHandleQuit(SHttpMsg* msg) {
SHttpModule* http = taosAcquireRef(httpRefMgt, chanId); SHttpModule* http = taosAcquireRef(httpRefMgt, chanId);
if (http == NULL) return; if (http == NULL) return;
uv_walk(http->loop, httpWalkCb, NULL); uv_walk(http->loop, httpWalkCb, NULL);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
} }
static bool httpFailFastShoudIgnoreMsg(SHashObj* pTable, char* server, int16_t port) { static bool httpFailFastShoudIgnoreMsg(SHashObj* pTable, char* server, int16_t port) {
@ -540,7 +540,7 @@ static void httpFailFastMayUpdate(SHashObj* pTable, char* server, int16_t port,
sprintf(buf, "%s:%d", server, port); sprintf(buf, "%s:%d", server, port);
if (succ) { if (succ) {
(void)taosHashRemove(pTable, buf, strlen(buf)); TAOS_UNUSED(taosHashRemove(pTable, buf, strlen(buf)));
} else { } else {
int32_t st = taosGetTimestampSec(); int32_t st = taosGetTimestampSec();
if ((code = taosHashPut(pTable, buf, strlen(buf), &st, sizeof(st))) != 0) { if ((code = taosHashPut(pTable, buf, strlen(buf), &st, sizeof(st))) != 0) {
@ -628,7 +628,7 @@ static void httpHandleReq(SHttpMsg* msg) {
tError("http-report failed to alloc read buf, dst:%s:%d, chanId:%" PRId64 ", seq:%" PRId64 ",reason:%s", cli->addr, tError("http-report failed to alloc read buf, dst:%s:%d, chanId:%" PRId64 ", seq:%" PRId64 ",reason:%s", cli->addr,
cli->port, chanId, cli->seq, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); cli->port, chanId, cli->seq, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
destroyHttpClient(cli); destroyHttpClient(cli);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
} }
@ -637,7 +637,7 @@ static void httpHandleReq(SHttpMsg* msg) {
tError("http-report failed to init socket handle, dst:%s:%d, chanId:%" PRId64 ", seq:%" PRId64 ", reason:%s", tError("http-report failed to init socket handle, dst:%s:%d, chanId:%" PRId64 ", seq:%" PRId64 ", reason:%s",
cli->addr, cli->port, chanId, cli->seq, uv_strerror(err)); cli->addr, cli->port, chanId, cli->seq, uv_strerror(err));
destroyHttpClient(cli); destroyHttpClient(cli);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
} }
@ -647,7 +647,7 @@ static void httpHandleReq(SHttpMsg* msg) {
tError("http-report failed to open socket, dst:%s:%d, chanId:%" PRId64 ", seq:%" PRId64 ", reason:%s", cli->addr, tError("http-report failed to open socket, dst:%s:%d, chanId:%" PRId64 ", seq:%" PRId64 ", reason:%s", cli->addr,
cli->port, chanId, cli->seq, tstrerror(terrno)); cli->port, chanId, cli->seq, tstrerror(terrno));
destroyHttpClient(cli); destroyHttpClient(cli);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
} }
@ -657,7 +657,7 @@ static void httpHandleReq(SHttpMsg* msg) {
cli->port, chanId, cli->seq, uv_strerror(ret)); cli->port, chanId, cli->seq, uv_strerror(ret));
destroyHttpClient(cli); destroyHttpClient(cli);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
} }
@ -668,7 +668,7 @@ static void httpHandleReq(SHttpMsg* msg) {
httpFailFastMayUpdate(http->connStatusTable, cli->addr, cli->port, 0); httpFailFastMayUpdate(http->connStatusTable, cli->addr, cli->port, 0);
destroyHttpClient(cli); destroyHttpClient(cli);
} }
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
END: END:
@ -678,7 +678,7 @@ END:
} }
httpDestroyMsg(msg); httpDestroyMsg(msg);
taosMemoryFree(header); taosMemoryFree(header);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
} }
static void httpModuleDestroy(SHttpModule* http) { static void httpModuleDestroy(SHttpModule* http) {
@ -689,7 +689,7 @@ static void httpModuleDestroy(SHttpModule* http) {
transAsyncPoolDestroy(http->asyncPool); transAsyncPoolDestroy(http->asyncPool);
} }
if (http->loop) { if (http->loop) {
(void)uv_loop_close(http->loop); TAOS_UNUSED(uv_loop_close(http->loop));
taosMemoryFree(http->loop); taosMemoryFree(http->loop);
} }
@ -754,7 +754,7 @@ int32_t taosSendHttpReport(const char* server, const char* uri, uint16_t port, c
int32_t taosSendHttpReportWithQID(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen, int32_t taosSendHttpReportWithQID(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
EHttpCompFlag flag, const char* qid) { EHttpCompFlag flag, const char* qid) {
(void)taosThreadOnce(&transHttpInit, transHttpEnvInit); TAOS_UNUSED(taosThreadOnce(&transHttpInit, transHttpEnvInit));
return taosSendHttpReportImplByChan(server, uri, port, pCont, contLen, flag, httpDefaultChanId, qid); return taosSendHttpReportImplByChan(server, uri, port, pCont, contLen, flag, httpDefaultChanId, qid);
} }
@ -825,7 +825,7 @@ _ERROR:
return code; return code;
} }
int64_t taosInitHttpChan() { int64_t taosInitHttpChan() {
(void)taosThreadOnce(&transHttpInit, transHttpEnvInit); TAOS_UNUSED(taosThreadOnce(&transHttpInit, transHttpEnvInit));
return transInitHttpChanImpl(); return transInitHttpChanImpl();
} }
@ -844,14 +844,14 @@ void taosDestroyHttpChan(int64_t chanId) {
ret = httpSendQuit(load, chanId); ret = httpSendQuit(load, chanId);
if (ret != 0) { if (ret != 0) {
tDebug("http-report already destroyed, chanId %" PRId64 ",reason:%s", chanId, tstrerror(ret)); tDebug("http-report already destroyed, chanId %" PRId64 ",reason:%s", chanId, tstrerror(ret));
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
return; return;
} }
(void)taosThreadJoin(load->thread, NULL); TAOS_UNUSED(taosThreadJoin(load->thread, NULL));
httpModuleDestroy(load); httpModuleDestroy(load);
(void)taosReleaseRef(httpRefMgt, chanId); TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
(void)taosRemoveRef(httpRefMgt, chanId); TAOS_UNUSED(taosRemoveRef(httpRefMgt, chanId));
} }

View File

@ -81,6 +81,6 @@ bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint1
void tmsgUpdateDnodeEpSet(SEpSet* epset) { void tmsgUpdateDnodeEpSet(SEpSet* epset) {
for (int32_t i = 0; i < epset->numOfEps; ++i) { for (int32_t i = 0; i < epset->numOfEps; ++i) {
(void)tmsgUpdateDnodeInfo(NULL, NULL, epset->eps[i].fqdn, &epset->eps[i].port); bool ret = tmsgUpdateDnodeInfo(NULL, NULL, epset->eps[i].fqdn, &epset->eps[i].port);
} }
} }

View File

@ -235,9 +235,9 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
#define CLI_RELEASE_UV(loop) \ #define CLI_RELEASE_UV(loop) \
do { \ do { \
(void)uv_walk(loop, cliWalkCb, NULL); \ TAOS_UNUSED(uv_walk(loop, cliWalkCb, NULL)); \
(void)uv_run(loop, UV_RUN_DEFAULT); \ TAOS_UNUSED(uv_run(loop, UV_RUN_DEFAULT)); \
(void)uv_loop_close(loop); \ TAOS_UNUSED(uv_loop_close(loop)); \
} while (0); } while (0);
// snprintf may cause performance problem // snprintf may cause performance problem
@ -247,7 +247,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
int16_t len = strlen(ip); \ int16_t len = strlen(ip); \
if (ip != NULL) memcpy(t, ip, len); \ if (ip != NULL) memcpy(t, ip, len); \
t[len] = ':'; \ t[len] = ':'; \
(void)titoa(port, 10, &t[len + 1]); \ TAOS_UNUSED(titoa(port, 10, &t[len + 1])); \
} while (0) } while (0)
#define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para)) #define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para))
@ -336,7 +336,7 @@ void cliResetTimer(SCliThrd* pThrd, SCliConn* conn) {
if (conn->timer) { if (conn->timer) {
if (uv_is_active((uv_handle_t*)conn->timer)) { if (uv_is_active((uv_handle_t*)conn->timer)) {
tDebug("%s conn %p stop timer", CONN_GET_INST_LABEL(conn), conn); tDebug("%s conn %p stop timer", CONN_GET_INST_LABEL(conn), conn);
(void)uv_timer_stop(conn->timer); TAOS_UNUSED(uv_timer_stop(conn->timer));
} }
if (taosArrayPush(pThrd->timerList, &conn->timer) == NULL) { if (taosArrayPush(pThrd->timerList, &conn->timer) == NULL) {
tError("failed to push timer %p to list, reason:%s", conn->timer, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); tError("failed to push timer %p to list, reason:%s", conn->timer, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
@ -375,15 +375,15 @@ bool cliConnSendSeqMsg(int64_t refId, SCliConn* conn) {
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
SCliMsg* t = QUEUE_DATA(h, SCliMsg, seqq); SCliMsg* t = QUEUE_DATA(h, SCliMsg, seqq);
transCtxMerge(&conn->ctx, &t->ctx->appCtx); transCtxMerge(&conn->ctx, &t->ctx->appCtx);
(void)transQueuePush(&conn->cliMsgs, t); TAOS_UNUSED(transQueuePush(&conn->cliMsgs, t));
tDebug("pop from conn %p, refId: %" PRId64 "", conn, refId); tDebug("pop from conn %p, refId: %" PRId64 "", conn, refId);
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
cliSend(conn); cliSend(conn);
return true; return true;
} }
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
tDebug("empty conn %p, refId: %" PRId64 "", conn, refId); tDebug("empty conn %p, refId: %" PRId64 "", conn, refId);
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
return false; return false;
} }
@ -496,7 +496,7 @@ void cliHandleResp(SCliConn* conn) {
return addConnToPool(pThrd->pool, conn); return addConnToPool(pThrd->pool, conn);
} }
(void)uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); TAOS_UNUSED(uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb));
} }
static void cliDestroyMsgInExhandle(int64_t refId) { static void cliDestroyMsgInExhandle(int64_t refId) {
if (refId == 0) return; if (refId == 0) return;
@ -510,7 +510,7 @@ static void cliDestroyMsgInExhandle(int64_t refId) {
destroyCmsg(t); destroyCmsg(t);
} }
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
} }
} }
@ -598,7 +598,7 @@ void cliConnTimeout(uv_timer_t* handle) {
tTrace("%s conn %p conn timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn)); tTrace("%s conn %p conn timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn));
(void)uv_timer_stop(handle); TAOS_UNUSED(uv_timer_stop(handle));
handle->data = NULL; handle->data = NULL;
cliResetTimer(pThrd, conn); cliResetTimer(pThrd, conn);
@ -610,7 +610,7 @@ void cliReadTimeoutCb(uv_timer_t* handle) {
// set up timeout cb // set up timeout cb
SCliConn* conn = handle->data; SCliConn* conn = handle->data;
tTrace("%s conn %p timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn)); tTrace("%s conn %p timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn));
(void)uv_read_stop(conn->stream); TAOS_UNUSED(uv_read_stop(conn->stream));
cliHandleExceptImpl(conn, TSDB_CODE_RPC_TIMEOUT); cliHandleExceptImpl(conn, TSDB_CODE_RPC_TIMEOUT);
} }
@ -847,7 +847,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
pMsg->ctx->task = NULL; pMsg->ctx->task = NULL;
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx); transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
(void)transQueuePush(&conn->cliMsgs, pMsg); TAOS_UNUSED(transQueuePush(&conn->cliMsgs, pMsg));
conn->status = ConnNormal; conn->status = ConnNormal;
cliSend(conn); cliSend(conn);
@ -871,8 +871,8 @@ static void addConnToPool(void* pool, SCliConn* conn) {
} }
static int32_t allocConnRef(SCliConn* conn, bool update) { static int32_t allocConnRef(SCliConn* conn, bool update) {
if (update) { if (update) {
(void)transReleaseExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
(void)transRemoveExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
conn->refId = -1; conn->refId = -1;
} }
@ -907,8 +907,8 @@ static int32_t allocConnRef(SCliConn* conn, bool update) {
static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) { static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
if (update) { if (update) {
(void)transReleaseExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
(void)transRemoveExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
conn->refId = -1; conn->refId = -1;
} }
SExHandle* exh = transAcquireExHandle(transGetRefMgt(), handle); SExHandle* exh = transAcquireExHandle(transGetRefMgt(), handle);
@ -924,7 +924,7 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
tDebug("conn %p specified by %" PRId64 "", conn, handle); tDebug("conn %p specified by %" PRId64 "", conn, handle);
(void)transReleaseExHandle(transGetRefMgt(), handle); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
return 0; return 0;
} }
@ -1004,7 +1004,7 @@ static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn) {
} }
tDebug("no available timer, create a timer %p", timer); tDebug("no available timer, create a timer %p", timer);
(void)uv_timer_init(pThrd->loop, timer); TAOS_UNUSED(uv_timer_init(pThrd->loop, timer));
} }
timer->data = conn; timer->data = conn;
@ -1022,7 +1022,7 @@ static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn) {
conn->broken = false; conn->broken = false;
transRefCliHandle(conn); transRefCliHandle(conn);
(void)atomic_add_fetch_32(&pThrd->connCount, 1); TAOS_UNUSED(atomic_add_fetch_32(&pThrd->connCount, 1));
TAOS_CHECK_GOTO(allocConnRef(conn, false), NULL, _failed); TAOS_CHECK_GOTO(allocConnRef(conn, false), NULL, _failed);
@ -1032,7 +1032,7 @@ _failed:
if (conn) { if (conn) {
taosMemoryFree(conn->stream); taosMemoryFree(conn->stream);
transReqQueueClear(&conn->wreqQueue); transReqQueueClear(&conn->wreqQueue);
(void)transDestroyBuffer(&conn->readBuf); TAOS_UNUSED(transDestroyBuffer(&conn->readBuf));
transQueueDestroy(&conn->cliMsgs); transQueueDestroy(&conn->cliMsgs);
} }
taosMemoryFree(conn); taosMemoryFree(conn);
@ -1059,8 +1059,8 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
} }
conn->list = NULL; conn->list = NULL;
(void)transReleaseExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
(void)transRemoveExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
conn->refId = -1; conn->refId = -1;
if (conn->task != NULL) { if (conn->task != NULL) {
@ -1071,7 +1071,7 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
if (clear) { if (clear) {
if (!uv_is_closing((uv_handle_t*)conn->stream)) { if (!uv_is_closing((uv_handle_t*)conn->stream)) {
(void)uv_read_stop(conn->stream); TAOS_UNUSED(uv_read_stop(conn->stream));
uv_close((uv_handle_t*)conn->stream, cliDestroy); uv_close((uv_handle_t*)conn->stream, cliDestroy);
} }
} }
@ -1084,11 +1084,11 @@ static void cliDestroy(uv_handle_t* handle) {
SCliThrd* pThrd = conn->hostThrd; SCliThrd* pThrd = conn->hostThrd;
cliResetTimer(pThrd, conn); cliResetTimer(pThrd, conn);
(void)atomic_sub_fetch_32(&pThrd->connCount, 1); TAOS_UNUSED(atomic_sub_fetch_32(&pThrd->connCount, 1));
if (conn->refId > 0) { if (conn->refId > 0) {
(void)transReleaseExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
(void)transRemoveExHandle(transGetRefMgt(), conn->refId); TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
} }
taosMemoryFree(conn->dstAddr); taosMemoryFree(conn->dstAddr);
taosMemoryFree(conn->stream); taosMemoryFree(conn->stream);
@ -1097,7 +1097,7 @@ static void cliDestroy(uv_handle_t* handle) {
tTrace("%s conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); tTrace("%s conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn);
transReqQueueClear(&conn->wreqQueue); transReqQueueClear(&conn->wreqQueue);
(void)transDestroyBuffer(&conn->readBuf); TAOS_UNUSED(transDestroyBuffer(&conn->readBuf));
taosMemoryFree(conn); taosMemoryFree(conn);
} }
@ -1106,7 +1106,7 @@ static bool cliHandleNoResp(SCliConn* conn) {
if (!transQueueEmpty(&conn->cliMsgs)) { if (!transQueueEmpty(&conn->cliMsgs)) {
SCliMsg* pMsg = transQueueGet(&conn->cliMsgs, 0); SCliMsg* pMsg = transQueueGet(&conn->cliMsgs, 0);
if (REQUEST_NO_RESP(&pMsg->msg)) { if (REQUEST_NO_RESP(&pMsg->msg)) {
(void)transQueuePop(&conn->cliMsgs); TAOS_UNUSED(transQueuePop(&conn->cliMsgs));
destroyCmsg(pMsg); destroyCmsg(pMsg);
res = true; res = true;
} }
@ -1153,7 +1153,7 @@ static void cliSendCb(uv_write_t* req, int status) {
tTrace("%s conn %p no resp required", CONN_GET_INST_LABEL(pConn), pConn); tTrace("%s conn %p no resp required", CONN_GET_INST_LABEL(pConn), pConn);
return; return;
} }
(void)uv_read_start((uv_stream_t*)pConn->stream, cliAllocRecvBufferCb, cliRecvCb); TAOS_UNUSED(uv_read_start((uv_stream_t*)pConn->stream, cliAllocRecvBufferCb, cliRecvCb));
} }
void cliSendBatch(SCliConn* pConn) { void cliSendBatch(SCliConn* pConn) {
int32_t code = 0; int32_t code = 0;
@ -1296,13 +1296,13 @@ void cliSend(SCliConn* pConn) {
if (timer == NULL) { if (timer == NULL) {
timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); timer = taosMemoryCalloc(1, sizeof(uv_timer_t));
tDebug("no available timer, create a timer %p", timer); tDebug("no available timer, create a timer %p", timer);
(void)uv_timer_init(pThrd->loop, timer); TAOS_UNUSED(uv_timer_init(pThrd->loop, timer));
} }
timer->data = pConn; timer->data = pConn;
pConn->timer = timer; pConn->timer = timer;
tGTrace("%s conn %p start timer for msg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType)); tGTrace("%s conn %p start timer for msg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType));
(void)uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0); TAOS_UNUSED(uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0));
} }
if (pHead->comp == 0 && pMsg->info.compressed == 0 && pConn->clientIp != pConn->serverIp) { if (pHead->comp == 0 && pMsg->info.compressed == 0 && pConn->clientIp != pConn->serverIp) {
@ -1402,8 +1402,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
tTrace("%s conn %p try to connect to %s", pTransInst->label, conn, pList->dst); tTrace("%s conn %p try to connect to %s", pTransInst->label, conn, pList->dst);
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10); int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
if (fd == -1) { if (fd == -1) {
tError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, tError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, tstrerror(terrno));
tstrerror(terrno));
cliHandleFastFail(conn, -1); cliHandleFastFail(conn, -1);
return; return;
} }
@ -1428,7 +1427,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
cliHandleFastFail(conn, -1); cliHandleFastFail(conn, -1);
return; return;
} }
(void)uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); TAOS_UNUSED(uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0));
return; return;
} }
@ -1541,12 +1540,12 @@ void cliConnCb(uv_connect_t* req, int status) {
struct sockaddr peername, sockname; struct sockaddr peername, sockname;
int addrlen = sizeof(peername); int addrlen = sizeof(peername);
(void)uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen); TAOS_UNUSED(uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen));
(void)transSockInfo2Str(&peername, pConn->dst); TAOS_UNUSED(transSockInfo2Str(&peername, pConn->dst));
addrlen = sizeof(sockname); addrlen = sizeof(sockname);
(void)uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen); TAOS_UNUSED(uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen));
(void)transSockInfo2Str(&sockname, pConn->src); TAOS_UNUSED(transSockInfo2Str(&sockname, pConn->src));
struct sockaddr_in addr = *(struct sockaddr_in*)&sockname; struct sockaddr_in addr = *(struct sockaddr_in*)&sockname;
struct sockaddr_in saddr = *(struct sockaddr_in*)&peername; struct sockaddr_in saddr = *(struct sockaddr_in*)&peername;
@ -1596,8 +1595,8 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrd* pThrd) {
tDebug("cli work thread %p start to quit", pThrd); tDebug("cli work thread %p start to quit", pThrd);
destroyCmsg(pMsg); destroyCmsg(pMsg);
(void)destroyConnPool(pThrd); TAOS_UNUSED(destroyConnPool(pThrd));
(void)uv_walk(pThrd->loop, cliWalkCb, NULL); TAOS_UNUSED(uv_walk(pThrd->loop, cliWalkCb, NULL));
} }
static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) { static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
int64_t refId = (int64_t)(pMsg->msg.info.handle); int64_t refId = (int64_t)(pMsg->msg.info.handle);
@ -1611,8 +1610,7 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
taosRLockLatch(&exh->latch); taosRLockLatch(&exh->latch);
SCliConn* conn = exh->handle; SCliConn* conn = exh->handle;
taosRUnLockLatch(&exh->latch); taosRUnLockLatch(&exh->latch);
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
(void)transReleaseExHandle(transGetRefMgt(), refId);
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn); tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
if (T_REF_VAL_GET(conn) == 2) { if (T_REF_VAL_GET(conn) == 2) {
@ -1636,7 +1634,7 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
int64_t refId = (int64_t)(pMsg->msg.info.handle); int64_t refId = (int64_t)(pMsg->msg.info.handle);
SExHandle* exh = transAcquireExHandle(transGetRefMgt(), refId); SExHandle* exh = transAcquireExHandle(transGetRefMgt(), refId);
if (exh == NULL) { if (exh == NULL) {
tDebug("id %" PRId64 " already released", refId); tDebug("refId %" PRId64 " already released", refId);
destroyCmsg(pMsg); destroyCmsg(pMsg);
return; return;
} }
@ -1648,7 +1646,7 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
if (conn == NULL || conn->refId != refId) { if (conn == NULL || conn->refId != refId) {
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception); TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception);
} }
tDebug("do free conn %p by id %" PRId64 "", conn, refId); tDebug("do free conn %p by refId %" PRId64 "", conn, refId);
int32_t size = transQueueSize(&conn->cliMsgs); int32_t size = transQueueSize(&conn->cliMsgs);
if (size == 0) { if (size == 0) {
@ -1656,7 +1654,7 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception); TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception);
} else { } else {
destroyCmsg(pMsg); destroyCmsg(pMsg);
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
while (T_REF_VAL_GET(conn) >= 1) { while (T_REF_VAL_GET(conn) >= 1) {
transUnrefCliHandle(conn); transUnrefCliHandle(conn);
@ -1666,9 +1664,9 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
_exception: _exception:
tDebug("already free conn %p by id %" PRId64 "", conn, refId); tDebug("already free conn %p by id %" PRId64 "", conn, refId);
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
(void)transRemoveExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), refId));
destroyCmsg(pMsg); destroyCmsg(pMsg);
} }
@ -1691,7 +1689,7 @@ SCliConn* cliGetConn(SCliMsg** pMsg, SCliThrd* pThrd, bool* ignore, char* addr)
conn = getConnFromPool2(pThrd, addr, pMsg); conn = getConnFromPool2(pThrd, addr, pMsg);
if (conn != NULL) specifyConnRef(conn, true, refId); if (conn != NULL) specifyConnRef(conn, true, refId);
} }
(void)transReleaseExHandle(transGetRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
} }
return conn; return conn;
}; };
@ -1787,7 +1785,7 @@ static void cliMayUpdateFqdnCache(SHashObj* cache, char* dst) {
if (i > 0) { if (i > 0) {
char fqdn[TSDB_FQDN_LEN + 1] = {0}; char fqdn[TSDB_FQDN_LEN + 1] = {0};
memcpy(fqdn, dst, i); memcpy(fqdn, dst, i);
(void)cliUpdateFqdnCache(cache, fqdn); TAOS_UNUSED(cliUpdateFqdnCache(cache, fqdn));
} }
} }
@ -1824,7 +1822,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
if (ignore == true) { if (ignore == true) {
// persist conn already release by server // persist conn already release by server
STransMsg resp = {0}; STransMsg resp = {0};
(void)cliBuildExceptResp(pMsg, &resp); TAOS_UNUSED(cliBuildExceptResp(pMsg, &resp));
// refactorr later // refactorr later
resp.info.cliVer = pTransInst->compatibilityVer; resp.info.cliVer = pTransInst->compatibilityVer;
@ -1841,14 +1839,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
if (conn != NULL) { if (conn != NULL) {
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx); transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
(void)transQueuePush(&conn->cliMsgs, pMsg); TAOS_UNUSED(transQueuePush(&conn->cliMsgs, pMsg));
cliSend(conn); cliSend(conn);
} else { } else {
code = cliCreateConn(pThrd, &conn); code = cliCreateConn(pThrd, &conn);
if (code != 0) { if (code != 0) {
tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code)); tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code));
STransMsg resp = {.code = code}; STransMsg resp = {.code = code};
(void)cliBuildExceptResp(pMsg, &resp); TAOS_UNUSED(cliBuildExceptResp(pMsg, &resp));
resp.info.cliVer = pTransInst->compatibilityVer; resp.info.cliVer = pTransInst->compatibilityVer;
if (pMsg->type != Release) { if (pMsg->type != Release) {
@ -1862,7 +1860,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
if (refId != 0) specifyConnRef(conn, true, refId); if (refId != 0) specifyConnRef(conn, true, refId);
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx); transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
(void)transQueuePush(&conn->cliMsgs, pMsg); TAOS_UNUSED(transQueuePush(&conn->cliMsgs, pMsg));
conn->dstAddr = taosStrdup(addr); conn->dstAddr = taosStrdup(addr);
@ -1882,8 +1880,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
tGTrace("%s conn %p try to connect to %s", pTransInst->label, conn, conn->dstAddr); tGTrace("%s conn %p try to connect to %s", pTransInst->label, conn, conn->dstAddr);
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10); int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
if (fd == -1) { if (fd == -1) {
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, tstrerror(terrno));
tstrerror(terrno));
cliHandleExcept(conn, -1); cliHandleExcept(conn, -1);
terrno = 0; terrno = 0;
return; return;
@ -1911,7 +1908,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
cliHandleFastFail(conn, ret); cliHandleFastFail(conn, ret);
return; return;
} }
(void)uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0); TAOS_UNUSED(uv_timer_start(conn->timer, cliConnTimeout, TRANS_CONN_TIMEOUT, 0));
} }
tGTrace("%s conn %p ready", pTransInst->label, conn); tGTrace("%s conn %p ready", pTransInst->label, conn);
} }
@ -2110,9 +2107,9 @@ static void cliAsyncCb(uv_async_t* handle) {
// batch process to avoid to lock/unlock frequently // batch process to avoid to lock/unlock frequently
queue wq; queue wq;
(void)taosThreadMutexLock(&item->mtx); TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
QUEUE_MOVE(&item->qmsg, &wq); QUEUE_MOVE(&item->qmsg, &wq);
(void)taosThreadMutexUnlock(&item->mtx); TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
int8_t supportBatch = pTransInst->supportBatch; int8_t supportBatch = pTransInst->supportBatch;
if (supportBatch == 0) { if (supportBatch == 0) {
@ -2162,7 +2159,7 @@ bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) {
tDebug("%s conn %p receive release request, refId:%" PRId64 ", may ignore", CONN_GET_INST_LABEL(conn), conn, tDebug("%s conn %p receive release request, refId:%" PRId64 ", may ignore", CONN_GET_INST_LABEL(conn), conn,
conn->refId); conn->refId);
(void)transClearBuffer(&conn->readBuf); TAOS_UNUSED(transClearBuffer(&conn->readBuf));
transFreeMsg(transContFromHead((char*)pHead)); transFreeMsg(transContFromHead((char*)pHead));
for (int i = 0; ahandle == 0 && i < transQueueSize(&conn->cliMsgs); i++) { for (int i = 0; ahandle == 0 && i < transQueueSize(&conn->cliMsgs); i++) {
@ -2192,10 +2189,10 @@ static void* cliWorkThread(void* arg) {
SCliThrd* pThrd = (SCliThrd*)arg; SCliThrd* pThrd = (SCliThrd*)arg;
pThrd->pid = taosGetSelfPthreadId(); pThrd->pid = taosGetSelfPthreadId();
(void)strtolower(threadName, pThrd->pTransInst->label); TAOS_UNUSED(strtolower(threadName, pThrd->pTransInst->label));
setThreadName(threadName); setThreadName(threadName);
(void)uv_run(pThrd->loop, UV_RUN_DEFAULT); TAOS_UNUSED(uv_run(pThrd->loop, UV_RUN_DEFAULT));
tDebug("thread quit-thread:%08" PRId64, pThrd->pid); tDebug("thread quit-thread:%08" PRId64, pThrd->pid);
return NULL; return NULL;
@ -2239,7 +2236,7 @@ _err:
if (cli) { if (cli) {
for (int i = 0; i < cli->numOfThreads; i++) { for (int i = 0; i < cli->numOfThreads; i++) {
if (cli->pThreadObj[i]) { if (cli->pThreadObj[i]) {
(void)cliSendQuit(cli->pThreadObj[i]); TAOS_UNUSED(cliSendQuit(cli->pThreadObj[i]));
destroyThrdObj(cli->pThreadObj[i]); destroyThrdObj(cli->pThreadObj[i]);
} }
} }
@ -2283,8 +2280,8 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) {
} }
if (pMsg->msg.info.handle != 0) { if (pMsg->msg.info.handle != 0) {
(void)transReleaseExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle));
(void)transRemoveExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle); TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle));
} }
transDestroyConnCtx(pMsg->ctx); transDestroyConnCtx(pMsg->ctx);
@ -2302,7 +2299,7 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
} }
QUEUE_INIT(&pThrd->msg); QUEUE_INIT(&pThrd->msg);
(void)taosThreadMutexInit(&pThrd->msgMtx, NULL); TAOS_UNUSED(taosThreadMutexInit(&pThrd->msgMtx, NULL));
pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
if (pThrd->loop == NULL) { if (pThrd->loop == NULL) {
@ -2324,8 +2321,8 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
pThrd->pool = createConnPool(4); pThrd->pool = createConnPool(4);
if (pThrd->pool == NULL) { if (pThrd->pool == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); TAOS_CHECK_GOTO(terrno, NULL, _end);
} }
if ((code = transDQCreate(pThrd->loop, &pThrd->delayQueue)) != 0) { if ((code = transDQCreate(pThrd->loop, &pThrd->delayQueue)) != 0) {
TAOS_CHECK_GOTO(code, NULL, _end); TAOS_CHECK_GOTO(code, NULL, _end);
@ -2366,9 +2363,9 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
if (timer == NULL) { if (timer == NULL) {
TAOS_CHECK_GOTO(terrno, NULL, _end); TAOS_CHECK_GOTO(terrno, NULL, _end);
} }
(void)uv_timer_init(pThrd->loop, timer); TAOS_UNUSED(uv_timer_init(pThrd->loop, timer));
if (taosArrayPush(pThrd->timerList, &timer) == NULL) { if (taosArrayPush(pThrd->timerList, &timer) == NULL) {
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); TAOS_CHECK_GOTO(terrno, NULL, _end);
} }
} }
pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime);
@ -2380,19 +2377,19 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
_end: _end:
if (pThrd) { if (pThrd) {
(void)taosThreadMutexDestroy(&pThrd->msgMtx); TAOS_UNUSED(taosThreadMutexDestroy(&pThrd->msgMtx));
(void)uv_loop_close(pThrd->loop); TAOS_UNUSED(uv_loop_close(pThrd->loop));
taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd->loop);
transAsyncPoolDestroy(pThrd->asyncPool); transAsyncPoolDestroy(pThrd->asyncPool);
for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) { for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) {
uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i); uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i);
(void)uv_timer_stop(timer); TAOS_UNUSED(uv_timer_stop(timer));
taosMemoryFree(timer); taosMemoryFree(timer);
} }
taosArrayDestroy(pThrd->timerList); taosArrayDestroy(pThrd->timerList);
(void)destroyConnPool(pThrd); TAOS_UNUSED(destroyConnPool(pThrd));
transDQDestroy(pThrd->delayQueue, NULL); transDQDestroy(pThrd->delayQueue, NULL);
transDQDestroy(pThrd->timeoutQueue, NULL); transDQDestroy(pThrd->timeoutQueue, NULL);
transDQDestroy(pThrd->waitConnQueue, NULL); transDQDestroy(pThrd->waitConnQueue, NULL);
@ -2409,9 +2406,9 @@ static void destroyThrdObj(SCliThrd* pThrd) {
return; return;
} }
(void)taosThreadJoin(pThrd->thread, NULL); TAOS_UNUSED(taosThreadJoin(pThrd->thread, NULL));
CLI_RELEASE_UV(pThrd->loop); CLI_RELEASE_UV(pThrd->loop);
(void)taosThreadMutexDestroy(&pThrd->msgMtx); TAOS_UNUSED(taosThreadMutexDestroy(&pThrd->msgMtx));
TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsgWrapper, (void*)pThrd); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsgWrapper, (void*)pThrd);
transAsyncPoolDestroy(pThrd->asyncPool); transAsyncPoolDestroy(pThrd->asyncPool);
@ -2478,9 +2475,9 @@ void cliWalkCb(uv_handle_t* handle, void* arg) {
if (uv_handle_get_type(handle) == UV_TIMER) { if (uv_handle_get_type(handle) == UV_TIMER) {
// do nothing // do nothing
} else { } else {
(void)uv_read_stop((uv_stream_t*)handle); TAOS_UNUSED(uv_read_stop((uv_stream_t*)handle));
} }
(void)uv_close(handle, cliDestroy); TAOS_UNUSED(uv_close(handle, cliDestroy));
} }
} }
@ -2518,7 +2515,7 @@ static void cliSchedMsgToDebug(SCliMsg* pMsg, char* label) {
STransConnCtx* pCtx = pMsg->ctx; STransConnCtx* pCtx = pMsg->ctx;
STraceId* trace = &pMsg->msg.info.traceId; STraceId* trace = &pMsg->msg.info.traceId;
char tbuf[512] = {0}; char tbuf[512] = {0};
(void)epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)); TAOS_UNUSED(epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)));
tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", label, tbuf, pCtx->retryStep, tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", label, tbuf, pCtx->retryStep,
pCtx->retryNextInterval); pCtx->retryNextInterval);
return; return;
@ -2533,7 +2530,7 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
arg->param1 = pMsg; arg->param1 = pMsg;
arg->param2 = pThrd; arg->param2 = pThrd;
(void)transDQSched(pThrd->delayQueue, doDelayTask, arg, pCtx->retryNextInterval); TAOS_UNUSED(transDQSched(pThrd->delayQueue, doDelayTask, arg, pCtx->retryNextInterval));
} }
FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) { FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) {
@ -2751,7 +2748,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
if (hasEpSet) { if (hasEpSet) {
if (rpcDebugFlag & DEBUG_TRACE) { if (rpcDebugFlag & DEBUG_TRACE) {
char tbuf[512] = {0}; char tbuf[512] = {0};
(void)epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)); TAOS_UNUSED(epsetToStr(&pCtx->epSet, tbuf, tListLen(tbuf)));
tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn); tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn);
} }
} }
@ -2763,7 +2760,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
} else { } else {
memcpy((char*)pCtx->pRsp, (char*)pResp, sizeof(*pResp)); memcpy((char*)pCtx->pRsp, (char*)pResp, sizeof(*pResp));
} }
(void)tsem_post(pCtx->pSem); TAOS_UNUSED(tsem_post(pCtx->pSem));
pCtx->pRsp = NULL; pCtx->pRsp = NULL;
} else { } else {
STransSyncMsg* pSyncMsg = taosAcquireRef(transGetSyncMsgMgt(), pCtx->syncMsgRef); STransSyncMsg* pSyncMsg = taosAcquireRef(transGetSyncMsgMgt(), pCtx->syncMsgRef);
@ -2773,8 +2770,8 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
pSyncMsg->hasEpSet = 1; pSyncMsg->hasEpSet = 1;
epsetAssign(&pSyncMsg->epSet, &pCtx->epSet); epsetAssign(&pSyncMsg->epSet, &pCtx->epSet);
} }
(void)tsem2_post(pSyncMsg->pSem); TAOS_UNUSED(tsem2_post(pSyncMsg->pSem));
(void)taosReleaseRef(transGetSyncMsgMgt(), pCtx->syncMsgRef); TAOS_UNUSED(taosReleaseRef(transGetSyncMsgMgt(), pCtx->syncMsgRef));
} else { } else {
rpcFreeCont(pResp->pCont); rpcFreeCont(pResp->pCont);
} }
@ -2843,7 +2840,7 @@ static FORCE_INLINE SCliThrd* transGetWorkThrdFromHandle(STrans* trans, int64_t
pThrd = exh->pThrd; pThrd = exh->pThrd;
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
(void)transReleaseExHandle(transGetRefMgt(), handle); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
return pThrd; return pThrd;
} }
@ -2949,7 +2946,7 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg); code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg);
if (code != 0) { if (code != 0) {
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
(void)transReleaseExHandle(transGetRefMgt(), handle); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
TAOS_CHECK_GOTO(code, NULL, _exception); TAOS_CHECK_GOTO(code, NULL, _exception);
} }
@ -2957,13 +2954,13 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
tDebug("msg refId: %" PRId64 "", handle); tDebug("msg refId: %" PRId64 "", handle);
(void)transReleaseExHandle(transGetRefMgt(), handle); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return 0; return 0;
} else { } else {
exh->inited = 1; exh->inited = 1;
taosWUnLockLatch(&exh->latch); taosWUnLockLatch(&exh->latch);
(void)transReleaseExHandle(transGetRefMgt(), handle); TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
} }
} }
} }
@ -2976,16 +2973,16 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle); EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle);
if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) { if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) {
destroyCmsg(pCliMsg); destroyCmsg(pCliMsg);
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code);
} }
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return 0; return 0;
_exception: _exception:
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL; pReq->pCont = NULL;
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return code; return code;
} }
int32_t transSendRequestWithId(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, int64_t* transpointId) { int32_t transSendRequestWithId(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, int64_t* transpointId) {
@ -3021,16 +3018,16 @@ int32_t transSendRequestWithId(void* shandle, const SEpSet* pEpSet, STransMsg* p
EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle); EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle);
if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) { if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) {
destroyCmsg(pCliMsg); destroyCmsg(pCliMsg);
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code);
} }
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return 0; return 0;
_exception: _exception:
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL; pReq->pCont = NULL;
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return code; return code;
} }
@ -3068,7 +3065,7 @@ int32_t transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
if (pCtx == NULL) { if (pCtx == NULL) {
(void)tsem_destroy(sem); TAOS_UNUSED(tsem_destroy(sem));
taosMemoryFree(sem); taosMemoryFree(sem);
TAOS_CHECK_GOTO(terrno, NULL, _RETURN1); TAOS_CHECK_GOTO(terrno, NULL, _RETURN1);
} }
@ -3082,7 +3079,7 @@ int32_t transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg));
if (cliMsg == NULL) { if (cliMsg == NULL) {
(void)tsem_destroy(sem); TAOS_UNUSED(tsem_destroy(sem));
taosMemoryFree(sem); taosMemoryFree(sem);
taosMemoryFree(pCtx); taosMemoryFree(pCtx);
TAOS_CHECK_GOTO(terrno, NULL, _RETURN1); TAOS_CHECK_GOTO(terrno, NULL, _RETURN1);
@ -3103,18 +3100,18 @@ int32_t transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
destroyCmsg(cliMsg); destroyCmsg(cliMsg);
TAOS_CHECK_GOTO((code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code), NULL, _RETURN); TAOS_CHECK_GOTO((code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code), NULL, _RETURN);
} }
(void)tsem_wait(sem); TAOS_UNUSED(tsem_wait(sem));
memcpy(pRsp, pTransRsp, sizeof(STransMsg)); memcpy(pRsp, pTransRsp, sizeof(STransMsg));
_RETURN: _RETURN:
tsem_destroy(sem); tsem_destroy(sem);
taosMemoryFree(sem); taosMemoryFree(sem);
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
taosMemoryFree(pTransRsp); taosMemoryFree(pTransRsp);
return code; return code;
_RETURN1: _RETURN1:
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
taosMemoryFree(pTransRsp); taosMemoryFree(pTransRsp);
taosMemoryFree(pReq->pCont); taosMemoryFree(pReq->pCont);
pReq->pCont = NULL; pReq->pCont = NULL;
@ -3151,7 +3148,7 @@ int32_t transCreateSyncMsg(STransMsg* pTransMsg, int64_t* refId) {
return 0; return 0;
_EXIT: _EXIT:
(void)tsem2_destroy(sem); TAOS_UNUSED(tsem2_destroy(sem));
taosMemoryFree(sem); taosMemoryFree(sem);
taosMemoryFree(pSyncMsg); taosMemoryFree(pSyncMsg);
return code; return code;
@ -3235,15 +3232,15 @@ int32_t transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq,
} }
} }
_RETURN: _RETURN:
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
(void)taosReleaseRef(transGetSyncMsgMgt(), ref); TAOS_UNUSED(taosReleaseRef(transGetSyncMsgMgt(), ref));
(void)taosRemoveRef(transGetSyncMsgMgt(), ref); TAOS_UNUSED(taosRemoveRef(transGetSyncMsgMgt(), ref));
return code; return code;
_RETURN2: _RETURN2:
transFreeMsg(pReq->pCont); transFreeMsg(pReq->pCont);
pReq->pCont = NULL; pReq->pCont = NULL;
taosMemoryFree(pTransMsg); taosMemoryFree(pTransMsg);
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return code; return code;
} }
/* /*
@ -3295,7 +3292,7 @@ int32_t transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) {
} }
} }
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
return code; return code;
} }
@ -3319,12 +3316,13 @@ int32_t transAllocHandle(int64_t* refId) {
QUEUE_INIT(&exh->q); QUEUE_INIT(&exh->q);
taosInitRWLatch(&exh->latch); taosInitRWLatch(&exh->latch);
tDebug("pre alloc refId %" PRId64 "", exh->refId); tDebug("pre alloc refId %" PRId64 ", alloc exhandle %p", exh->refId, exh);
*refId = exh->refId; *refId = exh->refId;
return 0; return 0;
} }
int32_t transFreeConnById(void* shandle, int64_t transpointId) { int32_t transFreeConnById(void* shandle, int64_t transpointId) {
int32_t code = 0; int32_t code = 0;
SCliMsg* pCli = NULL;
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle);
if (pTransInst == NULL) { if (pTransInst == NULL) {
return TSDB_CODE_RPC_MODULE_QUIT; return TSDB_CODE_RPC_MODULE_QUIT;
@ -3339,7 +3337,7 @@ int32_t transFreeConnById(void* shandle, int64_t transpointId) {
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception); TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception);
} }
SCliMsg* pCli = taosMemoryCalloc(1, sizeof(SCliMsg)); pCli = taosMemoryCalloc(1, sizeof(SCliMsg));
if (pCli == NULL) { if (pCli == NULL) {
TAOS_CHECK_GOTO(terrno, NULL, _exception); TAOS_CHECK_GOTO(terrno, NULL, _exception);
} }
@ -3352,11 +3350,19 @@ int32_t transFreeConnById(void* shandle, int64_t transpointId) {
code = transAsyncSend(pThrd->asyncPool, &pCli->q); code = transAsyncSend(pThrd->asyncPool, &pCli->q);
if (code != 0) { if (code != 0) {
taosMemoryFree(pCli); taosMemoryFreeClear(pCli);
TAOS_CHECK_GOTO(code, NULL, _exception); TAOS_CHECK_GOTO(code, NULL, _exception);
} }
_exception: _exception:
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
if (code != 0) {
if (transpointId != 0) {
(void)transReleaseExHandle(transGetRefMgt(), transpointId);
(void)transRemoveExHandle(transGetRefMgt(), transpointId);
}
taosMemoryFree(pCli);
}
return code; return code;
} }

View File

@ -272,7 +272,7 @@ int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAs
} }
item->pThrd = arg; item->pThrd = arg;
QUEUE_INIT(&item->qmsg); QUEUE_INIT(&item->qmsg);
(void)taosThreadMutexInit(&item->mtx, NULL); TAOS_UNUSED(taosThreadMutexInit(&item->mtx, NULL));
async->data = item; async->data = item;
err = uv_async_init(loop, async, cb); err = uv_async_init(loop, async, cb);
@ -301,7 +301,7 @@ void transAsyncPoolDestroy(SAsyncPool* pool) {
SAsyncItem* item = async->data; SAsyncItem* item = async->data;
if (item == NULL) continue; if (item == NULL) continue;
(void)taosThreadMutexDestroy(&item->mtx); TAOS_UNUSED(taosThreadMutexDestroy(&item->mtx));
taosMemoryFree(item); taosMemoryFree(item);
} }
taosMemoryFree(pool->asyncs); taosMemoryFree(pool->asyncs);
@ -328,9 +328,9 @@ int transAsyncSend(SAsyncPool* pool, queue* q) {
uv_async_t* async = &(pool->asyncs[idx]); uv_async_t* async = &(pool->asyncs[idx]);
SAsyncItem* item = async->data; SAsyncItem* item = async->data;
(void)taosThreadMutexLock(&item->mtx); TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
QUEUE_PUSH(&item->qmsg, q); QUEUE_PUSH(&item->qmsg, q);
(void)taosThreadMutexUnlock(&item->mtx); TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
int ret = uv_async_send(async); int ret = uv_async_send(async);
if (ret != 0) { if (ret != 0) {
tError("failed to send async,reason:%s", uv_err_name(ret)); tError("failed to send async,reason:%s", uv_err_name(ret));
@ -393,7 +393,7 @@ void* transCtxDumpVal(STransCtx* ctx, int32_t key) {
return NULL; return NULL;
} }
void* ret = NULL; void* ret = NULL;
(void)(*cVal->clone)(cVal->val, &ret); TAOS_UNUSED((*cVal->clone)(cVal->val, &ret));
return ret; return ret;
} }
void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) {
@ -401,7 +401,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) {
if (ctx->brokenVal.clone == NULL) { if (ctx->brokenVal.clone == NULL) {
return ret; return ret;
} }
(void)(*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret); TAOS_UNUSED((*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret));
*msgType = ctx->brokenVal.msgType; *msgType = ctx->brokenVal.msgType;
@ -549,7 +549,7 @@ static void transDQTimeout(uv_timer_t* timer) {
} }
} while (1); } while (1);
if (timeout != 0) { if (timeout != 0) {
(void)uv_timer_start(queue->timer, transDQTimeout, timeout, 0); TAOS_UNUSED(uv_timer_start(queue->timer, transDQTimeout, timeout, 0));
} }
} }
int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue) {
@ -614,7 +614,7 @@ void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) {
taosMemoryFree(queue); taosMemoryFree(queue);
} }
void transDQCancel(SDelayQueue* queue, SDelayTask* task) { void transDQCancel(SDelayQueue* queue, SDelayTask* task) {
(void)uv_timer_stop(queue->timer); TAOS_UNUSED(uv_timer_stop(queue->timer));
if (heapSize(queue->heap) <= 0) { if (heapSize(queue->heap) <= 0) {
taosMemoryFree(task->arg); taosMemoryFree(task->arg);
@ -634,7 +634,7 @@ void transDQCancel(SDelayQueue* queue, SDelayTask* task) {
SDelayTask* task = container_of(minNode, SDelayTask, node); SDelayTask* task = container_of(minNode, SDelayTask, node);
uint64_t timeout = now > task->execTime ? now - task->execTime : 0; uint64_t timeout = now > task->execTime ? now - task->execTime : 0;
(void)uv_timer_start(queue->timer, transDQTimeout, timeout, 0); TAOS_UNUSED(uv_timer_start(queue->timer, transDQTimeout, timeout, 0));
} }
} }
@ -659,7 +659,7 @@ SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg,
tTrace("timer %p put task into delay queue, timeoutMs:%" PRIu64, queue->timer, timeoutMs); tTrace("timer %p put task into delay queue, timeoutMs:%" PRIu64, queue->timer, timeoutMs);
heapInsert(queue->heap, &task->node); heapInsert(queue->heap, &task->node);
(void)uv_timer_start(queue->timer, transDQTimeout, timeoutMs, 0); TAOS_UNUSED(uv_timer_start(queue->timer, transDQTimeout, timeoutMs, 0));
return task; return task;
} }
@ -708,7 +708,7 @@ static void transInitEnv() {
svrRefMgt = transOpenRefMgt(50000, transDestroyExHandle); svrRefMgt = transOpenRefMgt(50000, transDestroyExHandle);
instMgt = taosOpenRef(50, rpcCloseImpl); instMgt = taosOpenRef(50, rpcCloseImpl);
transSyncMsgMgt = taosOpenRef(50, transDestroySyncMsg); transSyncMsgMgt = taosOpenRef(50, transDestroySyncMsg);
(void)uv_os_setenv("UV_TCP_SINGLE_ACCEPT", "1"); TAOS_UNUSED(uv_os_setenv("UV_TCP_SINGLE_ACCEPT", "1"));
} }
static void transDestroyEnv() { static void transDestroyEnv() {
transCloseRefMgt(refMgt); transCloseRefMgt(refMgt);
@ -768,6 +768,7 @@ void transDestroyExHandle(void* handle) {
if (!QUEUE_IS_EMPTY(&eh->q)) { if (!QUEUE_IS_EMPTY(&eh->q)) {
tDebug("handle %p mem leak", handle); tDebug("handle %p mem leak", handle);
} }
tDebug("free exhandle %p", handle);
taosMemoryFree(handle); taosMemoryFree(handle);
} }
@ -775,7 +776,7 @@ void transDestroySyncMsg(void* msg) {
if (msg == NULL) return; if (msg == NULL) return;
STransSyncMsg* pSyncMsg = msg; STransSyncMsg* pSyncMsg = msg;
(void)tsem2_destroy(pSyncMsg->pSem); TAOS_UNUSED(tsem2_destroy(pSyncMsg->pSem));
taosMemoryFree(pSyncMsg->pSem); taosMemoryFree(pSyncMsg->pSem);
transFreeMsg(pSyncMsg->pRsp->pCont); transFreeMsg(pSyncMsg->pRsp->pCont);
taosMemoryFree(pSyncMsg->pRsp); taosMemoryFree(pSyncMsg->pRsp);

View File

@ -190,9 +190,9 @@ static int32_t addHandleToAcceptloop(void* arg);
#define SRV_RELEASE_UV(loop) \ #define SRV_RELEASE_UV(loop) \
do { \ do { \
(void)uv_walk(loop, uvWalkCb, NULL); \ TAOS_UNUSED(uv_walk(loop, uvWalkCb, NULL)); \
(void)uv_run(loop, UV_RUN_DEFAULT); \ TAOS_UNUSED(uv_run(loop, UV_RUN_DEFAULT)); \
(void)uv_loop_close(loop); \ TAOS_UNUSED(uv_loop_close(loop)); \
} while (0); } while (0);
#define ASYNC_ERR_JRET(thrd) \ #define ASYNC_ERR_JRET(thrd) \
@ -594,7 +594,7 @@ void uvOnSendCb(uv_write_t* req, int status) {
(pTransInst->cfp)(pTransInst->parent, &(conn->regArg.msg), NULL); (pTransInst->cfp)(pTransInst->parent, &(conn->regArg.msg), NULL);
memset(&conn->regArg, 0, sizeof(conn->regArg)); memset(&conn->regArg, 0, sizeof(conn->regArg));
} }
(void)transQueuePop(&conn->srvMsgs); TAOS_UNUSED(transQueuePop(&conn->srvMsgs));
taosMemoryFree(msg); taosMemoryFree(msg);
msg = (SSvrMsg*)transQueueGet(&conn->srvMsgs, 0); msg = (SSvrMsg*)transQueueGet(&conn->srvMsgs, 0);
@ -651,7 +651,7 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
// handle invalid drop_task resp, TD-20098 // handle invalid drop_task resp, TD-20098
if (pConn->inType == TDMT_SCH_DROP_TASK && pMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) { if (pConn->inType == TDMT_SCH_DROP_TASK && pMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
(void)transQueuePop(&pConn->srvMsgs); TAOS_UNUSED(transQueuePop(&pConn->srvMsgs));
destroySmsg(smsg); destroySmsg(smsg);
return TSDB_CODE_INVALID_MSG; return TSDB_CODE_INVALID_MSG;
} }
@ -707,7 +707,7 @@ static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) {
transRefSrvHandle(pConn); transRefSrvHandle(pConn);
uv_write_t* req = transReqQueuePush(&pConn->wreqQueue); uv_write_t* req = transReqQueuePush(&pConn->wreqQueue);
(void)uv_write(req, (uv_stream_t*)pConn->pTcp, &wb, 1, uvOnSendCb); TAOS_UNUSED(uv_write(req, (uv_stream_t*)pConn->pTcp, &wb, 1, uvOnSendCb));
} }
static void uvStartSendResp(SSvrMsg* smsg) { static void uvStartSendResp(SSvrMsg* smsg) {
// impl // impl
@ -759,9 +759,9 @@ void uvWorkerAsyncCb(uv_async_t* handle) {
queue wq; queue wq;
// batch process to avoid to lock/unlock frequently // batch process to avoid to lock/unlock frequently
(void)taosThreadMutexLock(&item->mtx); TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
QUEUE_MOVE(&item->qmsg, &wq); QUEUE_MOVE(&item->qmsg, &wq);
(void)taosThreadMutexUnlock(&item->mtx); TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
while (!QUEUE_IS_EMPTY(&wq)) { while (!QUEUE_IS_EMPTY(&wq)) {
queue* head = QUEUE_HEAD(&wq); queue* head = QUEUE_HEAD(&wq);
@ -784,12 +784,12 @@ void uvWorkerAsyncCb(uv_async_t* handle) {
SExHandle* exh2 = transAcquireExHandle(transGetSvrRefMgt(), refId); SExHandle* exh2 = transAcquireExHandle(transGetSvrRefMgt(), refId);
if (exh2 == NULL || exh1 != exh2) { if (exh2 == NULL || exh1 != exh2) {
tTrace("handle except msg %p, ignore it", exh1); tTrace("handle except msg %p, ignore it", exh1);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
destroySmsg(msg); destroySmsg(msg);
continue; continue;
} }
msg->pConn = exh1->handle; msg->pConn = exh1->handle;
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
(*transAsyncHandle[msg->type])(msg, pThrd); (*transAsyncHandle[msg->type])(msg, pThrd);
} }
} }
@ -827,7 +827,7 @@ static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) {
tTrace("conn %p received release request", pConn); tTrace("conn %p received release request", pConn);
STraceId traceId = pHead->traceId; STraceId traceId = pHead->traceId;
(void)transClearBuffer(&pConn->readBuf); TAOS_UNUSED(transClearBuffer(&pConn->readBuf));
transFreeMsg(transContFromHead((char*)pHead)); transFreeMsg(transContFromHead((char*)pHead));
if (pConn->status != ConnAcquire) { if (pConn->status != ConnAcquire) {
return true; return true;
@ -906,7 +906,8 @@ void uvOnAcceptCb(uv_stream_t* stream, int status) {
tTrace("new connection accepted by main server, dispatch to %dth worker-thread", pObj->workerIdx); tTrace("new connection accepted by main server, dispatch to %dth worker-thread", pObj->workerIdx);
(void)uv_write2(wr, (uv_stream_t*)&(pObj->pipe[pObj->workerIdx][0]), &buf, 1, (uv_stream_t*)cli, uvOnPipeWriteCb); TAOS_UNUSED(
uv_write2(wr, (uv_stream_t*)&(pObj->pipe[pObj->workerIdx][0]), &buf, 1, (uv_stream_t*)cli, uvOnPipeWriteCb));
} else { } else {
if (!uv_is_closing((uv_handle_t*)cli)) { if (!uv_is_closing((uv_handle_t*)cli)) {
tError("failed to accept tcp: %s", uv_err_name(err)); tError("failed to accept tcp: %s", uv_err_name(err));
@ -971,7 +972,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) { if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) {
uv_os_fd_t fd; uv_os_fd_t fd;
(void)uv_fileno((const uv_handle_t*)pConn->pTcp, &fd); TAOS_UNUSED(uv_fileno((const uv_handle_t*)pConn->pTcp, &fd));
tTrace("conn %p created, fd:%d", pConn, fd); tTrace("conn %p created, fd:%d", pConn, fd);
struct sockaddr peername, sockname; struct sockaddr peername, sockname;
@ -981,7 +982,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
transUnrefSrvHandle(pConn); transUnrefSrvHandle(pConn);
return; return;
} }
(void)transSockInfo2Str(&peername, pConn->dst); TAOS_UNUSED(transSockInfo2Str(&peername, pConn->dst));
addrlen = sizeof(sockname); addrlen = sizeof(sockname);
if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&sockname, &addrlen)) { if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&sockname, &addrlen)) {
@ -989,7 +990,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
transUnrefSrvHandle(pConn); transUnrefSrvHandle(pConn);
return; return;
} }
(void)transSockInfo2Str(&sockname, pConn->src); TAOS_UNUSED(transSockInfo2Str(&sockname, pConn->src));
struct sockaddr_in addr = *(struct sockaddr_in*)&peername; struct sockaddr_in addr = *(struct sockaddr_in*)&peername;
struct sockaddr_in saddr = *(struct sockaddr_in*)&sockname; struct sockaddr_in saddr = *(struct sockaddr_in*)&sockname;
@ -998,7 +999,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
pConn->serverIp = saddr.sin_addr.s_addr; pConn->serverIp = saddr.sin_addr.s_addr;
pConn->port = ntohs(addr.sin_port); pConn->port = ntohs(addr.sin_port);
(void)uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb); TAOS_UNUSED(uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb));
} else { } else {
tDebug("failed to create new connection"); tDebug("failed to create new connection");
@ -1010,7 +1011,7 @@ void* transAcceptThread(void* arg) {
// opt // opt
setThreadName("trans-accept"); setThreadName("trans-accept");
SServerObj* srv = (SServerObj*)arg; SServerObj* srv = (SServerObj*)arg;
(void)uv_run(srv->loop, UV_RUN_DEFAULT); TAOS_UNUSED(uv_run(srv->loop, UV_RUN_DEFAULT));
return NULL; return NULL;
} }
@ -1021,7 +1022,7 @@ void uvOnPipeConnectionCb(uv_connect_t* connect, int status) {
}; };
SWorkThrd* pThrd = container_of(connect, SWorkThrd, connect_req); SWorkThrd* pThrd = container_of(connect, SWorkThrd, connect_req);
(void)uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); TAOS_UNUSED(uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb));
} }
static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) {
int32_t code = 0; int32_t code = 0;
@ -1124,7 +1125,7 @@ static int32_t addHandleToAcceptloop(void* arg) {
void* transWorkerThread(void* arg) { void* transWorkerThread(void* arg) {
setThreadName("trans-svr-work"); setThreadName("trans-svr-work");
SWorkThrd* pThrd = (SWorkThrd*)arg; SWorkThrd* pThrd = (SWorkThrd*)arg;
(void)uv_run(pThrd->loop, UV_RUN_DEFAULT); TAOS_UNUSED(uv_run(pThrd->loop, UV_RUN_DEFAULT));
return NULL; return NULL;
} }
@ -1201,7 +1202,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) {
_end: _end:
if (pConn) { if (pConn) {
transQueueDestroy(&pConn->srvMsgs); transQueueDestroy(&pConn->srvMsgs);
(void)transDestroyBuffer(&pConn->readBuf); TAOS_UNUSED(transDestroyBuffer(&pConn->readBuf));
taosMemoryFree(pConn->pTcp); taosMemoryFree(pConn->pTcp);
taosMemoryFree(pConn); taosMemoryFree(pConn);
pConn = NULL; pConn = NULL;
@ -1230,8 +1231,8 @@ static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) {
} }
static int32_t reallocConnRef(SSvrConn* conn) { static int32_t reallocConnRef(SSvrConn* conn) {
if (conn->refId > 0) { if (conn->refId > 0) {
(void)transReleaseExHandle(transGetSvrRefMgt(), conn->refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), conn->refId));
(void)transRemoveExHandle(transGetSvrRefMgt(), conn->refId); TAOS_UNUSED(transRemoveExHandle(transGetSvrRefMgt(), conn->refId));
} }
// avoid app continue to send msg on invalid handle // avoid app continue to send msg on invalid handle
SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle));
@ -1267,8 +1268,8 @@ static void uvDestroyConn(uv_handle_t* handle) {
} }
SWorkThrd* thrd = conn->hostThrd; SWorkThrd* thrd = conn->hostThrd;
(void)transReleaseExHandle(transGetSvrRefMgt(), conn->refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), conn->refId));
(void)transRemoveExHandle(transGetSvrRefMgt(), conn->refId); TAOS_UNUSED(transRemoveExHandle(transGetSvrRefMgt(), conn->refId));
STrans* pTransInst = thrd->pTransInst; STrans* pTransInst = thrd->pTransInst;
tDebug("%s conn %p destroy", transLabel(pTransInst), conn); tDebug("%s conn %p destroy", transLabel(pTransInst), conn);
@ -1283,7 +1284,7 @@ static void uvDestroyConn(uv_handle_t* handle) {
QUEUE_REMOVE(&conn->queue); QUEUE_REMOVE(&conn->queue);
taosMemoryFree(conn->pTcp); taosMemoryFree(conn->pTcp);
destroyConnRegArg(conn); destroyConnRegArg(conn);
(void)transDestroyBuffer(&conn->readBuf); TAOS_UNUSED(transDestroyBuffer(&conn->readBuf));
taosMemoryFree(conn); taosMemoryFree(conn);
if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) { if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) {
@ -1563,7 +1564,7 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd) {
if (!transQueuePush(&conn->srvMsgs, msg)) { if (!transQueuePush(&conn->srvMsgs, msg)) {
return; return;
} }
(void)transQueuePop(&conn->srvMsgs); TAOS_UNUSED(transQueuePop(&conn->srvMsgs));
if (conn->regArg.init) { if (conn->regArg.init) {
transFreeMsg(conn->regArg.msg.pCont); transFreeMsg(conn->regArg.msg.pCont);
@ -1636,7 +1637,7 @@ void destroyWorkThrd(SWorkThrd* pThrd) {
} }
if (pThrd->inited) { if (pThrd->inited) {
sendQuitToWorkThrd(pThrd); sendQuitToWorkThrd(pThrd);
(void)taosThreadJoin(pThrd->thread, NULL); TAOS_UNUSED(taosThreadJoin(pThrd->thread, NULL));
SRV_RELEASE_UV(pThrd->loop); SRV_RELEASE_UV(pThrd->loop);
TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SSvrMsg, destroySmsgWrapper, NULL); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SSvrMsg, destroySmsgWrapper, NULL);
} }
@ -1646,7 +1647,7 @@ void sendQuitToWorkThrd(SWorkThrd* pThrd) {
SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg));
msg->type = Quit; msg->type = Quit;
tDebug("server send quit msg to work thread"); tDebug("server send quit msg to work thread");
(void)transAsyncSend(pThrd->asyncPool, &msg->q); TAOS_UNUSED(transAsyncSend(pThrd->asyncPool, &msg->q));
} }
void transCloseServer(void* arg) { void transCloseServer(void* arg) {
@ -1655,8 +1656,8 @@ void transCloseServer(void* arg) {
if (srv->inited) { if (srv->inited) {
tDebug("send quit msg to accept thread"); tDebug("send quit msg to accept thread");
(void)uv_async_send(srv->pAcceptAsync); TAOS_UNUSED(uv_async_send(srv->pAcceptAsync));
(void)taosThreadJoin(srv->thread, NULL); TAOS_UNUSED(taosThreadJoin(srv->thread, NULL));
SRV_RELEASE_UV(srv->loop); SRV_RELEASE_UV(srv->loop);
for (int i = 0; i < srv->numOfThreads; i++) { for (int i = 0; i < srv->numOfThreads; i++) {
@ -1724,15 +1725,15 @@ int32_t transReleaseSrvHandle(void* handle) {
tDebug("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); tDebug("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle);
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
destroySmsg(m); destroySmsg(m);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return code; return code;
} }
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return 0; return 0;
_return1: _return1:
tDebug("handle %p failed to send to release handle", exh); tDebug("handle %p failed to send to release handle", exh);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return code; return code;
_return2: _return2:
tDebug("handle %p failed to send to release handle", exh); tDebug("handle %p failed to send to release handle", exh);
@ -1775,17 +1776,17 @@ int32_t transSendResponse(const STransMsg* msg) {
tGDebug("conn %p start to send resp (1/2)", exh->handle); tGDebug("conn %p start to send resp (1/2)", exh->handle);
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
destroySmsg(m); destroySmsg(m);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return code; return code;
} }
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return 0; return 0;
_return1: _return1:
tDebug("handle %p failed to send resp", exh); tDebug("handle %p failed to send resp", exh);
rpcFreeCont(msg->pCont); rpcFreeCont(msg->pCont);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return code; return code;
_return2: _return2:
tDebug("handle %p failed to send resp", exh); tDebug("handle %p failed to send resp", exh);
@ -1820,17 +1821,17 @@ int32_t transRegisterMsg(const STransMsg* msg) {
tDebug("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle); tDebug("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle);
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
destroySmsg(m); destroySmsg(m);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return code; return code;
} }
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return 0; return 0;
_return1: _return1:
tDebug("handle %p failed to register brokenlink", exh); tDebug("handle %p failed to register brokenlink", exh);
rpcFreeCont(msg->pCont); rpcFreeCont(msg->pCont);
(void)transReleaseExHandle(transGetSvrRefMgt(), refId); TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
return code; return code;
_return2: _return2:
tDebug("handle %p failed to register brokenlink", exh); tDebug("handle %p failed to register brokenlink", exh);
@ -1875,7 +1876,7 @@ int32_t transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) {
break; break;
} }
} }
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)thandle); TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)thandle));
if (code != 0) { if (code != 0) {
tError("ip-white-list update failed since %s", tstrerror(code)); tError("ip-white-list update failed since %s", tstrerror(code));

View File

@ -86,11 +86,9 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
} }
int32_t walApplyVer(SWal *pWal, int64_t ver) { void walApplyVer(SWal *pWal, int64_t ver) {
// TODO: error check // TODO: error check
pWal->vers.appliedVer = ver; pWal->vers.appliedVer = ver;
TAOS_RETURN(TSDB_CODE_SUCCESS);
} }
int32_t walCommit(SWal *pWal, int64_t ver) { int32_t walCommit(SWal *pWal, int64_t ver) {
@ -603,7 +601,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
wError("vgId:%d, file:%" PRId64 ".log, failed to malloc since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal), wError("vgId:%d, file:%" PRId64 ".log, failed to malloc since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
strerror(errno)); strerror(errno));
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); TAOS_CHECK_GOTO(terrno, &lino, _exit);
} }
TAOS_UNUSED(memset(newBody, 0, cyptedBodyLen)); TAOS_UNUSED(memset(newBody, 0, cyptedBodyLen));
TAOS_UNUSED(memcpy(newBody, body, plainBodyLen)); TAOS_UNUSED(memcpy(newBody, body, plainBodyLen));
@ -615,7 +613,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
if (newBody != NULL) taosMemoryFreeClear(newBody); if (newBody != NULL) taosMemoryFreeClear(newBody);
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); TAOS_CHECK_GOTO(terrno, &lino, _exit);
} }
SCryptOpts opts; SCryptOpts opts;

View File

@ -232,7 +232,7 @@ int32_t tsem_init(tsem_t *psem, int flags, unsigned int count) {
if(sem_init(psem, flags, count) == 0) { if(sem_init(psem, flags, count) == 0) {
return 0; return 0;
} else { } else {
return TAOS_SYSTEM_ERROR(errno); return terrno = TAOS_SYSTEM_ERROR(errno);
} }
} }

View File

@ -335,7 +335,7 @@ int32_t taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, con
if (buf == NULL) { if (buf == NULL) {
tmp = taosMemoryMalloc(size); tmp = taosMemoryMalloc(size);
if (NULL == tmp) { if (NULL == tmp) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
} else { } else {
tmp = buf; tmp = buf;
@ -467,7 +467,7 @@ static int32_t taosMergeSortHelper(void *src, int64_t numOfElem, int64_t size, c
int32_t currSize; int32_t currSize;
void *tmp = taosMemoryMalloc(numOfElem * size); void *tmp = taosMemoryMalloc(numOfElem * size);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
for (currSize = THRESHOLD_SIZE; currSize <= numOfElem - 1; currSize = 2 * currSize) { for (currSize = THRESHOLD_SIZE; currSize <= numOfElem - 1; currSize = 2 * currSize) {

View File

@ -22,7 +22,7 @@ int32_t base64_encode(const uint8_t *value, int32_t vlen, char **result) {
uint8_t oval = 0; uint8_t oval = 0;
*result = (char *)taosMemoryMalloc((size_t)(vlen * 4) / 3 + 10); *result = (char *)taosMemoryMalloc((size_t)(vlen * 4) / 3 + 10);
if (*result == NULL) { if (*result == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
char *out = *result; char *out = *result;
while (vlen >= 3) { while (vlen >= 3) {
@ -58,7 +58,7 @@ int32_t base64_decode(const char *value, int32_t inlen, int32_t *outlen, uint8_t
int32_t c1, c2, c3, c4; int32_t c1, c2, c3, c4;
*result = (uint8_t *)taosMemoryMalloc((size_t)(inlen * 3) / 4 + 1); *result = (uint8_t *)taosMemoryMalloc((size_t)(inlen * 3) / 4 + 1);
if (*result == NULL) { if (*result == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
uint8_t *out = *result; uint8_t *out = *result;

View File

@ -1766,12 +1766,12 @@ int32_t tsDecompressBigint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in
FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, cmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_BIGINT, 0); FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, cmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_BIGINT, 0);
} }
int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level) { void tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t *level) {
DEFINE_VAR(cmprAlg) DEFINE_VAR(cmprAlg)
*l1Alg = l1; *l1Alg = l1;
*l2Alg = l2; *l2Alg = l2;
*level = lvl; *level = lvl;
return 0; return;
} }
int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, uint8_t lvlDiabled, uint8_t lvlDefault, int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, uint8_t lvlDiabled, uint8_t lvlDefault,

View File

@ -78,7 +78,7 @@ int32_t tStartEncode(SEncoder* pCoder) {
pNode = tEncoderMalloc(pCoder, sizeof(*pNode)); pNode = tEncoderMalloc(pCoder, sizeof(*pNode));
if (pNode == NULL) { if (pNode == NULL) {
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); TAOS_RETURN(terrno);
} }
pNode->data = pCoder->data; pNode->data = pCoder->data;
@ -126,7 +126,7 @@ int32_t tStartDecode(SDecoder* pCoder) {
pNode = tDecoderMalloc(pCoder, sizeof(*pNode)); pNode = tDecoderMalloc(pCoder, sizeof(*pNode));
if (pNode == NULL) { if (pNode == NULL) {
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); TAOS_RETURN(terrno);
} }
pNode->data = pCoder->data; pNode->data = pCoder->data;

View File

@ -224,7 +224,9 @@ int32_t taosWriteQitem(STaosQueue *queue, void *pItem) {
(void)taosThreadMutexUnlock(&queue->mutex); (void)taosThreadMutexUnlock(&queue->mutex);
if (queue->qset) { if (queue->qset) {
(void)tsem_post(&queue->qset->sem); if (tsem_post(&queue->qset->sem) != 0) {
uError("failed to post semaphore for queue set:%p", queue->qset);
}
} }
return code; return code;
} }
@ -333,7 +335,10 @@ int32_t taosOpenQset(STaosQset **qset) {
} }
(void)taosThreadMutexInit(&(*qset)->mutex, NULL); (void)taosThreadMutexInit(&(*qset)->mutex, NULL);
(void)tsem_init(&(*qset)->sem, 0, 0); if (tsem_init(&(*qset)->sem, 0, 0) != 0) {
taosMemoryFree(*qset);
return terrno;
}
uDebug("qset:%p is opened", qset); uDebug("qset:%p is opened", qset);
return 0; return 0;
@ -354,7 +359,9 @@ void taosCloseQset(STaosQset *qset) {
(void)taosThreadMutexUnlock(&qset->mutex); (void)taosThreadMutexUnlock(&qset->mutex);
(void)taosThreadMutexDestroy(&qset->mutex); (void)taosThreadMutexDestroy(&qset->mutex);
(void)tsem_destroy(&qset->sem); if (tsem_destroy(&qset->sem) != 0) {
uError("failed to destroy semaphore for qset:%p", qset);
}
taosMemoryFree(qset); taosMemoryFree(qset);
uDebug("qset:%p is closed", qset); uDebug("qset:%p is closed", qset);
} }
@ -364,7 +371,9 @@ void taosCloseQset(STaosQset *qset) {
// thread to exit. // thread to exit.
void taosQsetThreadResume(STaosQset *qset) { void taosQsetThreadResume(STaosQset *qset) {
uDebug("qset:%p, it will exit", qset); uDebug("qset:%p, it will exit", qset);
(void)tsem_post(&qset->sem); if (tsem_post(&qset->sem) != 0) {
uError("failed to post semaphore for qset:%p", qset);
}
} }
int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle) { int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle) {
@ -432,7 +441,9 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo)
STaosQnode *pNode = NULL; STaosQnode *pNode = NULL;
int32_t code = 0; int32_t code = 0;
(void)tsem_wait(&qset->sem); if (tsem_wait(&qset->sem) != 0) {
uError("failed to wait semaphore for qset:%p", qset);
}
(void)taosThreadMutexLock(&qset->mutex); (void)taosThreadMutexLock(&qset->mutex);
@ -476,7 +487,9 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo *
STaosQueue *queue; STaosQueue *queue;
int32_t code = 0; int32_t code = 0;
(void)tsem_wait(&qset->sem); if (tsem_wait(&qset->sem) != 0) {
uError("failed to wait semaphore for qset:%p", qset);
}
(void)taosThreadMutexLock(&qset->mutex); (void)taosThreadMutexLock(&qset->mutex);
for (int32_t i = 0; i < qset->numOfQueues; ++i) { for (int32_t i = 0; i < qset->numOfQueues; ++i) {
@ -510,7 +523,9 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo *
(void)atomic_sub_fetch_32(&qset->numOfItems, qall->numOfItems); (void)atomic_sub_fetch_32(&qset->numOfItems, qall->numOfItems);
for (int32_t j = 1; j < qall->numOfItems; ++j) { for (int32_t j = 1; j < qall->numOfItems; ++j) {
(void)tsem_wait(&qset->sem); if (tsem_wait(&qset->sem) != 0) {
uError("failed to wait semaphore for qset:%p", qset);
}
} }
} }

View File

@ -46,7 +46,7 @@ int32_t tScalableBfInit(uint64_t expectedEntries, double errorRate, SScalableBf*
pSBf->numBits = 0; pSBf->numBits = 0;
pSBf->bfArray = taosArrayInit(defaultSize, sizeof(void*)); pSBf->bfArray = taosArrayInit(defaultSize, sizeof(void*));
if (!pSBf->bfArray) { if (!pSBf->bfArray) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
} }
@ -76,7 +76,7 @@ int32_t tScalableBfPutNoCheck(SScalableBf* pSBf, const void* keyBuf, uint32_t le
int32_t size = taosArrayGetSize(pSBf->bfArray); int32_t size = taosArrayGetSize(pSBf->bfArray);
SBloomFilter* pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1); SBloomFilter* pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1);
if (!pNormalBf) { if (!pNormalBf) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
} }
if (tBloomFilterIsFull(pNormalBf)) { if (tBloomFilterIsFull(pNormalBf)) {
@ -236,7 +236,7 @@ int32_t tScalableBfDecode(SDecoder* pDecoder, SScalableBf** ppSBf) {
} }
pSBf->bfArray = taosArrayInit(size * 2, POINTER_BYTES); pSBf->bfArray = taosArrayInit(size * 2, POINTER_BYTES);
if (!pSBf->bfArray) { if (!pSBf->bfArray) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
} }
@ -246,7 +246,7 @@ int32_t tScalableBfDecode(SDecoder* pDecoder, SScalableBf** ppSBf) {
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
void* tmpRes = taosArrayPush(pSBf->bfArray, &pBF); void* tmpRes = taosArrayPush(pSBf->bfArray, &pBF);
if (!tmpRes) { if (!tmpRes) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
QUERY_CHECK_CODE(code, lino, _error); QUERY_CHECK_CODE(code, lino, _error);
} }
} }

View File

@ -178,7 +178,7 @@ int32_t tAutoQWorkerInit(SAutoQWorkerPool *pool) {
pool->workers = taosArrayInit(2, sizeof(SQueueWorker *)); pool->workers = taosArrayInit(2, sizeof(SQueueWorker *));
if (pool->workers == NULL) { if (pool->workers == NULL) {
taosCloseQset(pool->qset); taosCloseQset(pool->qset);
return terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
(void)taosThreadMutexInit(&pool->mutex, NULL); (void)taosThreadMutexInit(&pool->mutex, NULL);

View File

@ -280,6 +280,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_ts-5473.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_ts4563.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_ts4563.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_replay.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_replay.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py

View File

@ -1,5 +1,6 @@
import csv import csv
import os import os
import platform
class TDCsv: class TDCsv:
def __init__(self): def __init__(self):
@ -25,7 +26,11 @@ class TDCsv:
@property @property
def file(self): def file(self):
if self.file_name and self.file_path: if self.file_name and self.file_path:
return os.path.join(self.file_path, self.file_name) print(f"self.file_path {self.file_path}, self.file_name {self.file_name}")
csv_file = os.path.join(self.file_path, self.file_name)
if platform.system().lower() == 'windows':
csv_file = csv_file.replace("\\", "/")
return csv_file
return None return None

View File

@ -24,26 +24,48 @@ from util.log import *
from util.constant import * from util.constant import *
import ctypes import ctypes
import random import random
# from datetime import timezone import datetime
import time import time
from tzlocal import get_localzone
def _parse_ns_timestamp(timestr): def _parse_ns_timestamp(timestr):
dt_obj = datetime.datetime.strptime(timestr[:len(timestr)-3], "%Y-%m-%d %H:%M:%S.%f") dt_obj = datetime.datetime.strptime(timestr[:len(timestr)-3], "%Y-%m-%d %H:%M:%S.%f")
tz = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1e9) + int(dt_obj.microsecond * 1000) + int(timestr[-3:]) tz = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1e9) + int(dt_obj.microsecond * 1000) + int(timestr[-3:])
return tz return tz
def _parse_datetime(timestr): def _parse_datetime(timestr):
# defined timestr formats
formats = [
'%Y-%m-%d %H:%M:%S.%f%z', # 包含微秒和时区偏移
'%Y-%m-%d %H:%M:%S%z', # 不包含微秒但包含时区偏移
'%Y-%m-%d %H:%M:%S.%f', # 包含微秒
'%Y-%m-%d %H:%M:%S' # 不包含微秒
]
for fmt in formats:
try: try:
return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') # try to parse the string with the current format
dt = datetime.datetime.strptime(timestr, fmt)
# 如果字符串包含时区信息,则返回 aware 对象
# if sting contains timezone info, return aware object
if dt.tzinfo is not None:
return dt
else:
# if sting does not contain timezone info, assume it is in local timezone
# get local timezone
local_timezone = get_localzone()
# print("Timezone:", local_timezone)
return dt.replace(tzinfo=local_timezone)
except ValueError: except ValueError:
pass continue # if the current format does not match, try the next format
try:
return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') # 如果所有格式都不匹配,返回 None
except ValueError: # if none of the formats match, return
pass raise ValueError(f"input format does not match. correct formats include: '{', '.join(formats)}'")
class TDSql: class TDSql:
def __init__(self): def __init__(self):
self.queryRows = 0 self.queryRows = 0
self.queryCols = 0 self.queryCols = 0
@ -408,6 +430,7 @@ class TDSql:
if self.queryResult[row][col] != data: if self.queryResult[row][col] != data:
if self.cursor.istype(col, "TIMESTAMP"): if self.cursor.istype(col, "TIMESTAMP"):
# tdLog.debug(f"self.queryResult[row][col]:{self.queryResult[row][col]}, data:{data},len(data):{len(data)}, isinstance(data,str) :{isinstance(data,str)}")
# suppose user want to check nanosecond timestamp if a longer data passed`` # suppose user want to check nanosecond timestamp if a longer data passed``
if isinstance(data,str) : if isinstance(data,str) :
if (len(data) >= 28): if (len(data) >= 28):
@ -419,8 +442,9 @@ class TDSql:
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args)
else: else:
# tdLog.info(f"datetime.timezone.utc:{datetime.timezone.utc},data:{data},_parse_datetime(data).astimezone(datetime.timezone.utc):{_parse_datetime(data).astimezone(datetime.timezone.utc)}")
if self.queryResult[row][col].astimezone(datetime.timezone.utc) == _parse_datetime(data).astimezone(datetime.timezone.utc): if self.queryResult[row][col].astimezone(datetime.timezone.utc) == _parse_datetime(data).astimezone(datetime.timezone.utc):
# tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col].astimezone(datetime.timezone.utc)} == expect:{_parse_datetime(data).astimezone(datetime.timezone.utc)}")
if(show): if(show):
tdLog.info("check successfully") tdLog.info("check successfully")
else: else:

View File

@ -133,7 +133,7 @@ class TDTestCase:
def run(self): def run(self):
self.topic_name_check() self.topic_name_check()
self.db_name_check() self.db_name_check()
if platform.system().lower() == 'windows': if platform.system().lower() != 'windows':
self.stream_name_check() self.stream_name_check()
self.table_name_check() self.table_name_check()
self.view_name_check() self.view_name_check()

View File

@ -203,7 +203,7 @@ class TDTestCase:
assert str(v) == str(value) assert str(v) == str(value)
else: else:
for v in values: for v in values:
tdLog.debug("Set {} to {}".format(name, v)) tdLog.debug("Set client {} to {}".format(name, v))
tdSql.error(f'alter local "{name} {v}";') tdSql.error(f'alter local "{name} {v}";')
def svr_check(self, item, except_values=False): def svr_check(self, item, except_values=False):

View File

@ -4,6 +4,7 @@ from util.log import *
from util.sql import * from util.sql import *
from util.cases import * from util.cases import *
from util.csv import * from util.csv import *
import platform
import os import os
import taos import taos
import json import json
@ -56,7 +57,6 @@ class TDTestCase:
tdSql.init(conn.cursor(), True) tdSql.init(conn.cursor(), True)
self.testcasePath = os.path.split(__file__)[0] self.testcasePath = os.path.split(__file__)[0]
self.testcasePath = self.testcasePath.replace('\\', '//')
self.testcaseFilename = os.path.split(__file__)[-1] self.testcaseFilename = os.path.split(__file__)[-1]
os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename))
# tdSql.execute(f"insert into db4096.ctb00 file '{self.testcasePath}//tableColumn4096csvLength64k.csv'") # tdSql.execute(f"insert into db4096.ctb00 file '{self.testcasePath}//tableColumn4096csvLength64k.csv'")

View File

@ -285,7 +285,7 @@ class TDTestCase:
self.drop_table_with_check() self.drop_table_with_check()
self.drop_table_with_check_tsma() self.drop_table_with_check_tsma()
self.drop_topic_check() self.drop_topic_check()
if platform.system().lower() == 'windows': if platform.system().lower() != 'windows':
self.drop_stream_check() self.drop_stream_check()
pass pass
def stop(self): def stop(self):

View File

@ -1,6 +1,5 @@
import queue import queue
import random import random
from fabric2.runners import threading
from pandas._libs import interval from pandas._libs import interval
import taos import taos
import sys import sys
@ -9,6 +8,7 @@ from util.common import TDCom
from util.log import * from util.log import *
from util.sql import * from util.sql import *
from util.cases import * from util.cases import *
import threading

View File

@ -140,14 +140,14 @@ class TDTestCase:
tdsql2 = tdCom.newTdSqlWithTimezone(timezone="UTC") tdsql2 = tdCom.newTdSqlWithTimezone(timezone="UTC")
tdsql2.query(f"select * from {dbname}.tzt") tdsql2.query(f"select * from {dbname}.tzt")
tdsql2.checkRows(1) tdsql2.checkRows(1)
tdsql2.checkData(0, 0, "2018-09-17 01:00:00") # checkData:The expected date and time is the local time zone of the machine where the test case is executed.
tdsql2.checkData(0, 0, "2018-09-17 09:00:00")
tdsql2.execute(f'insert into {dbname}.tzt values({self.ts + 1000}, 2)') tdsql2.execute(f'insert into {dbname}.tzt values({self.ts + 1000}, 2)')
tdsql2.query(f"select * from {dbname}.tzt order by ts") tdsql2.query(f"select * from {dbname}.tzt order by ts")
tdsql2.checkRows(2) tdsql2.checkRows(2)
tdsql2.checkData(0, 0, "2018-09-17 01:00:00") tdsql2.checkData(0, 0, "2018-09-17 09:00:00")
tdsql2.checkData(1, 0, "2018-09-17 01:00:01") tdsql2.checkData(1, 0, "2018-09-17 09:00:01")
tdsql2 = tdCom.newTdSqlWithTimezone(timezone="Asia/Shanghai") tdsql2 = tdCom.newTdSqlWithTimezone(timezone="Asia/Shanghai")
tdsql2.query(f"select * from {dbname}.tzt order by ts") tdsql2.query(f"select * from {dbname}.tzt order by ts")
@ -160,7 +160,7 @@ class TDTestCase:
tdSql.prepare() tdSql.prepare()
self.timeZoneTest() self.timeZoneTest()
self.inAndNotinTest() # self.inAndNotinTest()
def stop(self): def stop(self):
@ -168,4 +168,5 @@ class TDTestCase:
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase()) tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase())

View File

@ -0,0 +1,39 @@
import taos
import sys
import time
import socket
import os
import threading
from util.log import *
from util.sql import *
from util.cases import *
from util.dnodes import *
from util.common import *
from taos.tmq import *
sys.path.append("./7-tmq")
from tmqCommon import *
class TDTestCase:
updatecfgDict = {'debugFlag': 135, 'asynclog': 0}
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug(f"start to excute {__file__}")
tdSql.init(conn.cursor())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
def run(self):
buildPath = tdCom.getBuildPath()
cmdStr = '%s/build/bin/tmq_write_raw_test'%(buildPath)
tdLog.info(cmdStr)
os.system(cmdStr)
return
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())

View File

@ -18,7 +18,7 @@ IF (TD_WEBSOCKET)
COMMAND git clean -f -d COMMAND git clean -f -d
BUILD_COMMAND BUILD_COMMAND
COMMAND cargo update COMMAND cargo update
COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features rustls COMMAND export CFLAGS=-fno-builtin && RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features rustls
INSTALL_COMMAND INSTALL_COMMAND
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
@ -37,7 +37,7 @@ IF (TD_WEBSOCKET)
COMMAND git clean -f -d COMMAND git clean -f -d
BUILD_COMMAND BUILD_COMMAND
COMMAND cargo update COMMAND cargo update
COMMAND cargo build --release -p taos-ws-sys --features rustls COMMAND export CFLAGS=-fno-builtin && cargo build --release -p taos-ws-sys --features rustls
INSTALL_COMMAND INSTALL_COMMAND
COMMAND cp target/release/taosws.dll ${CMAKE_BINARY_DIR}/build/lib COMMAND cp target/release/taosws.dll ${CMAKE_BINARY_DIR}/build/lib
COMMAND cp target/release/taosws.dll.lib ${CMAKE_BINARY_DIR}/build/lib/taosws.lib COMMAND cp target/release/taosws.dll.lib ${CMAKE_BINARY_DIR}/build/lib/taosws.lib
@ -57,7 +57,7 @@ IF (TD_WEBSOCKET)
COMMAND git clean -f -d COMMAND git clean -f -d
BUILD_COMMAND BUILD_COMMAND
COMMAND cargo update COMMAND cargo update
COMMAND cargo build --release -p taos-ws-sys --features rustls COMMAND export CFLAGS=-fno-builtin && cargo build --release -p taos-ws-sys --features rustls
INSTALL_COMMAND INSTALL_COMMAND
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include

View File

@ -34,10 +34,10 @@ int shell_conn_ws_server(bool first) {
size_t len = strlen(shell.args.dsn); size_t len = strlen(shell.args.dsn);
char * dsn = taosMemoryMalloc(len + 32); char * dsn = taosMemoryMalloc(len + 32);
sprintf(dsn, "%s&conn_mode=1", shell.args.dsn); sprintf(dsn, "%s&conn_mode=1", shell.args.dsn);
shell.ws_conn = ws_connect_with_dsn(dsn); shell.ws_conn = ws_connect(dsn);
taosMemoryFree(dsn); taosMemoryFree(dsn);
} else { } else {
shell.ws_conn = ws_connect_with_dsn(shell.args.dsn); shell.ws_conn = ws_connect(shell.args.dsn);
} }
if (NULL == shell.ws_conn) { if (NULL == shell.ws_conn) {
@ -95,7 +95,7 @@ int shell_conn_ws_server(bool first) {
static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) { static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) {
const void* data = NULL; const void* data = NULL;
int rows; int rows;
ws_fetch_block(wres, &data, &rows); ws_fetch_raw_block(wres, &data, &rows);
if (wres) { if (wres) {
*execute_time += (double)(ws_take_timing(wres)/1E6); *execute_time += (double)(ws_take_timing(wres)/1E6);
} }
@ -129,7 +129,7 @@ static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) {
putchar('\n'); putchar('\n');
} }
numOfRows += rows; numOfRows += rows;
ws_fetch_block(wres, &data, &rows); ws_fetch_raw_block(wres, &data, &rows);
} while (rows && !shell.stop_query); } while (rows && !shell.stop_query);
return numOfRows; return numOfRows;
} }
@ -137,7 +137,7 @@ static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) {
static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) { static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) {
int rows = 0; int rows = 0;
const void* data = NULL; const void* data = NULL;
ws_fetch_block(wres, &data, &rows); ws_fetch_raw_block(wres, &data, &rows);
if (wres) { if (wres) {
*pexecute_time += (double)(ws_take_timing(wres)/1E6); *pexecute_time += (double)(ws_take_timing(wres)/1E6);
} }
@ -172,7 +172,7 @@ static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) {
} }
numOfRows++; numOfRows++;
} }
ws_fetch_block(wres, &data, &rows); ws_fetch_raw_block(wres, &data, &rows);
} while (rows && !shell.stop_query); } while (rows && !shell.stop_query);
return numOfRows; return numOfRows;
} }
@ -192,7 +192,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres,
} }
int rows = 0; int rows = 0;
const void* data = NULL; const void* data = NULL;
ws_fetch_block(wres, &data, &rows); ws_fetch_raw_block(wres, &data, &rows);
if (wres) { if (wres) {
*pexecute_time += (double)(ws_take_timing(wres)/1E6); *pexecute_time += (double)(ws_take_timing(wres)/1E6);
} }
@ -226,7 +226,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres,
} }
taosFprintfFile(pFile, "\r\n"); taosFprintfFile(pFile, "\r\n");
} }
ws_fetch_block(wres, &data, &rows); ws_fetch_raw_block(wres, &data, &rows);
} while (rows && !shell.stop_query); } while (rows && !shell.stop_query);
taosCloseFile(&pFile); taosCloseFile(&pFile);
return numOfRows; return numOfRows;

View File

@ -3,6 +3,7 @@ add_dependencies(tmq_demo taos)
add_executable(tmq_sim tmqSim.c) add_executable(tmq_sim tmqSim.c)
add_executable(create_table createTable.c) add_executable(create_table createTable.c)
add_executable(tmq_taosx_ci tmq_taosx_ci.c) add_executable(tmq_taosx_ci tmq_taosx_ci.c)
add_executable(tmq_write_raw_test tmq_write_raw_test.c)
add_executable(write_raw_block_test write_raw_block_test.c) add_executable(write_raw_block_test write_raw_block_test.c)
add_executable(sml_test sml_test.c) add_executable(sml_test sml_test.c)
add_executable(get_db_name_test get_db_name_test.c) add_executable(get_db_name_test get_db_name_test.c)
@ -84,6 +85,14 @@ target_link_libraries(
PUBLIC os PUBLIC os
) )
target_link_libraries(
tmq_write_raw_test
PUBLIC taos
PUBLIC util
PUBLIC common
PUBLIC os
)
target_link_libraries( target_link_libraries(
sml_test sml_test
PUBLIC taos PUBLIC taos

View File

@ -0,0 +1,281 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "cJSON.h"
#include "taos.h"
#include "tmsg.h"
#include "types.h"
static TAOS* use_db() {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
if (pConn == NULL) {
return NULL;
}
TAOS_RES* pRes = taos_query(pConn, "use db_taosx");
if (taos_errno(pRes) != 0) {
printf("error in use db_taosx, reason:%s\n", taos_errstr(pRes));
return NULL;
}
taos_free_result(pRes);
return pConn;
}
static void msg_process(TAOS_RES* msg) {
printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg));
printf("db: %s\n", tmq_get_db_name(msg));
printf("vg: %d\n", tmq_get_vgroup_id(msg));
TAOS* pConn = use_db();
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META || tmq_get_res_type(msg) == TMQ_RES_METADATA) {
char* result = tmq_get_json_meta(msg);
printf("meta result: %s\n", result);
tmq_free_json_meta(result);
}
tmq_raw_data raw = {0};
tmq_get_raw(msg, &raw);
printf("write raw data type: %d\n", raw.raw_type);
int32_t ret = tmq_write_raw(pConn, raw);
printf("write raw data: %s\n", tmq_err2str(ret));
ASSERT(ret == 0);
tmq_free_raw(raw);
taos_close(pConn);
}
int buildDatabase(TAOS* pConn, TAOS_RES* pRes) {
pRes = taos_query(pConn,
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
"nchar(8), t4 bool)");
if (taos_errno(pRes) != 0) {
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)");
if (taos_errno(pRes) != 0) {
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into ct0 using st1 tags(1000, \"ttt\", true) values(1626006833400, 1, 2, 'a')");
if (taos_errno(pRes) != 0) {
printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)");
if (taos_errno(pRes) != 0) {
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)");
if (taos_errno(pRes) != 0) {
printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into ct1 using st1(t1) tags(2000) values(1626006833600, 3, 4, 'b')");
if (taos_errno(pRes) != 0) {
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)");
if (taos_errno(pRes) != 0) {
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into ct0 using st1 tags(1000, \"ttt\", true) values(1626006833400, 1, 2, 'a')");
if (taos_errno(pRes) != 0) {
printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into ct1 using st1(t1) tags(2000) values(1626006833600, 3, 4, 'b')");
if (taos_errno(pRes) != 0) {
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(
pConn,
"insert into ct3 using st1(t1) tags(3000) values(1626006833600, 5, 6, 'c') ct1 using st1(t1) tags(2000) values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, "
"'ddd') ct0 using st1 tags(1000, \"ttt\", true) values(1626006833603, 4, 3, 'hwj') ct1 using st1(t1) tags(2000) values(now+5s, 23, 32, 's21ds')");
if (taos_errno(pRes) != 0) {
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
return 0;
}
int32_t init_env() {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
if (pConn == NULL) {
return -1;
}
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx");
if (taos_errno(pRes) != 0) {
printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create database if not exists db_taosx vgroups 1 wal_retention_period 3600");
if (taos_errno(pRes) != 0) {
printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "drop topic if exists topic_db");
if (taos_errno(pRes) != 0) {
printf("error in drop topic, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "drop database if exists abc1");
if (taos_errno(pRes) != 0) {
printf("error in drop db, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1 wal_retention_period 3600");
if (taos_errno(pRes) != 0) {
printf("error in create db, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("error in use db, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
buildDatabase(pConn, pRes);
taos_close(pConn);
return 0;
}
int32_t create_topic() {
printf("create topic\n");
TAOS_RES* pRes;
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
if (pConn == NULL) {
return -1;
}
pRes = taos_query(pConn, "create topic topic_db with meta as database abc1");
if (taos_errno(pRes) != 0) {
printf("failed to create topic topic_db, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
taos_close(pConn);
return 0;
}
void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
printf("commit %d tmq %p param %p\n", code, tmq, param);
}
tmq_t* build_consumer() {
tmq_conf_t* conf = tmq_conf_new();
tmq_conf_set(conf, "group.id", "tg2");
tmq_conf_set(conf, "client.id", "my app 1");
tmq_conf_set(conf, "td.connect.user", "root");
tmq_conf_set(conf, "td.connect.pass", "taosdata");
tmq_conf_set(conf, "msg.with.table.name", "true");
tmq_conf_set(conf, "enable.auto.commit", "true");
tmq_conf_set(conf, "auto.offset.reset", "earliest");
tmq_conf_set(conf, "msg.consume.excluded", "1");
// tmq_conf_set(conf, "max.poll.interval.ms", "20000");
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
assert(tmq);
tmq_conf_destroy(conf);
return tmq;
}
tmq_list_t* build_topic_list() {
tmq_list_t* topic_list = tmq_list_new();
tmq_list_append(topic_list, "topic_db");
return topic_list;
}
void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
int32_t code;
if ((code = tmq_subscribe(tmq, topics))) {
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
printf("subscribe err\n");
return;
}
int32_t cnt = 0;
while (1) {
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 5000);
if (tmqmessage) {
cnt++;
msg_process(tmqmessage);
taos_free_result(tmqmessage);
} else {
break;
}
}
code = tmq_consumer_close(tmq);
if (code)
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
else
fprintf(stderr, "%% Consumer closed\n");
}
int main(int argc, char* argv[]) {
if (init_env() < 0) {
return -1;
}
create_topic();
tmq_t* tmq = build_consumer();
tmq_list_t* topic_list = build_topic_list();
basic_consume_loop(tmq, topic_list);
tmq_list_destroy(topic_list);
}