Merge branches '3.0' and 'fix/TD-32265' of https://github.com/taosdata/TDengine into fix/TD-32265
This commit is contained in:
commit
72bd34a6b2
|
@ -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);
|
||||
|
||||
end:
|
||||
uDebug("create stable return, sql json:%s", cJSON_PrintUnformatted(*pJson));
|
||||
uDebug("create stable return");
|
||||
tDecoderClear(&coder);
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ static void processAlterStb(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
buildAlterSTableJson(req.alterOriData, req.alterOriDataLen, pJson);
|
||||
|
||||
end:
|
||||
uDebug("alter stable return, sql json:%s", cJSON_PrintUnformatted(*pJson));
|
||||
uDebug("alter stable return");
|
||||
tDecoderClear(&coder);
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
int64_t id = pCreateReq->uid;
|
||||
uint8_t tagNum = pCreateReq->ctb.tagNum;
|
||||
int32_t code = 0;
|
||||
|
||||
cJSON* tags = NULL;
|
||||
cJSON* tableName = cJSON_CreateString(name);
|
||||
RAW_NULL_CHECK(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_FALSE_CHECK(cJSON_AddItemToObject(json, "tagNum", tagNumJson));
|
||||
|
||||
cJSON* tags = cJSON_CreateArray();
|
||||
tags = cJSON_CreateArray();
|
||||
RAW_NULL_CHECK(tags);
|
||||
SArray* pTagVals = NULL;
|
||||
RAW_RETURN_CHECK(tTagToValArray(pTag, &pTagVals));
|
||||
|
@ -543,7 +543,7 @@ static void processCreateTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
}
|
||||
|
||||
end:
|
||||
uDebug("create table return, sql json:%s", cJSON_PrintUnformatted(*pJson));
|
||||
uDebug("create table return");
|
||||
tDeleteSVCreateTbBatchReq(&req);
|
||||
tDecoderClear(&decoder);
|
||||
}
|
||||
|
@ -772,7 +772,7 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
}
|
||||
|
||||
end:
|
||||
uDebug("alter table return, sql json:%s", cJSON_PrintUnformatted(json));
|
||||
uDebug("alter table return");
|
||||
tDecoderClear(&decoder);
|
||||
*pJson = json;
|
||||
}
|
||||
|
@ -807,7 +807,7 @@ static void processDropSTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableName", tableName));
|
||||
|
||||
end:
|
||||
uDebug("processDropSTable return, sql json:%s", cJSON_PrintUnformatted(json));
|
||||
uDebug("processDropSTable return");
|
||||
tDecoderClear(&decoder);
|
||||
*pJson = json;
|
||||
}
|
||||
|
@ -843,7 +843,7 @@ static void processDeleteTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", sqlJson));
|
||||
|
||||
end:
|
||||
uDebug("processDeleteTable return, sql json:%s", cJSON_PrintUnformatted(json));
|
||||
uDebug("processDeleteTable return");
|
||||
tDecoderClear(&coder);
|
||||
*pJson = json;
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ static void processDropTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
RAW_FALSE_CHECK(cJSON_AddItemToObject(json, "tableNameList", tableNameList));
|
||||
|
||||
end:
|
||||
uDebug("processDropTable return, json sql:%s", cJSON_PrintUnformatted(json));
|
||||
uDebug("processDropTable return");
|
||||
tDecoderClear(&decoder);
|
||||
*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);
|
||||
taosMemoryFree(fields);
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
if (pCreateReqDst) {
|
||||
tdDestroySVCreateTbReq(pCreateReqDst);
|
||||
taosMemoryFreeClear(pCreateReqDst);
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
SET_ERROR_MSG("table:%s, err:%s", tbName, err);
|
||||
goto end;
|
||||
|
@ -1944,7 +1948,7 @@ end:
|
|||
taosMemoryFreeClear(pTableMeta);
|
||||
if (pCreateReqDst) {
|
||||
tdDestroySVCreateTbReq(pCreateReqDst);
|
||||
taosMemoryFree(pCreateReqDst);
|
||||
taosMemoryFreeClear(pCreateReqDst);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -2038,6 +2042,7 @@ char* tmq_get_json_meta(TAOS_RES* res) {
|
|||
processSimpleMeta(&pMetaRspObj->metaRsp, &pJson);
|
||||
char* string = cJSON_PrintUnformatted(pJson);
|
||||
cJSON_Delete(pJson);
|
||||
uDebug("tmq_get_json_meta string:%s", string);
|
||||
return string;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,6 +164,9 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
|||
if (argc < 2) return 0;
|
||||
|
||||
global.envCmd = taosMemoryMalloc((argc - 1) * sizeof(char *));
|
||||
if (global.envCmd == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
memset(global.envCmd, 0, (argc - 1) * sizeof(char *));
|
||||
for (int32_t i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "-c") == 0) {
|
||||
|
|
|
@ -150,6 +150,10 @@ int32_t dmReadEps(SDnodeData *pData) {
|
|||
}
|
||||
|
||||
char *tmp = taosMemoryMalloc(scopeLen + 1);
|
||||
if (tmp == NULL) {
|
||||
dError("failed to malloc memory for tsEncryptScope:%s", tsEncryptScope);
|
||||
goto _OVER;
|
||||
}
|
||||
memset(tmp, 0, scopeLen + 1);
|
||||
memcpy(tmp, tsEncryptScope, scopeLen);
|
||||
|
||||
|
|
|
@ -342,6 +342,11 @@ static int32_t dmCompareEncryptKey(char *file, char *key, bool toLogFile) {
|
|||
|
||||
int len = ENCRYPTED_LEN(size);
|
||||
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};
|
||||
strncpy(opts.key, key, ENCRYPT_KEY_LEN);
|
||||
|
|
|
@ -137,7 +137,7 @@ NextTbl:
|
|||
memcpy(pVal, tVal, tLen);
|
||||
vLen = tLen;
|
||||
}
|
||||
(void)tdbTbcMoveToNext(pReader->pCur);
|
||||
TAOS_UNUSED(tdbTbcMoveToNext(pReader->pCur));
|
||||
break;
|
||||
}
|
||||
if (except == 1) {
|
||||
|
@ -147,7 +147,7 @@ NextTbl:
|
|||
pReader->pos += 1;
|
||||
pPair = taosArrayGet(pReader->tdbTbList, pReader->pos);
|
||||
code = tdbTbcOpen(pPair->tbl, &pReader->pCur, NULL);
|
||||
(void)tdbTbcMoveToFirst(pReader->pCur);
|
||||
TAOS_UNUSED(tdbTbcMoveToFirst(pReader->pCur));
|
||||
|
||||
goto NextTbl;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback, i
|
|||
streamMetaWLock(pTq->pStreamMeta);
|
||||
tqDebug("vgId:%d, vnode stream-task snapshot writer closed", TD_VID(pTq->pVnode));
|
||||
if (rollback) {
|
||||
tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
|
||||
TAOS_UNUSED(tdbAbort(pTq->pStreamMeta->db, pTq->pStreamMeta->txn));
|
||||
} else {
|
||||
code = tdbCommit(pTq->pStreamMeta->db, pTq->pStreamMeta->txn);
|
||||
if (code) goto _err;
|
||||
|
|
|
@ -3179,7 +3179,7 @@ static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pI
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -299,7 +299,7 @@ static int32_t filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader, bo
|
|||
|
||||
pReader->status.pLDataIterArray = taosArrayInit(4, POINTER_BYTES);
|
||||
if (pReader->status.pLDataIterArray == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
// 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;
|
||||
if (idstr != NULL && pReader->idStr == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
|
@ -2918,7 +2918,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, int32_t orde
|
|||
} else {
|
||||
void* p1 = taosArrayAddAll(pSource, pBlockScanInfo->pMemDelData);
|
||||
if (p1 == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1461,7 +1461,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalo
|
|||
pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES);
|
||||
if (NULL == pRsp->pTableMeta) {
|
||||
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) {
|
||||
|
@ -1476,7 +1476,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalo
|
|||
if (NULL == taosArrayPush(pRsp->pTableMeta, &pTableMeta)) {
|
||||
ctgError("taosArrayPush failed, idx:%d", i);
|
||||
taosMemoryFreeClear(pTableMeta);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
|
|||
taosArrayRemove(pExchangeInfo->pResultBlockList, 0);
|
||||
void* tmp = taosArrayPush(pExchangeInfo->pRecycledBlocks, &p);
|
||||
if (!tmp) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
pTaskInfo->code = code;
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
|
@ -590,7 +590,7 @@ int32_t buildTableScanOperatorParam(SOperatorParam** ppRes, SArray* pUidList, in
|
|||
if (NULL == pScan->pUidList) {
|
||||
taosMemoryFree(pScan);
|
||||
taosMemoryFreeClear(*ppRes);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
pScan->tableSeq = tableSeq;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ int32_t doCreateTask(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC
|
|||
p->schemaInfos = taosArrayInit(1, sizeof(SSchemaInfo));
|
||||
if (p->id.str == NULL || p->schemaInfos == NULL) {
|
||||
doDestroyTask(p);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*pTaskInfo = p;
|
||||
|
|
|
@ -80,6 +80,10 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe
|
|||
IndexCache* pCache = mem->pCache;
|
||||
|
||||
CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm));
|
||||
if (pCt == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCt->colVal = term->colVal;
|
||||
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;
|
||||
|
||||
CacheTerm* pCt = taosMemoryCalloc(1, sizeof(CacheTerm));
|
||||
if (pCt == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCt->colVal = term->colVal;
|
||||
pCt->version = atomic_load_64(&pCache->version);
|
||||
|
||||
|
@ -539,6 +547,10 @@ int idxCacheSchedToMerge(IndexCache* pCache, bool notify) {
|
|||
schedMsg.ahandle = pCache;
|
||||
if (notify) {
|
||||
schedMsg.thandle = taosMemoryMalloc(1);
|
||||
if (schedMsg.thandle == NULL) {
|
||||
indexError("fail to schedule merge task");
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
schedMsg.msg = NULL;
|
||||
idxAcquireRef(pCache->index->refId);
|
||||
|
|
|
@ -260,7 +260,10 @@ char* idxPackJsonData(SIndexTerm* itm) {
|
|||
|
||||
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
|
||||
char* buf = (char*)taosMemoryCalloc(1, sz);
|
||||
char* p = buf;
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
char* p = buf;
|
||||
|
||||
memcpy(p, itm->colName, itm->nColName);
|
||||
p += itm->nColName;
|
||||
|
@ -288,7 +291,10 @@ char* idxPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip) {
|
|||
|
||||
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
|
||||
char* buf = (char*)taosMemoryCalloc(1, sz);
|
||||
char* p = buf;
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
char* p = buf;
|
||||
|
||||
memcpy(p, itm->colName, itm->nColName);
|
||||
p += itm->nColName;
|
||||
|
@ -315,7 +321,11 @@ char* idxPackJsonDataPrefixNoType(SIndexTerm* itm, int32_t* skip) {
|
|||
|
||||
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
|
||||
char* buf = (char*)taosMemoryCalloc(1, sz);
|
||||
char* p = buf;
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* p = buf;
|
||||
|
||||
memcpy(p, itm->colName, itm->nColName);
|
||||
p += itm->nColName;
|
||||
|
|
|
@ -57,9 +57,17 @@ void fstUnFinishedNodesDestroy(FstUnFinishedNodes* nodes) {
|
|||
|
||||
void fstUnFinishedNodesPushEmpty(FstUnFinishedNodes* nodes, bool isFinal) {
|
||||
FstBuilderNode* node = taosMemoryMalloc(sizeof(FstBuilderNode));
|
||||
if (node == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
node->isFinal = isFinal;
|
||||
node->finalOutput = 0;
|
||||
node->trans = taosArrayInit(16, sizeof(FstTransition));
|
||||
if (node->trans == NULL) {
|
||||
taosMemoryFree(node);
|
||||
return;
|
||||
}
|
||||
|
||||
FstBuilderNodeUnfinished un = {.node = node, .last = 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++) {
|
||||
FstBuilderNode* n = taosMemoryMalloc(sizeof(FstBuilderNode));
|
||||
if (n == NULL) {
|
||||
return;
|
||||
}
|
||||
n->isFinal = false;
|
||||
n->finalOutput = 0;
|
||||
n->trans = taosArrayInit(16, sizeof(FstTransition));
|
||||
|
@ -295,6 +306,9 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode
|
|||
if (sz > TRANS_INDEX_THRESHOLD) {
|
||||
// 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);
|
||||
if (index == NULL) {
|
||||
return;
|
||||
}
|
||||
memset(index, 255, sizeof(uint8_t) * 256);
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
FstTransition* t = taosArrayGet(node->trans, i);
|
||||
|
@ -973,6 +987,10 @@ Fst* fstCreate(FstSlice* slice) {
|
|||
fst->meta->checkSum = checkSum;
|
||||
|
||||
FstSlice* s = taosMemoryCalloc(1, sizeof(FstSlice));
|
||||
if (s == NULL) {
|
||||
goto FST_CREAT_FAILED;
|
||||
}
|
||||
|
||||
*s = fstSliceCopy(slice, 0, FST_SLICE_LEN(slice) - 1);
|
||||
fst->data = s;
|
||||
|
||||
|
@ -1326,6 +1344,9 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) {
|
|||
|
||||
int32_t isz = taosArrayGetSize(sws->inp);
|
||||
uint8_t* buf = (uint8_t*)taosMemoryMalloc(isz * sizeof(uint8_t));
|
||||
if (buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (uint32_t i = 0; i < isz; i++) {
|
||||
buf[i] = *(uint8_t*)taosArrayGet(sws->inp, i);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,11 @@ StartWithStateValue* startWithStateValueCreate(StartWithStateKind kind, ValueTyp
|
|||
} else if (ty == FST_CHAR) {
|
||||
size_t len = strlen((char*)val);
|
||||
sv->ptr = (char*)taosMemoryCalloc(1, len + 1);
|
||||
if (sv->ptr == NULL) {
|
||||
taosMemoryFree(sv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(sv->ptr, val, len);
|
||||
} else if (ty == FST_ARRAY) {
|
||||
// TODO,
|
||||
|
@ -63,6 +68,11 @@ StartWithStateValue* startWithStateValueDump(StartWithStateValue* sv) {
|
|||
} else if (nsv->type == FST_CHAR) {
|
||||
size_t len = strlen(sv->ptr);
|
||||
nsv->ptr = (char*)taosMemoryCalloc(1, len + 1);
|
||||
if (nsv->ptr == NULL) {
|
||||
taosMemoryFree(nsv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(nsv->ptr, sv->ptr, len);
|
||||
} else if (nsv->type == FST_ARRAY) {
|
||||
//
|
||||
|
|
|
@ -134,6 +134,9 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
|
|||
int32_t cacheMemSize = sizeof(SDataBlock) + kBlockSize;
|
||||
|
||||
SDataBlock* blk = taosMemoryCalloc(1, cacheMemSize);
|
||||
if (blk == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
blk->blockId = blkId;
|
||||
blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize);
|
||||
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.wBufCap = kBlockSize * 4;
|
||||
ctx->file.wBuf = taosMemoryCalloc(1, ctx->file.wBufCap);
|
||||
if (ctx->file.wBuf == NULL) {
|
||||
indexError("failed to allocate memory for write buffer");
|
||||
goto END;
|
||||
}
|
||||
} else {
|
||||
ctx->file.pFile = taosOpenFile(path, TD_FILE_READ);
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -325,6 +337,10 @@ int idxFileFlush(IdxFstFile* write) {
|
|||
|
||||
void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) {
|
||||
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++) {
|
||||
buf[i] = (uint8_t)n;
|
||||
n = n >> 8;
|
||||
|
|
|
@ -80,6 +80,10 @@ FstSlice fstSliceCreate(uint8_t* data, uint64_t len) {
|
|||
str->ref = 1;
|
||||
str->len = len;
|
||||
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) {
|
||||
memcpy(str->data, data, len);
|
||||
|
|
|
@ -799,6 +799,10 @@ static bool tfileIteratorNext(Iterate* iiter) {
|
|||
int32_t sz = 0;
|
||||
char* ch = (char*)fstSliceData(&rt->data, &sz);
|
||||
colVal = taosMemoryCalloc(1, sz + 1);
|
||||
if (colVal == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(colVal, ch, sz);
|
||||
|
||||
offset = (uint64_t)(rt->out.out);
|
||||
|
@ -835,6 +839,10 @@ Iterate* tfileIteratorCreate(TFileReader* reader) {
|
|||
}
|
||||
|
||||
Iterate* iter = taosMemoryCalloc(1, sizeof(Iterate));
|
||||
if (iter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iter->iter = tfileFstIteratorCreate(reader);
|
||||
if (iter->iter == NULL) {
|
||||
taosMemoryFree(iter);
|
||||
|
@ -843,6 +851,11 @@ Iterate* tfileIteratorCreate(TFileReader* reader) {
|
|||
iter->next = tfileIteratorNext;
|
||||
iter->getValue = tifileIterateGetValue;
|
||||
iter->val.val = taosArrayInit(1, sizeof(uint64_t));
|
||||
if (iter->val.val == NULL) {
|
||||
tfileIteratorDestroy(iter);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iter->val.colVal = NULL;
|
||||
return iter;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,10 @@ int32_t iUnion(SArray *in, SArray *out) {
|
|||
}
|
||||
|
||||
MergeIndex *mi = taosMemoryCalloc(sz, sizeof(MergeIndex));
|
||||
if (mi == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
SArray *t = taosArrayGetP(in, i);
|
||||
mi[i].len = (int32_t)taosArrayGetSize(t);
|
||||
|
|
|
@ -46,7 +46,7 @@ int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData) {
|
|||
}
|
||||
pNew->aCol = taosArrayDup(pDataBlock->pData->aCol, NULL);
|
||||
if (!pNew->aCol) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
taosMemoryFreeClear(*pData);
|
||||
return code;
|
||||
}
|
||||
|
@ -951,7 +951,7 @@ int32_t qResetStmtColumns(SArray* pCols, bool deepClear) {
|
|||
SColData* pCol = (SColData*)taosArrayGet(pCols, i);
|
||||
if (pCol == NULL) {
|
||||
qError("qResetStmtColumns column is NULL");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (deepClear) {
|
||||
tColDataDeepClear(pCol);
|
||||
|
@ -971,7 +971,7 @@ int32_t qResetStmtDataBlock(STableDataCxt* block, bool deepClear) {
|
|||
SColData* pCol = (SColData*)taosArrayGet(pBlock->pData->aCol, i);
|
||||
if (pCol == NULL) {
|
||||
qError("qResetStmtDataBlock column is NULL");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
if (deepClear) {
|
||||
tColDataDeepClear(pCol);
|
||||
|
@ -1033,7 +1033,7 @@ int32_t qCloneStmtDataBlock(STableDataCxt** pDst, STableDataCxt* pSrc, bool rese
|
|||
pNewTb->aCol = taosArrayDup(pCxt->pData->aCol, NULL);
|
||||
if (NULL == pNewTb->aCol) {
|
||||
insDestroyTableDataCxt(*pDst);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pNewCxt->pData = pNewTb;
|
||||
|
|
|
@ -856,7 +856,7 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList,
|
|||
code = buildSubmitReq(src->vgId, src->pData, &dst->pData, &dst->size);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ static int32_t rewriteDropTableWithMetaCache(STranslateContext* pCxt) {
|
|||
if (!pMetaCache->pTableMeta &&
|
||||
!(pMetaCache->pTableMeta =
|
||||
taosHashInit(tbMetaExSize, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK))) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SMetaRes** ppMetaRes = NULL;
|
||||
|
@ -2087,7 +2087,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
|||
pVal->datum.p = taosMemoryCalloc(1, size + VARSTR_HEADER_SIZE);
|
||||
if (NULL == pVal->datum.p) {
|
||||
if (isHexChar) taosMemoryFree(data);
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||
return generateDealNodeErrMsg(pCxt, terrno);
|
||||
}
|
||||
varDataSetLen(pVal->datum.p, 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);
|
||||
pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1);
|
||||
if (NULL == pVal->datum.p) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||
return generateDealNodeErrMsg(pCxt, terrno);
|
||||
}
|
||||
varDataSetLen(pVal->datum.p, 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: {
|
||||
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
||||
if (NULL == pVal->datum.p) {
|
||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||
return generateDealNodeErrMsg(pCxt, terrno);
|
||||
}
|
||||
|
||||
int32_t len = 0;
|
||||
|
@ -6264,7 +6264,7 @@ static int32_t unionEqualCondTbnamesOfSameTable(SArray* aTableTbnames, SEqCondTb
|
|||
SEqCondTbNameTableInfo* info = taosArrayGet(aTableTbnames, i);
|
||||
if (info->pRealTable == pInfo->pRealTable) {
|
||||
if (NULL == taosArrayAddAll(info->aTbnames, pInfo->aTbnames)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
taosArrayDestroy(pInfo->aTbnames);
|
||||
|
|
|
@ -1124,7 +1124,7 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
|
|||
if (TSDB_CODE_SUCCESS == code && NULL != pVgList) {
|
||||
*pVgInfo = taosArrayDup(pVgList, NULL);
|
||||
if (NULL == *pVgInfo) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
|
@ -1439,7 +1439,7 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
|||
|
||||
*pDnodes = taosArrayDup((SArray*)pRes->pRes, NULL);
|
||||
if (NULL == *pDnodes) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ void cleanDir(const char* pPath, const char* id) {
|
|||
|
||||
if (taosIsDir(pPath)) {
|
||||
taosRemoveDir(pPath);
|
||||
(void)taosMkDir(pPath);
|
||||
TAOS_UNUSED(taosMkDir(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:
|
||||
if (code != 0) {
|
||||
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(dstName);
|
||||
(void)taosCloseDir(&pDir);
|
||||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
return code;
|
||||
|
||||
_ERROR:
|
||||
taosMemoryFreeClear(srcName);
|
||||
taosMemoryFreeClear(dstName);
|
||||
(void)taosCloseDir(&pDir);
|
||||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -833,9 +833,8 @@ int32_t streamBackendInit(const char* streamPath, int64_t chkpId, int32_t vgId,
|
|||
pHandle->list = tdListNew(sizeof(SCfComparator));
|
||||
TSDB_CHECK_NULL(pHandle->list, code, lino, _EXIT, terrno);
|
||||
|
||||
(void)taosThreadMutexInit(&pHandle->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pHandle->cfMutex, NULL);
|
||||
|
||||
TAOS_UNUSED(taosThreadMutexInit(&pHandle->mutex, NULL));
|
||||
TAOS_UNUSED(taosThreadMutexInit(&pHandle->cfMutex, NULL));
|
||||
pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
TSDB_CHECK_NULL(pHandle->cfInst, code, lino, _EXIT, terrno);
|
||||
|
||||
|
@ -948,11 +947,11 @@ void streamBackendCleanup(void* arg) {
|
|||
void streamBackendHandleCleanup(void* arg) {
|
||||
SBackendCfWrapper* wrapper = arg;
|
||||
bool remove = wrapper->remove;
|
||||
(void)taosThreadRwlockWrlock(&wrapper->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&wrapper->rwLock));
|
||||
|
||||
stDebug("start to do-close backendwrapper %p, %s", wrapper, wrapper->idstr);
|
||||
if (wrapper->rocksdb == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&wrapper->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&wrapper->rwLock));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1003,9 +1002,9 @@ void streamBackendHandleCleanup(void* arg) {
|
|||
wrapper->readOpts = NULL;
|
||||
taosMemoryFreeClear(wrapper->cfOpts);
|
||||
taosMemoryFreeClear(wrapper->param);
|
||||
(void)taosThreadRwlockUnlock(&wrapper->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&wrapper->rwLock));
|
||||
|
||||
(void)taosThreadRwlockDestroy(&wrapper->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockDestroy(&wrapper->rwLock));
|
||||
wrapper->rocksdb = NULL;
|
||||
// taosReleaseRef(streamBackendId, wrapper->backendId);
|
||||
|
||||
|
@ -1099,7 +1098,7 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
|
|||
int32_t code = 0;
|
||||
STaskDbWrapper* pBackend = arg;
|
||||
SArray * chkpDel = NULL, *chkpDup = NULL;
|
||||
(void)taosThreadRwlockWrlock(&pBackend->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&pBackend->chkpDirLock));
|
||||
|
||||
if (taosArrayPush(pBackend->chkpSaved, &chkpId) == NULL) {
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _exception);
|
||||
|
@ -1152,7 +1151,7 @@ int32_t chkpMayDelObsolete(void* arg, int64_t chkpId, char* path) {
|
|||
taosArrayDestroy(pBackend->chkpSaved);
|
||||
pBackend->chkpSaved = chkpDup;
|
||||
|
||||
(void)taosThreadRwlockUnlock(&pBackend->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&pBackend->chkpDirLock));
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(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:
|
||||
taosArrayDestroy(chkpDup);
|
||||
taosArrayDestroy(chkpDel);
|
||||
(void)taosThreadRwlockUnlock(&pBackend->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&pBackend->chkpDirLock));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1315,12 +1314,12 @@ int32_t taskDbLoadChkpInfo(STaskDbWrapper* pBackend) {
|
|||
taosArraySort(pBackend->chkpSaved, chkpIdComp);
|
||||
|
||||
taosMemoryFree(pChkpDir);
|
||||
(void)taosCloseDir(&pDir);
|
||||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
|
||||
return 0;
|
||||
_exception:
|
||||
taosMemoryFree(pChkpDir);
|
||||
(void)taosCloseDir(&pDir);
|
||||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
return code;
|
||||
}
|
||||
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) {
|
||||
// release
|
||||
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||
TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
|
||||
}
|
||||
|
||||
int64_t taskGetDBRef(void* arg) {
|
||||
|
@ -1622,7 +1621,7 @@ int32_t chkpLoadExtraInfo(char* pChkpIdDir, int64_t* chkpId, int64_t* processId)
|
|||
code = 0;
|
||||
_EXIT:
|
||||
taosMemoryFree(pDst);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pFile));
|
||||
return code;
|
||||
}
|
||||
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;
|
||||
|
||||
_EXIT:
|
||||
(void)taosCloseFile(&pFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pFile));
|
||||
taosMemoryFree(pDst);
|
||||
return code;
|
||||
}
|
||||
|
@ -1735,7 +1734,7 @@ int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId, int64_t processId) {
|
|||
goto _EXIT;
|
||||
}
|
||||
|
||||
(void)atomic_store_64(&pTaskDb->dataWritten, 0);
|
||||
TAOS_UNUSED(atomic_store_64(&pTaskDb->dataWritten, 0));
|
||||
pTaskDb->chkpId = chkpId;
|
||||
|
||||
_EXIT:
|
||||
|
@ -1743,13 +1742,13 @@ _EXIT:
|
|||
// clear checkpoint dir if failed
|
||||
if (code != 0 && pChkpDir != NULL) {
|
||||
if (taosDirExist(pChkpIdDir)) {
|
||||
(void)taosRemoveDir(pChkpIdDir);
|
||||
TAOS_UNUSED(taosRemoveDir(pChkpIdDir));
|
||||
}
|
||||
}
|
||||
taosMemoryFree(pChkpIdDir);
|
||||
taosMemoryFree(pChkpDir);
|
||||
|
||||
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||
TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
|
||||
taosMemoryFree(ppCf);
|
||||
return code;
|
||||
}
|
||||
|
@ -1822,7 +1821,7 @@ int defaultKeyComp(void* state, const char* aBuf, size_t aLen, const char* bBuf,
|
|||
}
|
||||
int streamStateValueIsStale(char* v) {
|
||||
int64_t ts = 0;
|
||||
(void)taosDecodeFixedI64(v, &ts);
|
||||
TAOS_UNUSED(taosDecodeFixedI64(v, &ts));
|
||||
return (ts != 0 && ts < taosGetTimestampMs()) ? 1 : 0;
|
||||
}
|
||||
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);
|
||||
p2 = taosDecodeFixedI64(p2, &key2.key.ts);
|
||||
|
||||
(void)taosDecodeFixedI64(p1, &key1.opNum);
|
||||
(void)taosDecodeFixedI64(p2, &key2.opNum);
|
||||
TAOS_UNUSED(taosDecodeFixedI64(p1, &key1.opNum));
|
||||
TAOS_UNUSED(taosDecodeFixedI64(p2, &key2.opNum));
|
||||
|
||||
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* p2 = (char*)bBuf;
|
||||
|
||||
(void)taosDecodeFixedI64(p1, &w1);
|
||||
(void)taosDecodeFixedI64(p2, &w2);
|
||||
TAOS_UNUSED(taosDecodeFixedI64(p1, &w1));
|
||||
TAOS_UNUSED(taosDecodeFixedI64(p2, &w2));
|
||||
if (w1 == w2) {
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -2107,7 +2106,7 @@ int32_t valueIsStale(void* k, int64_t ts) {
|
|||
}
|
||||
|
||||
void destroyCompare(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2190,7 +2189,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
|||
// compatiable with previous data
|
||||
p = taosDecodeBinary(p, (void**)&pOutput, key.len);
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXCEPT;
|
||||
}
|
||||
|
||||
|
@ -2205,7 +2204,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
|||
if (key.compress == 1) {
|
||||
p = taosDecodeBinary(p, (void**)&pCompressData, key.len);
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXCEPT;
|
||||
}
|
||||
pOutput = taosMemoryCalloc(1, key.rawLen);
|
||||
|
@ -2224,7 +2223,7 @@ int32_t valueDecode(void* value, int32_t vlen, int64_t* ttl, char** dest) {
|
|||
} else {
|
||||
p = taosDecodeBinary(p, (void**)&pOutput, key.len);
|
||||
if (p == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _EXCEPT;
|
||||
}
|
||||
}
|
||||
|
@ -2251,31 +2250,28 @@ _EXCEPT:
|
|||
}
|
||||
|
||||
const char* compareDefaultName(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return ginitDict[0].key;
|
||||
}
|
||||
const char* compareStateName(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return ginitDict[1].key;
|
||||
}
|
||||
const char* compareWinKeyName(void* arg) {
|
||||
(void)arg;
|
||||
return ginitDict[2].key;
|
||||
}
|
||||
const char* compareWinKeyName(void* arg) { return ginitDict[2].key; }
|
||||
const char* compareSessionKeyName(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return ginitDict[3].key;
|
||||
}
|
||||
const char* compareFuncKeyName(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return ginitDict[4].key;
|
||||
}
|
||||
const char* compareParKeyName(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return ginitDict[5].key;
|
||||
}
|
||||
const char* comparePartagKeyName(void* arg) {
|
||||
(void)arg;
|
||||
TAOS_UNUSED(arg);
|
||||
return ginitDict[6].key;
|
||||
}
|
||||
|
||||
|
@ -2303,7 +2299,7 @@ const char* compactFilteFactoryNameFunc(void* arg) {
|
|||
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,
|
||||
char** newval, size_t* newvlen, unsigned char* value_changed) {
|
||||
return streamStateValueIsStale((char*)val) ? 1 : 0;
|
||||
|
@ -2416,7 +2412,7 @@ void taskDbRemoveRef(void* pTaskDb) {
|
|||
}
|
||||
|
||||
STaskDbWrapper* pBackend = pTaskDb;
|
||||
(void)taosReleaseRef(taskDbWrapperId, pBackend->refId);
|
||||
TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, pBackend->refId));
|
||||
}
|
||||
|
||||
void taskDbSetClearFileFlag(void* pTaskDb) {
|
||||
|
@ -2491,24 +2487,24 @@ void taskDbInitChkpOpt(STaskDbWrapper* pTaskDb) {
|
|||
pTaskDb->chkpId = -1;
|
||||
pTaskDb->chkpCap = 4;
|
||||
pTaskDb->chkpSaved = taosArrayInit(4, sizeof(int64_t));
|
||||
(void)taskDbLoadChkpInfo(pTaskDb);
|
||||
TAOS_UNUSED(taskDbLoadChkpInfo(pTaskDb));
|
||||
|
||||
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)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&pTaskDb->chkpDirLock));
|
||||
if (taosArrayPush(pTaskDb->chkpInUse, &chkp) == NULL) {
|
||||
stError("failed to push chkp: %" PRIi64 " into inuse", chkp);
|
||||
}
|
||||
taosArraySort(pTaskDb->chkpInUse, chkpIdComp);
|
||||
(void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&pTaskDb->chkpDirLock));
|
||||
}
|
||||
|
||||
void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
||||
(void)taosThreadRwlockWrlock(&pTaskDb->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&pTaskDb->chkpDirLock));
|
||||
int32_t size = taosArrayGetSize(pTaskDb->chkpInUse);
|
||||
for (int i = 0; i < size; i++) {
|
||||
int64_t* p = taosArrayGet(pTaskDb->chkpInUse, i);
|
||||
|
@ -2517,13 +2513,13 @@ void taskDbUnRefChkp(STaskDbWrapper* pTaskDb, int64_t chkp) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
(void)taosThreadRwlockUnlock(&pTaskDb->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&pTaskDb->chkpDirLock));
|
||||
}
|
||||
|
||||
void taskDbDestroyChkpOpt(STaskDbWrapper* pTaskDb) {
|
||||
taosArrayDestroy(pTaskDb->chkpSaved);
|
||||
taosArrayDestroy(pTaskDb->chkpInUse);
|
||||
(void)taosThreadRwlockDestroy(&pTaskDb->chkpDirLock);
|
||||
TAOS_UNUSED(taosThreadRwlockDestroy(&pTaskDb->chkpDirLock));
|
||||
}
|
||||
|
||||
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) {
|
||||
STaskDbWrapper* p = pTaskDb;
|
||||
(void)streamMutexLock(&p->mutex);
|
||||
TAOS_UNUSED(streamMutexLock(&p->mutex));
|
||||
p->chkpId = chkpId;
|
||||
(void)streamMutexUnlock(&p->mutex);
|
||||
TAOS_UNUSED(streamMutexUnlock(&p->mutex));
|
||||
}
|
||||
|
||||
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->path = statePath ? taosStrdup(statePath) : NULL;
|
||||
|
||||
(void)taosThreadMutexInit(&pTaskDb->mutex, NULL);
|
||||
TAOS_UNUSED(taosThreadMutexInit(&pTaskDb->mutex, NULL));
|
||||
taskDbInitChkpOpt(pTaskDb);
|
||||
taskDbInitOpt(pTaskDb);
|
||||
|
||||
|
@ -2772,7 +2768,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
|
|||
|
||||
char* buf = taosMemoryCalloc(1, cap);
|
||||
if (buf == NULL) {
|
||||
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||
TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
|
||||
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);
|
||||
if (nBytes <= 0 || nBytes >= cap) {
|
||||
taosMemoryFree(buf);
|
||||
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||
TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
|
||||
return TSDB_CODE_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
|
@ -2791,7 +2787,7 @@ int32_t taskDbGenChkpUploadData__rsync(STaskDbWrapper* pDb, int64_t chkpId, char
|
|||
taosMemoryFree(buf);
|
||||
}
|
||||
|
||||
(void)taosReleaseRef(taskDbWrapperId, refId);
|
||||
TAOS_UNUSED(taosReleaseRef(taskDbWrapperId, refId));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3028,7 +3024,7 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t
|
|||
|
||||
inst->dbOpt = handle->dbOpt;
|
||||
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 {
|
||||
inst = *pInst;
|
||||
}
|
||||
|
@ -3269,9 +3265,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
|
|||
break; \
|
||||
} \
|
||||
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}; \
|
||||
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); \
|
||||
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
||||
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; \
|
||||
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); \
|
||||
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
||||
rocksdb_t* db = wrapper->db; \
|
||||
|
@ -3346,9 +3342,9 @@ rocksdb_iterator_t* streamStateIterCreate(SStreamState* pState, const char* cfKe
|
|||
break; \
|
||||
} \
|
||||
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}; \
|
||||
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); \
|
||||
rocksdb_column_family_handle_t* pHandle = ((rocksdb_column_family_handle_t**)wrapper->pCf)[ginitDict[i].idx]; \
|
||||
rocksdb_t* db = wrapper->db; \
|
||||
|
@ -3387,7 +3383,7 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) {
|
|||
stDebug("streamStateClear_rocksdb");
|
||||
|
||||
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 eKeyStr[128] = {0};
|
||||
|
@ -3403,8 +3399,8 @@ int32_t streamStateClear_rocksdb(SStreamState* pState) {
|
|||
if (err != NULL) {
|
||||
char toStringStart[128] = {0};
|
||||
char toStringEnd[128] = {0};
|
||||
(void)stateKeyToString(&sKey, toStringStart);
|
||||
(void)stateKeyToString(&eKey, toStringEnd);
|
||||
TAOS_UNUSED(stateKeyToString(&sKey, toStringStart));
|
||||
TAOS_UNUSED(stateKeyToString(&eKey, toStringEnd));
|
||||
|
||||
stWarn("failed to delete range cf(state) start: %s, end:%s, reason:%s", toStringStart, toStringEnd, err);
|
||||
taosMemoryFree(err);
|
||||
|
@ -3464,7 +3460,7 @@ int32_t streamStateAddIfNotExist_rocksdb(SStreamState* pState, const SWinKey* ke
|
|||
}
|
||||
*pVal = taosMemoryMalloc(size);
|
||||
if (*pVal == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
memset(*pVal, 0, size);
|
||||
return 0;
|
||||
|
@ -3482,7 +3478,7 @@ int32_t streamStateGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey, cons
|
|||
if (rocksdb_iter_valid(pCur->iter) && !iterValueIsStale(pCur->iter)) {
|
||||
size_t tlen;
|
||||
char* keyStr = (char*)rocksdb_iter_key(pCur->iter, &tlen);
|
||||
(void)stateKeyDecode((void*)pKtmp, keyStr);
|
||||
TAOS_UNUSED(stateKeyDecode((void*)pKtmp, keyStr));
|
||||
if (pKtmp->opNum != pCur->number) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -3535,7 +3531,7 @@ SStreamStateCur* streamStateSeekKeyNext_rocksdb(SStreamState* pState, const SWin
|
|||
SStateKey curKey;
|
||||
size_t 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) {
|
||||
return pCur;
|
||||
}
|
||||
|
@ -3557,7 +3553,7 @@ SStreamStateCur* streamStateSeekToLast_rocksdb(SStreamState* pState) {
|
|||
|
||||
{
|
||||
char tbuf[256] = {0};
|
||||
(void)stateKeyToString((void*)&maxStateKey, tbuf);
|
||||
TAOS_UNUSED(stateKeyToString((void*)&maxStateKey, tbuf));
|
||||
stDebug("seek to last:%s", tbuf);
|
||||
}
|
||||
|
||||
|
@ -3607,7 +3603,7 @@ SStreamStateCur* streamStateGetCur_rocksdb(SStreamState* pState, const SWinKey*
|
|||
SStateKey curKey;
|
||||
size_t kLen = 0;
|
||||
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) {
|
||||
pCur->number = pState->number;
|
||||
|
@ -3755,7 +3751,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pSta
|
|||
size_t klen;
|
||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||
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;
|
||||
|
||||
rocksdb_iter_prev(pCur->iter);
|
||||
|
@ -3792,7 +3788,7 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pSta
|
|||
size_t klen;
|
||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||
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;
|
||||
|
||||
rocksdb_iter_next(pCur->iter);
|
||||
|
@ -3832,7 +3828,7 @@ SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, con
|
|||
size_t klen;
|
||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||
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;
|
||||
|
||||
rocksdb_iter_next(pCur->iter);
|
||||
|
@ -3872,7 +3868,7 @@ SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, con
|
|||
size_t klen;
|
||||
const char* iKey = rocksdb_iter_key(pCur->iter, &klen);
|
||||
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;
|
||||
|
||||
rocksdb_iter_prev(pCur->iter);
|
||||
|
@ -3894,7 +3890,7 @@ int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey*
|
|||
return -1;
|
||||
}
|
||||
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 (pVLen != NULL) *pVLen = 0;
|
||||
|
@ -3973,7 +3969,7 @@ SStreamStateCur* streamStateFillGetCur_rocksdb(SStreamState* pState, const SWinK
|
|||
size_t kLen;
|
||||
SWinKey curKey;
|
||||
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) {
|
||||
return pCur;
|
||||
}
|
||||
|
@ -3992,7 +3988,7 @@ int32_t streamStateFillGetKVByCur_rocksdb(SStreamStateCur* pCur, SWinKey* pKey,
|
|||
}
|
||||
size_t klen, vlen;
|
||||
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);
|
||||
int32_t len = valueDecode((void*)valStr, vlen, NULL, (char**)pVal);
|
||||
|
@ -4033,7 +4029,7 @@ SStreamStateCur* streamStateFillSeekKeyNext_rocksdb(SStreamState* pState, const
|
|||
SWinKey curKey;
|
||||
size_t kLen = 0;
|
||||
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) {
|
||||
return pCur;
|
||||
}
|
||||
|
@ -4070,7 +4066,7 @@ SStreamStateCur* streamStateFillSeekKeyPrev_rocksdb(SStreamState* pState, const
|
|||
SWinKey curKey;
|
||||
size_t kLen = 0;
|
||||
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) {
|
||||
return pCur;
|
||||
}
|
||||
|
@ -4154,7 +4150,7 @@ int32_t streamStateSessionAddIfNotExist_rocksdb(SStreamState* pState, SSessionKe
|
|||
|
||||
void* tmp = taosMemoryMalloc(valSize);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SStreamStateCur* pCur = streamStateSessionSeekKeyCurrentPrev_rocksdb(pState, key);
|
||||
|
@ -4206,7 +4202,7 @@ void streamStateSessionClear_rocksdb(SStreamState* pState) {
|
|||
if (code == 0 && size > 0) {
|
||||
memset(buf, 0, size);
|
||||
// refactor later
|
||||
(void)streamStateSessionPut_rocksdb(pState, &delKey, buf, size);
|
||||
TAOS_UNUSED(streamStateSessionPut_rocksdb(pState, &delKey, buf, size));
|
||||
} else {
|
||||
taosMemoryFreeClear(buf);
|
||||
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,
|
||||
void* val, int32_t vlen, int64_t ttl) {
|
||||
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);
|
||||
if (i < 0) {
|
||||
|
@ -4439,7 +4435,7 @@ int32_t streamStatePutBatch(SStreamState* pState, const char* cfKeyName, rocksdb
|
|||
|
||||
{
|
||||
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);
|
||||
}
|
||||
return 0;
|
||||
|
@ -4454,7 +4450,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
|
|||
|
||||
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_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};
|
||||
(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);
|
||||
}
|
||||
return 0;
|
||||
|
@ -4473,7 +4469,7 @@ int32_t streamStatePutBatchOptimize(SStreamState* pState, int32_t cfIdx, rocksdb
|
|||
int32_t streamStatePutBatch_rocksdb(SStreamState* pState, void* pBatch) {
|
||||
char* err = NULL;
|
||||
STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend;
|
||||
(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);
|
||||
if (err != NULL) {
|
||||
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) {
|
||||
return terrno;
|
||||
}
|
||||
(void)strncpy(fname, name, len);
|
||||
TAOS_UNUSED(strncpy(fname, name, len));
|
||||
if (taosArrayPush(diff, &fname) == NULL) {
|
||||
taosMemoryFree(fname);
|
||||
return terrno;
|
||||
|
@ -4642,7 +4638,7 @@ void dbChkpDebugInfo(SDbChkp* pDb) {
|
|||
int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
||||
int32_t code = 0;
|
||||
int32_t nBytes;
|
||||
(void)taosThreadRwlockWrlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&p->rwLock));
|
||||
|
||||
p->preCkptId = p->curChkpId;
|
||||
p->curChkpId = chkpId;
|
||||
|
@ -4660,7 +4656,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
|||
nBytes =
|
||||
snprintf(p->buf, p->len, "%s%s%s%scheckpoint%" PRId64 "", p->path, TD_DIRSEP, "checkpoints", TD_DIRSEP, chkpId);
|
||||
if (nBytes <= 0 || nBytes >= p->len) {
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
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);
|
||||
if (pDir == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -4706,9 +4702,9 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
(void)taosCloseDir(&pDir);
|
||||
TAOS_UNUSED(taosCloseDir(&pDir));
|
||||
if (code != 0) {
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -4720,14 +4716,14 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
|||
if (name != NULL && !isBkdDataMeta(name, len)) {
|
||||
char* fname = taosMemoryCalloc(1, len + 1);
|
||||
if (fname == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(void)strncpy(fname, name, len);
|
||||
TAOS_UNUSED(strncpy(fname, name, len));
|
||||
if (taosArrayPush(p->pAdd, &fname) == NULL) {
|
||||
taosMemoryFree(fname);
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
@ -4761,7 +4757,7 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) {
|
|||
|
||||
p->idx = 1 - p->idx;
|
||||
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -4819,7 +4815,7 @@ int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) {
|
|||
}
|
||||
|
||||
p->update = 0;
|
||||
(void)taosThreadRwlockInit(&p->rwLock, NULL);
|
||||
TAOS_UNUSED(taosThreadRwlockInit(&p->rwLock, NULL));
|
||||
|
||||
SArray* list = NULL;
|
||||
code = dbChkpGetDelta(p, initChkpId, list);
|
||||
|
@ -4860,7 +4856,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
static char* chkpMeta = "META";
|
||||
int32_t code = 0;
|
||||
|
||||
(void)taosThreadRwlockRdlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockRdlock(&p->rwLock));
|
||||
|
||||
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)) {
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
stError("chkp failed to format meta file: %s, reason: invalid msg", dstDir);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pFile));
|
||||
goto _ERROR;
|
||||
}
|
||||
|
||||
|
@ -5011,10 +5007,10 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
if (nBytes != strlen(content)) {
|
||||
code = terrno;
|
||||
stError("chkp failed to write meta file: %s,reason:%s", dstDir, tstrerror(code));
|
||||
(void)taosCloseFile(&pFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pFile));
|
||||
goto _ERROR;
|
||||
}
|
||||
(void)taosCloseFile(&pFile);
|
||||
TAOS_UNUSED(taosCloseFile(&pFile));
|
||||
|
||||
// clear delta data buf
|
||||
taosArrayClearP(p->pAdd, taosMemoryFree);
|
||||
|
@ -5023,7 +5019,7 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
|
|||
|
||||
_ERROR:
|
||||
taosMemoryFree(buffer);
|
||||
(void)taosThreadRwlockUnlock(&p->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&p->rwLock));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -5068,7 +5064,7 @@ void bkdMgtDestroy(SBkdMgt* bm) {
|
|||
pIter = taosHashIterate(bm->pDbChkpTbl, pIter);
|
||||
}
|
||||
|
||||
(void)taosThreadRwlockDestroy(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockDestroy(&bm->rwLock));
|
||||
taosMemoryFree(bm->path);
|
||||
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 code = 0;
|
||||
(void)taosThreadRwlockWrlock(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockWrlock(&bm->rwLock));
|
||||
SDbChkp** ppChkp = taosHashGet(bm->pDbChkpTbl, taskId, strlen(taskId));
|
||||
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;
|
||||
char* path = taosMemoryCalloc(1, cap);
|
||||
if (path == NULL) {
|
||||
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
||||
return terrno;
|
||||
}
|
||||
|
||||
int32_t nBytes = snprintf(path, cap, "%s%s%s", bm->path, TD_DIRSEP, taskId);
|
||||
if (nBytes <= 0 || nBytes >= cap) {
|
||||
taosMemoryFree(path);
|
||||
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
||||
code = TSDB_CODE_OUT_OF_RANGE;
|
||||
return code;
|
||||
}
|
||||
|
@ -5100,20 +5096,20 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list,
|
|||
code = dbChkpCreate(path, chkpId, &p);
|
||||
if (code != 0) {
|
||||
taosMemoryFree(path);
|
||||
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
||||
return code;
|
||||
}
|
||||
|
||||
if (taosHashPut(bm->pDbChkpTbl, taskId, strlen(taskId), &p, sizeof(void*)) != 0) {
|
||||
dbChkpDestroy(p);
|
||||
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
pChkp = p;
|
||||
code = dbChkpDumpTo(pChkp, dname, list);
|
||||
(void)taosThreadRwlockUnlock(&bm->rwLock);
|
||||
TAOS_UNUSED(taosThreadRwlockUnlock(&bm->rwLock));
|
||||
return code;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6
|
|||
if (pChkpoint->blocks == NULL) {
|
||||
taosMemoryFree(pBlock);
|
||||
taosFreeQitem(pChkpoint);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
void* p = taosArrayPush(pChkpoint->blocks, pBlock);
|
||||
|
@ -70,7 +70,7 @@ int32_t createChkptTriggerBlock(SStreamTask* pTask, int32_t checkpointType, int6
|
|||
taosArrayDestroy(pChkpoint->blocks);
|
||||
taosMemoryFree(pBlock);
|
||||
taosFreeQitem(pChkpoint);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*pRes = pChkpoint;
|
||||
|
@ -740,7 +740,7 @@ int32_t uploadCheckpointData(SStreamTask* pTask, int64_t checkpointId, int64_t d
|
|||
|
||||
SArray* toDelFiles = taosArrayInit(4, POINTER_BYTES);
|
||||
if (toDelFiles == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
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));
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ int32_t streamMergedSubmitNew(SStreamMergedSubmit** pSubmit) {
|
|||
if ((*pSubmit)->submits == NULL) {
|
||||
taosFreeQitem(*pSubmit);
|
||||
*pSubmit = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(*pSubmit)->type = STREAM_INPUT__MERGED_SUBMIT;
|
||||
|
|
|
@ -73,7 +73,7 @@ static int32_t tInitStreamDispatchReq(SStreamDispatchReq* pReq, const SStreamTas
|
|||
if (pReq->data == NULL || pReq->dataLen == NULL) {
|
||||
taosArrayDestroyP(pReq->data, taosMemoryFree);
|
||||
taosArrayDestroy(pReq->dataLen);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -110,7 +110,7 @@ int32_t streamTaskBroadcastRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* r
|
|||
|
||||
buf = rpcMallocCont(sizeof(SMsgHead) + len);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId);
|
||||
|
@ -209,7 +209,7 @@ int32_t streamSendCheckMsg(SStreamTask* pTask, const SStreamTaskCheckReq* pReq,
|
|||
|
||||
buf = rpcMallocCont(sizeof(SMsgHead) + tlen);
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
((SMsgHead*)buf)->vgId = htonl(nodeId);
|
||||
|
|
|
@ -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
|
||||
|
||||
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
|
||||
|
|
|
@ -236,7 +236,7 @@ static FORCE_INLINE int32_t taosBuildDstAddr(const char* server, uint16_t port,
|
|||
static void* httpThread(void* arg) {
|
||||
SHttpModule* http = (SHttpModule*)arg;
|
||||
setThreadName("http-cli-send-thread");
|
||||
(void)uv_run(http->loop, UV_RUN_DEFAULT);
|
||||
TAOS_UNUSED(uv_run(http->loop, UV_RUN_DEFAULT));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ static void httpAsyncCb(uv_async_t* handle) {
|
|||
static int32_t BATCH_SIZE = 20;
|
||||
int32_t count = 0;
|
||||
|
||||
(void)taosThreadMutexLock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
|
||||
httpMayDiscardMsg(http, item);
|
||||
|
||||
while (!QUEUE_IS_EMPTY(&item->qmsg) && count++ < BATCH_SIZE) {
|
||||
|
@ -360,7 +360,7 @@ static void httpAsyncCb(uv_async_t* handle) {
|
|||
QUEUE_REMOVE(h);
|
||||
QUEUE_PUSH(&wq, h);
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
|
||||
|
||||
httpTrace(&wq);
|
||||
|
||||
|
@ -393,7 +393,7 @@ static FORCE_INLINE void clientCloseCb(uv_handle_t* handle) {
|
|||
SHttpModule* http = taosAcquireRef(httpRefMgt, cli->chanId);
|
||||
if (http != NULL) {
|
||||
http->connNum -= 1;
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
}
|
||||
|
||||
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)) {
|
||||
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
|
||||
}
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
}
|
||||
|
||||
int32_t httpSendQuit(SHttpModule* http, int64_t chanId) {
|
||||
|
@ -514,7 +514,7 @@ static void httpHandleQuit(SHttpMsg* msg) {
|
|||
SHttpModule* http = taosAcquireRef(httpRefMgt, chanId);
|
||||
if (http == NULL) return;
|
||||
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) {
|
||||
|
@ -536,11 +536,11 @@ static bool httpFailFastShoudIgnoreMsg(SHashObj* pTable, char* server, int16_t p
|
|||
}
|
||||
static void httpFailFastMayUpdate(SHashObj* pTable, char* server, int16_t port, int8_t succ) {
|
||||
int32_t code = 0;
|
||||
char buf[256] = {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "%s:%d", server, port);
|
||||
|
||||
if (succ) {
|
||||
(void)taosHashRemove(pTable, buf, strlen(buf));
|
||||
TAOS_UNUSED(taosHashRemove(pTable, buf, strlen(buf)));
|
||||
} else {
|
||||
int32_t st = taosGetTimestampSec();
|
||||
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,
|
||||
cli->port, chanId, cli->seq, tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||
destroyHttpClient(cli);
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
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",
|
||||
cli->addr, cli->port, chanId, cli->seq, uv_strerror(err));
|
||||
destroyHttpClient(cli);
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
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,
|
||||
cli->port, chanId, cli->seq, tstrerror(terrno));
|
||||
destroyHttpClient(cli);
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -657,7 +657,7 @@ static void httpHandleReq(SHttpMsg* msg) {
|
|||
cli->port, chanId, cli->seq, uv_strerror(ret));
|
||||
|
||||
destroyHttpClient(cli);
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -668,7 +668,7 @@ static void httpHandleReq(SHttpMsg* msg) {
|
|||
httpFailFastMayUpdate(http->connStatusTable, cli->addr, cli->port, 0);
|
||||
destroyHttpClient(cli);
|
||||
}
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
return;
|
||||
|
||||
END:
|
||||
|
@ -678,7 +678,7 @@ END:
|
|||
}
|
||||
httpDestroyMsg(msg);
|
||||
taosMemoryFree(header);
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
}
|
||||
|
||||
static void httpModuleDestroy(SHttpModule* http) {
|
||||
|
@ -689,7 +689,7 @@ static void httpModuleDestroy(SHttpModule* http) {
|
|||
transAsyncPoolDestroy(http->asyncPool);
|
||||
}
|
||||
if (http->loop) {
|
||||
(void)uv_loop_close(http->loop);
|
||||
TAOS_UNUSED(uv_loop_close(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,
|
||||
EHttpCompFlag flag, const char* qid) {
|
||||
(void)taosThreadOnce(&transHttpInit, transHttpEnvInit);
|
||||
TAOS_UNUSED(taosThreadOnce(&transHttpInit, transHttpEnvInit));
|
||||
return taosSendHttpReportImplByChan(server, uri, port, pCont, contLen, flag, httpDefaultChanId, qid);
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ _ERROR:
|
|||
return code;
|
||||
}
|
||||
int64_t taosInitHttpChan() {
|
||||
(void)taosThreadOnce(&transHttpInit, transHttpEnvInit);
|
||||
TAOS_UNUSED(taosThreadOnce(&transHttpInit, transHttpEnvInit));
|
||||
return transInitHttpChanImpl();
|
||||
}
|
||||
|
||||
|
@ -844,14 +844,14 @@ void taosDestroyHttpChan(int64_t chanId) {
|
|||
ret = httpSendQuit(load, chanId);
|
||||
if (ret != 0) {
|
||||
tDebug("http-report already destroyed, chanId %" PRId64 ",reason:%s", chanId, tstrerror(ret));
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
return;
|
||||
}
|
||||
|
||||
(void)taosThreadJoin(load->thread, NULL);
|
||||
TAOS_UNUSED(taosThreadJoin(load->thread, NULL));
|
||||
|
||||
httpModuleDestroy(load);
|
||||
|
||||
(void)taosReleaseRef(httpRefMgt, chanId);
|
||||
(void)taosRemoveRef(httpRefMgt, chanId);
|
||||
TAOS_UNUSED(taosReleaseRef(httpRefMgt, chanId));
|
||||
TAOS_UNUSED(taosRemoveRef(httpRefMgt, chanId));
|
||||
}
|
||||
|
|
|
@ -233,11 +233,11 @@ static void destroyThrdObj(SCliThrd* pThrd);
|
|||
int32_t cliSendQuit(SCliThrd* thrd);
|
||||
static void cliWalkCb(uv_handle_t* handle, void* arg);
|
||||
|
||||
#define CLI_RELEASE_UV(loop) \
|
||||
do { \
|
||||
(void)uv_walk(loop, cliWalkCb, NULL); \
|
||||
(void)uv_run(loop, UV_RUN_DEFAULT); \
|
||||
(void)uv_loop_close(loop); \
|
||||
#define CLI_RELEASE_UV(loop) \
|
||||
do { \
|
||||
TAOS_UNUSED(uv_walk(loop, cliWalkCb, NULL)); \
|
||||
TAOS_UNUSED(uv_run(loop, UV_RUN_DEFAULT)); \
|
||||
TAOS_UNUSED(uv_loop_close(loop)); \
|
||||
} while (0);
|
||||
|
||||
// snprintf may cause performance problem
|
||||
|
@ -247,7 +247,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
|
|||
int16_t len = strlen(ip); \
|
||||
if (ip != NULL) memcpy(t, ip, len); \
|
||||
t[len] = ':'; \
|
||||
(void)titoa(port, 10, &t[len + 1]); \
|
||||
TAOS_UNUSED(titoa(port, 10, &t[len + 1])); \
|
||||
} while (0)
|
||||
|
||||
#define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para))
|
||||
|
@ -336,7 +336,7 @@ void cliResetTimer(SCliThrd* pThrd, SCliConn* conn) {
|
|||
if (conn->timer) {
|
||||
if (uv_is_active((uv_handle_t*)conn->timer)) {
|
||||
tDebug("%s conn %p stop timer", CONN_GET_INST_LABEL(conn), conn);
|
||||
(void)uv_timer_stop(conn->timer);
|
||||
TAOS_UNUSED(uv_timer_stop(conn->timer));
|
||||
}
|
||||
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));
|
||||
|
@ -375,15 +375,15 @@ bool cliConnSendSeqMsg(int64_t refId, SCliConn* conn) {
|
|||
taosWUnLockLatch(&exh->latch);
|
||||
SCliMsg* t = QUEUE_DATA(h, SCliMsg, seqq);
|
||||
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);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
cliSend(conn);
|
||||
return true;
|
||||
}
|
||||
taosWUnLockLatch(&exh->latch);
|
||||
tDebug("empty conn %p, refId: %" PRId64 "", conn, refId);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,7 @@ void cliHandleResp(SCliConn* 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) {
|
||||
if (refId == 0) return;
|
||||
|
@ -510,7 +510,7 @@ static void cliDestroyMsgInExhandle(int64_t refId) {
|
|||
destroyCmsg(t);
|
||||
}
|
||||
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));
|
||||
|
||||
(void)uv_timer_stop(handle);
|
||||
TAOS_UNUSED(uv_timer_stop(handle));
|
||||
handle->data = NULL;
|
||||
|
||||
cliResetTimer(pThrd, conn);
|
||||
|
@ -610,7 +610,7 @@ void cliReadTimeoutCb(uv_timer_t* handle) {
|
|||
// set up timeout cb
|
||||
SCliConn* conn = handle->data;
|
||||
tTrace("%s conn %p timeout, ref:%d", CONN_GET_INST_LABEL(conn), conn, T_REF_VAL_GET(conn));
|
||||
(void)uv_read_stop(conn->stream);
|
||||
TAOS_UNUSED(uv_read_stop(conn->stream));
|
||||
cliHandleExceptImpl(conn, TSDB_CODE_RPC_TIMEOUT);
|
||||
}
|
||||
|
||||
|
@ -847,7 +847,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
|
|||
pMsg->ctx->task = NULL;
|
||||
|
||||
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
|
||||
(void)transQueuePush(&conn->cliMsgs, pMsg);
|
||||
TAOS_UNUSED(transQueuePush(&conn->cliMsgs, pMsg));
|
||||
|
||||
conn->status = ConnNormal;
|
||||
cliSend(conn);
|
||||
|
@ -871,8 +871,8 @@ static void addConnToPool(void* pool, SCliConn* conn) {
|
|||
}
|
||||
static int32_t allocConnRef(SCliConn* conn, bool update) {
|
||||
if (update) {
|
||||
(void)transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
(void)transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
|
||||
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) {
|
||||
if (update) {
|
||||
(void)transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
(void)transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
|
||||
conn->refId = -1;
|
||||
}
|
||||
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);
|
||||
|
||||
(void)transReleaseExHandle(transGetRefMgt(), handle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1004,7 +1004,7 @@ static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn) {
|
|||
conn->broken = false;
|
||||
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);
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ _failed:
|
|||
if (conn) {
|
||||
taosMemoryFree(conn->stream);
|
||||
transReqQueueClear(&conn->wreqQueue);
|
||||
(void)transDestroyBuffer(&conn->readBuf);
|
||||
TAOS_UNUSED(transDestroyBuffer(&conn->readBuf));
|
||||
transQueueDestroy(&conn->cliMsgs);
|
||||
}
|
||||
taosMemoryFree(conn);
|
||||
|
@ -1059,8 +1059,8 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
|
|||
}
|
||||
conn->list = NULL;
|
||||
|
||||
(void)transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
(void)transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
|
||||
conn->refId = -1;
|
||||
|
||||
if (conn->task != NULL) {
|
||||
|
@ -1071,7 +1071,7 @@ static void cliDestroyConn(SCliConn* conn, bool clear) {
|
|||
|
||||
if (clear) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1084,11 +1084,11 @@ static void cliDestroy(uv_handle_t* handle) {
|
|||
SCliThrd* pThrd = conn->hostThrd;
|
||||
cliResetTimer(pThrd, conn);
|
||||
|
||||
(void)atomic_sub_fetch_32(&pThrd->connCount, 1);
|
||||
TAOS_UNUSED(atomic_sub_fetch_32(&pThrd->connCount, 1));
|
||||
|
||||
if (conn->refId > 0) {
|
||||
(void)transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
(void)transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), conn->refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), conn->refId));
|
||||
}
|
||||
taosMemoryFree(conn->dstAddr);
|
||||
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);
|
||||
transReqQueueClear(&conn->wreqQueue);
|
||||
(void)transDestroyBuffer(&conn->readBuf);
|
||||
TAOS_UNUSED(transDestroyBuffer(&conn->readBuf));
|
||||
|
||||
taosMemoryFree(conn);
|
||||
}
|
||||
|
@ -1106,7 +1106,7 @@ static bool cliHandleNoResp(SCliConn* conn) {
|
|||
if (!transQueueEmpty(&conn->cliMsgs)) {
|
||||
SCliMsg* pMsg = transQueueGet(&conn->cliMsgs, 0);
|
||||
if (REQUEST_NO_RESP(&pMsg->msg)) {
|
||||
(void)transQueuePop(&conn->cliMsgs);
|
||||
TAOS_UNUSED(transQueuePop(&conn->cliMsgs));
|
||||
destroyCmsg(pMsg);
|
||||
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);
|
||||
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) {
|
||||
int32_t code = 0;
|
||||
|
@ -1296,13 +1296,13 @@ void cliSend(SCliConn* pConn) {
|
|||
if (timer == NULL) {
|
||||
timer = taosMemoryCalloc(1, sizeof(uv_timer_t));
|
||||
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;
|
||||
pConn->timer = timer;
|
||||
|
||||
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) {
|
||||
|
@ -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);
|
||||
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
||||
if (fd == -1) {
|
||||
tError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
||||
tstrerror(terrno));
|
||||
tError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, tstrerror(terrno));
|
||||
cliHandleFastFail(conn, -1);
|
||||
return;
|
||||
}
|
||||
|
@ -1428,7 +1427,7 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) {
|
|||
cliHandleFastFail(conn, -1);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1541,12 +1540,12 @@ void cliConnCb(uv_connect_t* req, int status) {
|
|||
|
||||
struct sockaddr peername, sockname;
|
||||
int addrlen = sizeof(peername);
|
||||
(void)uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen);
|
||||
(void)transSockInfo2Str(&peername, pConn->dst);
|
||||
TAOS_UNUSED(uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen));
|
||||
TAOS_UNUSED(transSockInfo2Str(&peername, pConn->dst));
|
||||
|
||||
addrlen = sizeof(sockname);
|
||||
(void)uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen);
|
||||
(void)transSockInfo2Str(&sockname, pConn->src);
|
||||
TAOS_UNUSED(uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen));
|
||||
TAOS_UNUSED(transSockInfo2Str(&sockname, pConn->src));
|
||||
|
||||
struct sockaddr_in addr = *(struct sockaddr_in*)&sockname;
|
||||
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);
|
||||
destroyCmsg(pMsg);
|
||||
|
||||
(void)destroyConnPool(pThrd);
|
||||
(void)uv_walk(pThrd->loop, cliWalkCb, NULL);
|
||||
TAOS_UNUSED(destroyConnPool(pThrd));
|
||||
TAOS_UNUSED(uv_walk(pThrd->loop, cliWalkCb, NULL));
|
||||
}
|
||||
static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||
int64_t refId = (int64_t)(pMsg->msg.info.handle);
|
||||
|
@ -1611,8 +1610,7 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
taosRLockLatch(&exh->latch);
|
||||
SCliConn* conn = exh->handle;
|
||||
taosRUnLockLatch(&exh->latch);
|
||||
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
tDebug("%s conn %p start to release to inst", CONN_GET_INST_LABEL(conn), conn);
|
||||
|
||||
if (T_REF_VAL_GET(conn) == 2) {
|
||||
|
@ -1656,7 +1654,7 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _exception);
|
||||
} else {
|
||||
destroyCmsg(pMsg);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
|
||||
while (T_REF_VAL_GET(conn) >= 1) {
|
||||
transUnrefCliHandle(conn);
|
||||
|
@ -1666,9 +1664,9 @@ static void cliHandleFreeById(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
_exception:
|
||||
tDebug("already free conn %p by id %" PRId64 "", conn, refId);
|
||||
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
(void)transRemoveExHandle(transGetRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), refId));
|
||||
destroyCmsg(pMsg);
|
||||
}
|
||||
|
||||
|
@ -1691,7 +1689,7 @@ SCliConn* cliGetConn(SCliMsg** pMsg, SCliThrd* pThrd, bool* ignore, char* addr)
|
|||
conn = getConnFromPool2(pThrd, addr, pMsg);
|
||||
if (conn != NULL) specifyConnRef(conn, true, refId);
|
||||
}
|
||||
(void)transReleaseExHandle(transGetRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), refId));
|
||||
}
|
||||
return conn;
|
||||
};
|
||||
|
@ -1787,7 +1785,7 @@ static void cliMayUpdateFqdnCache(SHashObj* cache, char* dst) {
|
|||
if (i > 0) {
|
||||
char fqdn[TSDB_FQDN_LEN + 1] = {0};
|
||||
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) {
|
||||
// persist conn already release by server
|
||||
STransMsg resp = {0};
|
||||
(void)cliBuildExceptResp(pMsg, &resp);
|
||||
TAOS_UNUSED(cliBuildExceptResp(pMsg, &resp));
|
||||
// refactorr later
|
||||
resp.info.cliVer = pTransInst->compatibilityVer;
|
||||
|
||||
|
@ -1841,14 +1839,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
|
||||
if (conn != NULL) {
|
||||
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
|
||||
(void)transQueuePush(&conn->cliMsgs, pMsg);
|
||||
TAOS_UNUSED(transQueuePush(&conn->cliMsgs, pMsg));
|
||||
cliSend(conn);
|
||||
} else {
|
||||
code = cliCreateConn(pThrd, &conn);
|
||||
if (code != 0) {
|
||||
tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code));
|
||||
STransMsg resp = {.code = code};
|
||||
(void)cliBuildExceptResp(pMsg, &resp);
|
||||
TAOS_UNUSED(cliBuildExceptResp(pMsg, &resp));
|
||||
|
||||
resp.info.cliVer = pTransInst->compatibilityVer;
|
||||
if (pMsg->type != Release) {
|
||||
|
@ -1862,7 +1860,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
if (refId != 0) specifyConnRef(conn, true, refId);
|
||||
|
||||
transCtxMerge(&conn->ctx, &pMsg->ctx->appCtx);
|
||||
(void)transQueuePush(&conn->cliMsgs, pMsg);
|
||||
TAOS_UNUSED(transQueuePush(&conn->cliMsgs, pMsg));
|
||||
|
||||
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);
|
||||
int32_t fd = taosCreateSocketWithTimeout(TRANS_CONN_TIMEOUT * 10);
|
||||
if (fd == -1) {
|
||||
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn,
|
||||
tstrerror(terrno));
|
||||
tGError("%s conn %p failed to create socket, reason:%s", transLabel(pTransInst), conn, tstrerror(terrno));
|
||||
cliHandleExcept(conn, -1);
|
||||
terrno = 0;
|
||||
return;
|
||||
|
@ -1911,7 +1908,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
cliHandleFastFail(conn, ret);
|
||||
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);
|
||||
}
|
||||
|
@ -2110,9 +2107,9 @@ static void cliAsyncCb(uv_async_t* handle) {
|
|||
|
||||
// batch process to avoid to lock/unlock frequently
|
||||
queue wq;
|
||||
(void)taosThreadMutexLock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
|
||||
QUEUE_MOVE(&item->qmsg, &wq);
|
||||
(void)taosThreadMutexUnlock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
|
||||
|
||||
int8_t supportBatch = pTransInst->supportBatch;
|
||||
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,
|
||||
conn->refId);
|
||||
|
||||
(void)transClearBuffer(&conn->readBuf);
|
||||
TAOS_UNUSED(transClearBuffer(&conn->readBuf));
|
||||
transFreeMsg(transContFromHead((char*)pHead));
|
||||
|
||||
for (int i = 0; ahandle == 0 && i < transQueueSize(&conn->cliMsgs); i++) {
|
||||
|
@ -2192,10 +2189,10 @@ static void* cliWorkThread(void* arg) {
|
|||
SCliThrd* pThrd = (SCliThrd*)arg;
|
||||
pThrd->pid = taosGetSelfPthreadId();
|
||||
|
||||
(void)strtolower(threadName, pThrd->pTransInst->label);
|
||||
TAOS_UNUSED(strtolower(threadName, pThrd->pTransInst->label));
|
||||
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);
|
||||
return NULL;
|
||||
|
@ -2239,7 +2236,7 @@ _err:
|
|||
if (cli) {
|
||||
for (int i = 0; i < cli->numOfThreads; i++) {
|
||||
if (cli->pThreadObj[i]) {
|
||||
(void)cliSendQuit(cli->pThreadObj[i]);
|
||||
TAOS_UNUSED(cliSendQuit(cli->pThreadObj[i]));
|
||||
destroyThrdObj(cli->pThreadObj[i]);
|
||||
}
|
||||
}
|
||||
|
@ -2283,8 +2280,8 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) {
|
|||
}
|
||||
|
||||
if (pMsg->msg.info.handle != 0) {
|
||||
(void)transReleaseExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle);
|
||||
(void)transRemoveExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetRefMgt(), (int64_t)pMsg->msg.info.handle));
|
||||
}
|
||||
|
||||
transDestroyConnCtx(pMsg->ctx);
|
||||
|
@ -2302,7 +2299,7 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
|||
}
|
||||
|
||||
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));
|
||||
if (pThrd->loop == NULL) {
|
||||
|
@ -2324,8 +2321,8 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
|||
|
||||
pThrd->pool = createConnPool(4);
|
||||
if (pThrd->pool == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
||||
}
|
||||
if ((code = transDQCreate(pThrd->loop, &pThrd->delayQueue)) != 0) {
|
||||
TAOS_CHECK_GOTO(code, NULL, _end);
|
||||
|
@ -2366,9 +2363,9 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
|||
if (timer == NULL) {
|
||||
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) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
||||
}
|
||||
}
|
||||
pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime);
|
||||
|
@ -2380,19 +2377,19 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) {
|
|||
|
||||
_end:
|
||||
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);
|
||||
transAsyncPoolDestroy(pThrd->asyncPool);
|
||||
for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) {
|
||||
uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i);
|
||||
(void)uv_timer_stop(timer);
|
||||
TAOS_UNUSED(uv_timer_stop(timer));
|
||||
taosMemoryFree(timer);
|
||||
}
|
||||
taosArrayDestroy(pThrd->timerList);
|
||||
|
||||
(void)destroyConnPool(pThrd);
|
||||
TAOS_UNUSED(destroyConnPool(pThrd));
|
||||
transDQDestroy(pThrd->delayQueue, NULL);
|
||||
transDQDestroy(pThrd->timeoutQueue, NULL);
|
||||
transDQDestroy(pThrd->waitConnQueue, NULL);
|
||||
|
@ -2409,9 +2406,9 @@ static void destroyThrdObj(SCliThrd* pThrd) {
|
|||
return;
|
||||
}
|
||||
|
||||
(void)taosThreadJoin(pThrd->thread, NULL);
|
||||
TAOS_UNUSED(taosThreadJoin(pThrd->thread, NULL));
|
||||
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);
|
||||
transAsyncPoolDestroy(pThrd->asyncPool);
|
||||
|
||||
|
@ -2478,9 +2475,9 @@ void cliWalkCb(uv_handle_t* handle, void* arg) {
|
|||
if (uv_handle_get_type(handle) == UV_TIMER) {
|
||||
// do nothing
|
||||
} 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;
|
||||
STraceId* trace = &pMsg->msg.info.traceId;
|
||||
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,
|
||||
pCtx->retryNextInterval);
|
||||
return;
|
||||
|
@ -2533,7 +2530,7 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
arg->param1 = pMsg;
|
||||
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) {
|
||||
|
@ -2751,7 +2748,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
if (hasEpSet) {
|
||||
if (rpcDebugFlag & DEBUG_TRACE) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -2763,7 +2760,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
} else {
|
||||
memcpy((char*)pCtx->pRsp, (char*)pResp, sizeof(*pResp));
|
||||
}
|
||||
(void)tsem_post(pCtx->pSem);
|
||||
TAOS_UNUSED(tsem_post(pCtx->pSem));
|
||||
pCtx->pRsp = NULL;
|
||||
} else {
|
||||
STransSyncMsg* pSyncMsg = taosAcquireRef(transGetSyncMsgMgt(), pCtx->syncMsgRef);
|
||||
|
@ -2773,8 +2770,8 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
|||
pSyncMsg->hasEpSet = 1;
|
||||
epsetAssign(&pSyncMsg->epSet, &pCtx->epSet);
|
||||
}
|
||||
(void)tsem2_post(pSyncMsg->pSem);
|
||||
(void)taosReleaseRef(transGetSyncMsgMgt(), pCtx->syncMsgRef);
|
||||
TAOS_UNUSED(tsem2_post(pSyncMsg->pSem));
|
||||
TAOS_UNUSED(taosReleaseRef(transGetSyncMsgMgt(), pCtx->syncMsgRef));
|
||||
} else {
|
||||
rpcFreeCont(pResp->pCont);
|
||||
}
|
||||
|
@ -2843,7 +2840,7 @@ static FORCE_INLINE SCliThrd* transGetWorkThrdFromHandle(STrans* trans, int64_t
|
|||
|
||||
pThrd = exh->pThrd;
|
||||
taosWUnLockLatch(&exh->latch);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), handle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
|
||||
|
||||
return pThrd;
|
||||
}
|
||||
|
@ -2949,7 +2946,7 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
|
|||
code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg);
|
||||
if (code != 0) {
|
||||
taosWUnLockLatch(&exh->latch);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), handle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
|
||||
TAOS_CHECK_GOTO(code, NULL, _exception);
|
||||
}
|
||||
|
||||
|
@ -2957,13 +2954,13 @@ int32_t transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, S
|
|||
taosWUnLockLatch(&exh->latch);
|
||||
|
||||
tDebug("msg refId: %" PRId64 "", handle);
|
||||
(void)transReleaseExHandle(transGetRefMgt(), handle);
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetRefMgt(), handle));
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
return 0;
|
||||
} else {
|
||||
exh->inited = 1;
|
||||
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);
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) {
|
||||
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);
|
||||
}
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
return 0;
|
||||
|
||||
_exception:
|
||||
transFreeMsg(pReq->pCont);
|
||||
pReq->pCont = NULL;
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
return code;
|
||||
}
|
||||
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);
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) {
|
||||
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);
|
||||
}
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
return 0;
|
||||
|
||||
_exception:
|
||||
transFreeMsg(pReq->pCont);
|
||||
pReq->pCont = NULL;
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -3068,7 +3065,7 @@ int32_t transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
|
|||
|
||||
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
||||
if (pCtx == NULL) {
|
||||
(void)tsem_destroy(sem);
|
||||
TAOS_UNUSED(tsem_destroy(sem));
|
||||
taosMemoryFree(sem);
|
||||
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));
|
||||
if (cliMsg == NULL) {
|
||||
(void)tsem_destroy(sem);
|
||||
TAOS_UNUSED(tsem_destroy(sem));
|
||||
taosMemoryFree(sem);
|
||||
taosMemoryFree(pCtx);
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _RETURN1);
|
||||
|
@ -3103,18 +3100,18 @@ int32_t transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra
|
|||
destroyCmsg(cliMsg);
|
||||
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));
|
||||
|
||||
_RETURN:
|
||||
tsem_destroy(sem);
|
||||
taosMemoryFree(sem);
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
taosMemoryFree(pTransRsp);
|
||||
return code;
|
||||
_RETURN1:
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
taosMemoryFree(pTransRsp);
|
||||
taosMemoryFree(pReq->pCont);
|
||||
pReq->pCont = NULL;
|
||||
|
@ -3151,7 +3148,7 @@ int32_t transCreateSyncMsg(STransMsg* pTransMsg, int64_t* refId) {
|
|||
return 0;
|
||||
|
||||
_EXIT:
|
||||
(void)tsem2_destroy(sem);
|
||||
TAOS_UNUSED(tsem2_destroy(sem));
|
||||
taosMemoryFree(sem);
|
||||
taosMemoryFree(pSyncMsg);
|
||||
return code;
|
||||
|
@ -3235,15 +3232,15 @@ int32_t transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq,
|
|||
}
|
||||
}
|
||||
_RETURN:
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
(void)taosReleaseRef(transGetSyncMsgMgt(), ref);
|
||||
(void)taosRemoveRef(transGetSyncMsgMgt(), ref);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
TAOS_UNUSED(taosReleaseRef(transGetSyncMsgMgt(), ref));
|
||||
TAOS_UNUSED(taosRemoveRef(transGetSyncMsgMgt(), ref));
|
||||
return code;
|
||||
_RETURN2:
|
||||
transFreeMsg(pReq->pCont);
|
||||
pReq->pCont = NULL;
|
||||
taosMemoryFree(pTransMsg);
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)shandle));
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAs
|
|||
}
|
||||
item->pThrd = arg;
|
||||
QUEUE_INIT(&item->qmsg);
|
||||
(void)taosThreadMutexInit(&item->mtx, NULL);
|
||||
TAOS_UNUSED(taosThreadMutexInit(&item->mtx, NULL));
|
||||
|
||||
async->data = item;
|
||||
err = uv_async_init(loop, async, cb);
|
||||
|
@ -301,7 +301,7 @@ void transAsyncPoolDestroy(SAsyncPool* pool) {
|
|||
SAsyncItem* item = async->data;
|
||||
if (item == NULL) continue;
|
||||
|
||||
(void)taosThreadMutexDestroy(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexDestroy(&item->mtx));
|
||||
taosMemoryFree(item);
|
||||
}
|
||||
taosMemoryFree(pool->asyncs);
|
||||
|
@ -328,9 +328,9 @@ int transAsyncSend(SAsyncPool* pool, queue* q) {
|
|||
uv_async_t* async = &(pool->asyncs[idx]);
|
||||
SAsyncItem* item = async->data;
|
||||
|
||||
(void)taosThreadMutexLock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
|
||||
QUEUE_PUSH(&item->qmsg, q);
|
||||
(void)taosThreadMutexUnlock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
|
||||
int ret = uv_async_send(async);
|
||||
if (ret != 0) {
|
||||
tError("failed to send async,reason:%s", uv_err_name(ret));
|
||||
|
@ -393,7 +393,7 @@ void* transCtxDumpVal(STransCtx* ctx, int32_t key) {
|
|||
return NULL;
|
||||
}
|
||||
void* ret = NULL;
|
||||
(void)(*cVal->clone)(cVal->val, &ret);
|
||||
TAOS_UNUSED((*cVal->clone)(cVal->val, &ret));
|
||||
return ret;
|
||||
}
|
||||
void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) {
|
||||
|
@ -401,7 +401,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) {
|
|||
if (ctx->brokenVal.clone == NULL) {
|
||||
return ret;
|
||||
}
|
||||
(void)(*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret);
|
||||
TAOS_UNUSED((*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret));
|
||||
|
||||
*msgType = ctx->brokenVal.msgType;
|
||||
|
||||
|
@ -549,7 +549,7 @@ static void transDQTimeout(uv_timer_t* timer) {
|
|||
}
|
||||
} while (1);
|
||||
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) {
|
||||
|
@ -614,7 +614,7 @@ void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) {
|
|||
taosMemoryFree(queue);
|
||||
}
|
||||
void transDQCancel(SDelayQueue* queue, SDelayTask* task) {
|
||||
(void)uv_timer_stop(queue->timer);
|
||||
TAOS_UNUSED(uv_timer_stop(queue->timer));
|
||||
|
||||
if (heapSize(queue->heap) <= 0) {
|
||||
taosMemoryFree(task->arg);
|
||||
|
@ -634,7 +634,7 @@ void transDQCancel(SDelayQueue* queue, SDelayTask* task) {
|
|||
SDelayTask* task = container_of(minNode, SDelayTask, node);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ static void transInitEnv() {
|
|||
svrRefMgt = transOpenRefMgt(50000, transDestroyExHandle);
|
||||
instMgt = taosOpenRef(50, rpcCloseImpl);
|
||||
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() {
|
||||
transCloseRefMgt(refMgt);
|
||||
|
@ -775,7 +775,7 @@ void transDestroySyncMsg(void* msg) {
|
|||
if (msg == NULL) return;
|
||||
|
||||
STransSyncMsg* pSyncMsg = msg;
|
||||
(void)tsem2_destroy(pSyncMsg->pSem);
|
||||
TAOS_UNUSED(tsem2_destroy(pSyncMsg->pSem));
|
||||
taosMemoryFree(pSyncMsg->pSem);
|
||||
transFreeMsg(pSyncMsg->pRsp->pCont);
|
||||
taosMemoryFree(pSyncMsg->pRsp);
|
||||
|
|
|
@ -188,11 +188,11 @@ static void sendQuitToWorkThrd(SWorkThrd* pThrd);
|
|||
static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName);
|
||||
static int32_t addHandleToAcceptloop(void* arg);
|
||||
|
||||
#define SRV_RELEASE_UV(loop) \
|
||||
do { \
|
||||
(void)uv_walk(loop, uvWalkCb, NULL); \
|
||||
(void)uv_run(loop, UV_RUN_DEFAULT); \
|
||||
(void)uv_loop_close(loop); \
|
||||
#define SRV_RELEASE_UV(loop) \
|
||||
do { \
|
||||
TAOS_UNUSED(uv_walk(loop, uvWalkCb, NULL)); \
|
||||
TAOS_UNUSED(uv_run(loop, UV_RUN_DEFAULT)); \
|
||||
TAOS_UNUSED(uv_loop_close(loop)); \
|
||||
} while (0);
|
||||
|
||||
#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);
|
||||
memset(&conn->regArg, 0, sizeof(conn->regArg));
|
||||
}
|
||||
(void)transQueuePop(&conn->srvMsgs);
|
||||
TAOS_UNUSED(transQueuePop(&conn->srvMsgs));
|
||||
taosMemoryFree(msg);
|
||||
|
||||
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
|
||||
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);
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) {
|
|||
|
||||
transRefSrvHandle(pConn);
|
||||
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) {
|
||||
// impl
|
||||
|
@ -759,9 +759,9 @@ void uvWorkerAsyncCb(uv_async_t* handle) {
|
|||
queue wq;
|
||||
|
||||
// batch process to avoid to lock/unlock frequently
|
||||
(void)taosThreadMutexLock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexLock(&item->mtx));
|
||||
QUEUE_MOVE(&item->qmsg, &wq);
|
||||
(void)taosThreadMutexUnlock(&item->mtx);
|
||||
TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx));
|
||||
|
||||
while (!QUEUE_IS_EMPTY(&wq)) {
|
||||
queue* head = QUEUE_HEAD(&wq);
|
||||
|
@ -784,12 +784,12 @@ void uvWorkerAsyncCb(uv_async_t* handle) {
|
|||
SExHandle* exh2 = transAcquireExHandle(transGetSvrRefMgt(), refId);
|
||||
if (exh2 == NULL || exh1 != exh2) {
|
||||
tTrace("handle except msg %p, ignore it", exh1);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
destroySmsg(msg);
|
||||
continue;
|
||||
}
|
||||
msg->pConn = exh1->handle;
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
(*transAsyncHandle[msg->type])(msg, pThrd);
|
||||
}
|
||||
}
|
||||
|
@ -827,7 +827,7 @@ static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) {
|
|||
tTrace("conn %p received release request", pConn);
|
||||
|
||||
STraceId traceId = pHead->traceId;
|
||||
(void)transClearBuffer(&pConn->readBuf);
|
||||
TAOS_UNUSED(transClearBuffer(&pConn->readBuf));
|
||||
transFreeMsg(transContFromHead((char*)pHead));
|
||||
if (pConn->status != ConnAcquire) {
|
||||
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);
|
||||
|
||||
(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 {
|
||||
if (!uv_is_closing((uv_handle_t*)cli)) {
|
||||
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) {
|
||||
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);
|
||||
|
||||
struct sockaddr peername, sockname;
|
||||
|
@ -981,7 +982,7 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
|
|||
transUnrefSrvHandle(pConn);
|
||||
return;
|
||||
}
|
||||
(void)transSockInfo2Str(&peername, pConn->dst);
|
||||
TAOS_UNUSED(transSockInfo2Str(&peername, pConn->dst));
|
||||
|
||||
addrlen = sizeof(sockname);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
(void)transSockInfo2Str(&sockname, pConn->src);
|
||||
TAOS_UNUSED(transSockInfo2Str(&sockname, pConn->src));
|
||||
|
||||
struct sockaddr_in addr = *(struct sockaddr_in*)&peername;
|
||||
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->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 {
|
||||
tDebug("failed to create new connection");
|
||||
|
@ -1010,7 +1011,7 @@ void* transAcceptThread(void* arg) {
|
|||
// opt
|
||||
setThreadName("trans-accept");
|
||||
SServerObj* srv = (SServerObj*)arg;
|
||||
(void)uv_run(srv->loop, UV_RUN_DEFAULT);
|
||||
TAOS_UNUSED(uv_run(srv->loop, UV_RUN_DEFAULT));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1021,7 +1022,7 @@ void uvOnPipeConnectionCb(uv_connect_t* connect, int status) {
|
|||
};
|
||||
|
||||
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) {
|
||||
int32_t code = 0;
|
||||
|
@ -1124,7 +1125,7 @@ static int32_t addHandleToAcceptloop(void* arg) {
|
|||
void* transWorkerThread(void* arg) {
|
||||
setThreadName("trans-svr-work");
|
||||
SWorkThrd* pThrd = (SWorkThrd*)arg;
|
||||
(void)uv_run(pThrd->loop, UV_RUN_DEFAULT);
|
||||
TAOS_UNUSED(uv_run(pThrd->loop, UV_RUN_DEFAULT));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1201,7 +1202,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) {
|
|||
_end:
|
||||
if (pConn) {
|
||||
transQueueDestroy(&pConn->srvMsgs);
|
||||
(void)transDestroyBuffer(&pConn->readBuf);
|
||||
TAOS_UNUSED(transDestroyBuffer(&pConn->readBuf));
|
||||
taosMemoryFree(pConn->pTcp);
|
||||
taosMemoryFree(pConn);
|
||||
pConn = NULL;
|
||||
|
@ -1230,8 +1231,8 @@ static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) {
|
|||
}
|
||||
static int32_t reallocConnRef(SSvrConn* conn) {
|
||||
if (conn->refId > 0) {
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), conn->refId);
|
||||
(void)transRemoveExHandle(transGetSvrRefMgt(), conn->refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), conn->refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetSvrRefMgt(), conn->refId));
|
||||
}
|
||||
// avoid app continue to send msg on invalid handle
|
||||
SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle));
|
||||
|
@ -1267,8 +1268,8 @@ static void uvDestroyConn(uv_handle_t* handle) {
|
|||
}
|
||||
SWorkThrd* thrd = conn->hostThrd;
|
||||
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), conn->refId);
|
||||
(void)transRemoveExHandle(transGetSvrRefMgt(), conn->refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), conn->refId));
|
||||
TAOS_UNUSED(transRemoveExHandle(transGetSvrRefMgt(), conn->refId));
|
||||
|
||||
STrans* pTransInst = thrd->pTransInst;
|
||||
tDebug("%s conn %p destroy", transLabel(pTransInst), conn);
|
||||
|
@ -1283,7 +1284,7 @@ static void uvDestroyConn(uv_handle_t* handle) {
|
|||
QUEUE_REMOVE(&conn->queue);
|
||||
taosMemoryFree(conn->pTcp);
|
||||
destroyConnRegArg(conn);
|
||||
(void)transDestroyBuffer(&conn->readBuf);
|
||||
TAOS_UNUSED(transDestroyBuffer(&conn->readBuf));
|
||||
taosMemoryFree(conn);
|
||||
|
||||
if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) {
|
||||
|
@ -1563,7 +1564,7 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd) {
|
|||
if (!transQueuePush(&conn->srvMsgs, msg)) {
|
||||
return;
|
||||
}
|
||||
(void)transQueuePop(&conn->srvMsgs);
|
||||
TAOS_UNUSED(transQueuePop(&conn->srvMsgs));
|
||||
|
||||
if (conn->regArg.init) {
|
||||
transFreeMsg(conn->regArg.msg.pCont);
|
||||
|
@ -1636,7 +1637,7 @@ void destroyWorkThrd(SWorkThrd* pThrd) {
|
|||
}
|
||||
if (pThrd->inited) {
|
||||
sendQuitToWorkThrd(pThrd);
|
||||
(void)taosThreadJoin(pThrd->thread, NULL);
|
||||
TAOS_UNUSED(taosThreadJoin(pThrd->thread, NULL));
|
||||
SRV_RELEASE_UV(pThrd->loop);
|
||||
TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SSvrMsg, destroySmsgWrapper, NULL);
|
||||
}
|
||||
|
@ -1646,7 +1647,7 @@ void sendQuitToWorkThrd(SWorkThrd* pThrd) {
|
|||
SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
msg->type = Quit;
|
||||
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) {
|
||||
|
@ -1655,8 +1656,8 @@ void transCloseServer(void* arg) {
|
|||
|
||||
if (srv->inited) {
|
||||
tDebug("send quit msg to accept thread");
|
||||
(void)uv_async_send(srv->pAcceptAsync);
|
||||
(void)taosThreadJoin(srv->thread, NULL);
|
||||
TAOS_UNUSED(uv_async_send(srv->pAcceptAsync));
|
||||
TAOS_UNUSED(taosThreadJoin(srv->thread, NULL));
|
||||
|
||||
SRV_RELEASE_UV(srv->loop);
|
||||
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);
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
|
||||
destroySmsg(m);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return 0;
|
||||
_return1:
|
||||
tDebug("handle %p failed to send to release handle", exh);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return code;
|
||||
_return2:
|
||||
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);
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
|
||||
destroySmsg(m);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return 0;
|
||||
|
||||
_return1:
|
||||
tDebug("handle %p failed to send resp", exh);
|
||||
rpcFreeCont(msg->pCont);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return code;
|
||||
_return2:
|
||||
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);
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
|
||||
destroySmsg(m);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return 0;
|
||||
|
||||
_return1:
|
||||
tDebug("handle %p failed to register brokenlink", exh);
|
||||
rpcFreeCont(msg->pCont);
|
||||
(void)transReleaseExHandle(transGetSvrRefMgt(), refId);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetSvrRefMgt(), refId));
|
||||
return code;
|
||||
_return2:
|
||||
tDebug("handle %p failed to register brokenlink", exh);
|
||||
|
@ -1875,7 +1876,7 @@ int32_t transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
(void)transReleaseExHandle(transGetInstMgt(), (int64_t)thandle);
|
||||
TAOS_UNUSED(transReleaseExHandle(transGetInstMgt(), (int64_t)thandle));
|
||||
|
||||
if (code != 0) {
|
||||
tError("ip-white-list update failed since %s", tstrerror(code));
|
||||
|
|
|
@ -601,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),
|
||||
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(memcpy(newBody, body, plainBodyLen));
|
||||
|
@ -613,7 +613,7 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
|||
|
||||
if (newBody != NULL) taosMemoryFreeClear(newBody);
|
||||
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _exit);
|
||||
}
|
||||
|
||||
SCryptOpts opts;
|
||||
|
|
|
@ -335,7 +335,7 @@ int32_t taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, con
|
|||
if (buf == NULL) {
|
||||
tmp = taosMemoryMalloc(size);
|
||||
if (NULL == tmp) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
} else {
|
||||
tmp = buf;
|
||||
|
@ -467,7 +467,7 @@ static int32_t taosMergeSortHelper(void *src, int64_t numOfElem, int64_t size, c
|
|||
int32_t currSize;
|
||||
void *tmp = taosMemoryMalloc(numOfElem * size);
|
||||
if (tmp == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
for (currSize = THRESHOLD_SIZE; currSize <= numOfElem - 1; currSize = 2 * currSize) {
|
||||
|
|
|
@ -22,7 +22,7 @@ int32_t base64_encode(const uint8_t *value, int32_t vlen, char **result) {
|
|||
uint8_t oval = 0;
|
||||
*result = (char *)taosMemoryMalloc((size_t)(vlen * 4) / 3 + 10);
|
||||
if (*result == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
char *out = *result;
|
||||
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;
|
||||
*result = (uint8_t *)taosMemoryMalloc((size_t)(inlen * 3) / 4 + 1);
|
||||
if (*result == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
uint8_t *out = *result;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ int32_t tStartEncode(SEncoder* pCoder) {
|
|||
|
||||
pNode = tEncoderMalloc(pCoder, sizeof(*pNode));
|
||||
if (pNode == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
pNode->data = pCoder->data;
|
||||
|
@ -126,7 +126,7 @@ int32_t tStartDecode(SDecoder* pCoder) {
|
|||
|
||||
pNode = tDecoderMalloc(pCoder, sizeof(*pNode));
|
||||
if (pNode == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
pNode->data = pCoder->data;
|
||||
|
|
|
@ -46,7 +46,7 @@ int32_t tScalableBfInit(uint64_t expectedEntries, double errorRate, SScalableBf*
|
|||
pSBf->numBits = 0;
|
||||
pSBf->bfArray = taosArrayInit(defaultSize, sizeof(void*));
|
||||
if (!pSBf->bfArray) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
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);
|
||||
SBloomFilter* pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1);
|
||||
if (!pNormalBf) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
}
|
||||
if (tBloomFilterIsFull(pNormalBf)) {
|
||||
|
@ -236,7 +236,7 @@ int32_t tScalableBfDecode(SDecoder* pDecoder, SScalableBf** ppSBf) {
|
|||
}
|
||||
pSBf->bfArray = taosArrayInit(size * 2, POINTER_BYTES);
|
||||
if (!pSBf->bfArray) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ int32_t tScalableBfDecode(SDecoder* pDecoder, SScalableBf** ppSBf) {
|
|||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
void* tmpRes = taosArrayPush(pSBf->bfArray, &pBF);
|
||||
if (!tmpRes) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ int32_t tAutoQWorkerInit(SAutoQWorkerPool *pool) {
|
|||
pool->workers = taosArrayInit(2, sizeof(SQueueWorker *));
|
||||
if (pool->workers == NULL) {
|
||||
taosCloseQset(pool->qset);
|
||||
return terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
(void)taosThreadMutexInit(&pool->mutex, NULL);
|
||||
|
|
|
@ -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-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_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_replay.py
|
||||
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py
|
||||
|
|
|
@ -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())
|
|
@ -18,7 +18,7 @@ IF (TD_WEBSOCKET)
|
|||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
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
|
||||
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
|
||||
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
|
||||
|
@ -37,7 +37,7 @@ IF (TD_WEBSOCKET)
|
|||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
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
|
||||
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
|
||||
|
@ -57,7 +57,7 @@ IF (TD_WEBSOCKET)
|
|||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
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
|
||||
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
|
||||
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
|
||||
|
|
|
@ -34,10 +34,10 @@ int shell_conn_ws_server(bool first) {
|
|||
size_t len = strlen(shell.args.dsn);
|
||||
char * dsn = taosMemoryMalloc(len + 32);
|
||||
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);
|
||||
} else {
|
||||
shell.ws_conn = ws_connect_with_dsn(shell.args.dsn);
|
||||
shell.ws_conn = ws_connect(shell.args.dsn);
|
||||
}
|
||||
|
||||
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) {
|
||||
const void* data = NULL;
|
||||
int rows;
|
||||
ws_fetch_block(wres, &data, &rows);
|
||||
ws_fetch_raw_block(wres, &data, &rows);
|
||||
if (wres) {
|
||||
*execute_time += (double)(ws_take_timing(wres)/1E6);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) {
|
|||
putchar('\n');
|
||||
}
|
||||
numOfRows += rows;
|
||||
ws_fetch_block(wres, &data, &rows);
|
||||
ws_fetch_raw_block(wres, &data, &rows);
|
||||
} while (rows && !shell.stop_query);
|
||||
return numOfRows;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) {
|
|||
static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) {
|
||||
int rows = 0;
|
||||
const void* data = NULL;
|
||||
ws_fetch_block(wres, &data, &rows);
|
||||
ws_fetch_raw_block(wres, &data, &rows);
|
||||
if (wres) {
|
||||
*pexecute_time += (double)(ws_take_timing(wres)/1E6);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) {
|
|||
}
|
||||
numOfRows++;
|
||||
}
|
||||
ws_fetch_block(wres, &data, &rows);
|
||||
ws_fetch_raw_block(wres, &data, &rows);
|
||||
} while (rows && !shell.stop_query);
|
||||
return numOfRows;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres,
|
|||
}
|
||||
int rows = 0;
|
||||
const void* data = NULL;
|
||||
ws_fetch_block(wres, &data, &rows);
|
||||
ws_fetch_raw_block(wres, &data, &rows);
|
||||
if (wres) {
|
||||
*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");
|
||||
}
|
||||
ws_fetch_block(wres, &data, &rows);
|
||||
ws_fetch_raw_block(wres, &data, &rows);
|
||||
} while (rows && !shell.stop_query);
|
||||
taosCloseFile(&pFile);
|
||||
return numOfRows;
|
||||
|
|
|
@ -3,6 +3,7 @@ add_dependencies(tmq_demo taos)
|
|||
add_executable(tmq_sim tmqSim.c)
|
||||
add_executable(create_table createTable.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(sml_test sml_test.c)
|
||||
add_executable(get_db_name_test get_db_name_test.c)
|
||||
|
@ -69,11 +70,11 @@ target_link_libraries(
|
|||
)
|
||||
|
||||
target_link_libraries(
|
||||
replay_test
|
||||
PUBLIC taos
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
PUBLIC os
|
||||
replay_test
|
||||
PUBLIC taos
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
PUBLIC os
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
|
@ -84,6 +85,14 @@ target_link_libraries(
|
|||
PUBLIC os
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
tmq_write_raw_test
|
||||
PUBLIC taos
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
PUBLIC os
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
sml_test
|
||||
PUBLIC taos
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue