Merge pull request #26811 from taosdata/enh/TD-30987-19

enh: add more check return
This commit is contained in:
Hongze Cheng 2024-07-28 16:23:35 +08:00 committed by GitHub
commit 52d07c7916
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 142 additions and 77 deletions

View File

@ -2899,7 +2899,6 @@ static FORCE_INLINE SMqRebInfo* tNewSMqRebSubscribe(const char* key) {
} }
pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t)); pRebInfo->newConsumers = taosArrayInit(0, sizeof(int64_t));
if (pRebInfo->newConsumers == NULL) { if (pRebInfo->newConsumers == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
} }
return pRebInfo; return pRebInfo;
@ -3455,7 +3454,9 @@ static FORCE_INLINE void* taosDecodeSMqTopicInfoMsg(void* buf, SMqTopicInfo* pTo
buf = taosDecodeStringTo(buf, pTopicInfo->name); buf = taosDecodeStringTo(buf, pTopicInfo->name);
int32_t sz; int32_t sz;
buf = taosDecodeFixedI32(buf, &sz); buf = taosDecodeFixedI32(buf, &sz);
pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqReportVgInfo)); if ((pTopicInfo->pVgInfo = taosArrayInit(sz, sizeof(SMqReportVgInfo))) == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
SMqReportVgInfo vgInfo; SMqReportVgInfo vgInfo;
buf = taosDecodeSMqVgInfo(buf, &vgInfo); buf = taosDecodeSMqVgInfo(buf, &vgInfo);
@ -3493,7 +3494,9 @@ static FORCE_INLINE void* taosDecodeSMqReportMsg(void* buf, SMqReportReq* pMsg)
buf = taosDecodeFixedI64(buf, &pMsg->consumerId); buf = taosDecodeFixedI64(buf, &pMsg->consumerId);
int32_t sz; int32_t sz;
buf = taosDecodeFixedI32(buf, &sz); buf = taosDecodeFixedI32(buf, &sz);
pMsg->pTopics = taosArrayInit(sz, sizeof(SMqTopicInfo)); if ((pMsg->pTopics = taosArrayInit(sz, sizeof(SMqTopicInfo))) == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
SMqTopicInfo topicInfo; SMqTopicInfo topicInfo;
buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo); buf = taosDecodeSMqTopicInfoMsg(buf, &topicInfo);

View File

@ -459,7 +459,7 @@ int32_t tRowBuildFromBind(SBindInfo *infos, int32_t numOfInfos, bool infoSorted,
SColVal colVal; SColVal colVal;
if ((colValArray = taosArrayInit(numOfInfos, sizeof(SColVal))) == NULL) { if ((colValArray = taosArrayInit(numOfInfos, sizeof(SColVal))) == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
for (int32_t iRow = 0; iRow < numOfRows; iRow++) { for (int32_t iRow = 0; iRow < numOfRows; iRow++) {
@ -670,7 +670,7 @@ static int32_t tRowMergeImpl(SArray *aRowP, STSchema *pTSchema, int32_t iStart,
// merge // merge
aColVal = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal)); aColVal = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal));
if (aColVal == NULL) { if (aColVal == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto _exit; goto _exit;
} }
@ -1748,7 +1748,7 @@ int32_t tTagToValArray(const STag *pTag, SArray **ppArray) {
(*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal)); (*ppArray) = taosArrayInit(pTag->nTag + 1, sizeof(STagVal));
if (*ppArray == NULL) { if (*ppArray == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = terrno;
goto _err; goto _err;
} }

View File

@ -1069,9 +1069,12 @@ int32_t metaFilterCreateTime(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
if (count > TRY_ERROR_LIMIT) break; if (count > TRY_ERROR_LIMIT) break;
int32_t cmp = (*param->filterFunc)((void *)&p->btime, (void *)&pBtimeKey->btime, param->type); int32_t cmp = (*param->filterFunc)((void *)&p->btime, (void *)&pBtimeKey->btime, param->type);
if (cmp == 0) if (cmp == 0) {
taosArrayPush(pUids, &p->uid); if (taosArrayPush(pUids, &p->uid) == NULL) {
else { ret = terrno;
break;
}
} else {
if (param->equal == true) { if (param->equal == true) {
if (count > TRY_ERROR_LIMIT) break; if (count > TRY_ERROR_LIMIT) break;
count++; count++;
@ -1132,7 +1135,10 @@ int32_t metaFilterTableName(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
cmp = (*param->filterFunc)(pTableKey, pName, pCursor->type); cmp = (*param->filterFunc)(pTableKey, pName, pCursor->type);
if (cmp == 0) { if (cmp == 0) {
tb_uid_t tuid = *(tb_uid_t *)pEntryVal; tb_uid_t tuid = *(tb_uid_t *)pEntryVal;
taosArrayPush(pUids, &tuid); if (taosArrayPush(pUids, &tuid) == NULL) {
ret = terrno;
goto END;
}
} else { } else {
if (param->equal == true) { if (param->equal == true) {
if (count > TRY_ERROR_LIMIT) break; if (count > TRY_ERROR_LIMIT) break;
@ -1328,7 +1334,10 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
} else { } else {
tuid = *(tb_uid_t *)(p->data + tDataTypes[pCursor->type].bytes); tuid = *(tb_uid_t *)(p->data + tDataTypes[pCursor->type].bytes);
} }
taosArrayPush(pUids, &tuid); if (taosArrayPush(pUids, &tuid) == NULL) {
ret = terrno;
break;
}
found = true; found = true;
} else { } else {
if (param->equal == true) { if (param->equal == true) {
@ -1432,7 +1441,11 @@ int32_t metaGetTableTags(void *pVnode, uint64_t suid, SArray *pUidTagInfo) {
STUidTagInfo info = {.uid = uid, .pTagVal = pCur->pVal}; STUidTagInfo info = {.uid = uid, .pTagVal = pCur->pVal};
info.pTagVal = taosMemoryMalloc(pCur->vLen); info.pTagVal = taosMemoryMalloc(pCur->vLen);
memcpy(info.pTagVal, pCur->pVal, pCur->vLen); memcpy(info.pTagVal, pCur->pVal, pCur->vLen);
taosArrayPush(pUidTagInfo, &info); if (taosArrayPush(pUidTagInfo, &info) == NULL) {
metaCloseCtbCursor(pCur);
taosHashCleanup(pSepecifiedUidMap);
return TSDB_CODE_OUT_OF_MEMORY;
}
} }
} else { // only the specified tables need to be added } else { // only the specified tables need to be added
while (1) { while (1) {

View File

@ -341,7 +341,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
break; break;
} }
taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid)); (void)taosArrayPush(tbUidList, &(((SCtbIdxKey *)pKey)->uid));
} }
tdbTbcClose(pCtbIdxc); tdbTbcClose(pCtbIdxc);
@ -405,7 +405,7 @@ static void metaGetSubtables(SMeta *pMeta, int64_t suid, SArray *uids) {
break; break;
} }
taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid)); (void)taosArrayPush(uids, &(((SCtbIdxKey *)pKey)->uid));
} }
tdbFree(pKey); tdbFree(pKey);
@ -1033,7 +1033,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
} }
if ((type == TSDB_CHILD_TABLE || type == TSDB_NORMAL_TABLE) && tbUids) { if ((type == TSDB_CHILD_TABLE || type == TSDB_NORMAL_TABLE) && tbUids) {
taosArrayPush(tbUids, &uid); (void)taosArrayPush(tbUids, &uid);
if (!TSDB_CACHE_NO(pMeta->pVnode->config)) { if (!TSDB_CACHE_NO(pMeta->pVnode->config)) {
tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL); tsdbCacheDropTable(pMeta->pVnode->pTsdb, uid, suid, NULL);
@ -1135,7 +1135,7 @@ static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
tbFName[TSDB_TABLE_FNAME_LEN] = '\0'; tbFName[TSDB_TABLE_FNAME_LEN] = '\0';
int32_t ret = vnodeValidateTableHash(pMeta->pVnode, tbFName); int32_t ret = vnodeValidateTableHash(pMeta->pVnode, tbFName);
if (ret < 0 && terrno == TSDB_CODE_VND_HASH_MISMATCH) { if (ret < 0 && terrno == TSDB_CODE_VND_HASH_MISMATCH) {
taosArrayPush(uidList, &me.uid); (void)taosArrayPush(uidList, &me.uid);
} }
} }
tDecoderClear(&dc); tDecoderClear(&dc);
@ -1783,11 +1783,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
} else { } else {
memcpy(&val.i64, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal); memcpy(&val.i64, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal);
} }
taosArrayPush(pTagArray, &val); (void)taosArrayPush(pTagArray, &val);
} else { } else {
STagVal val = {.cid = pCol->colId}; STagVal val = {.cid = pCol->colId};
if (tTagGet(pOldTag, &val)) { if (tTagGet(pOldTag, &val)) {
taosArrayPush(pTagArray, &val); (void)taosArrayPush(pTagArray, &val);
} }
} }
} }
@ -2171,7 +2171,7 @@ static int metaDropTagIndex(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterT
} }
SMetaPair pair = {.key = pKey, nKey = nKey}; SMetaPair pair = {.key = pKey, nKey = nKey};
taosArrayPush(tagIdxList, &pair); (void)taosArrayPush(tagIdxList, &pair);
} }
tdbTbcClose(pTagIdxc); tdbTbcClose(pTagIdxc);

View File

@ -770,7 +770,11 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) {
STFileSet *fset; STFileSet *fset;
TARRAY2_FOREACH(fs->fSetArr, fset) { TARRAY2_FOREACH(fs->fSetArr, fset) {
if (fset->channelOpened) { if (fset->channelOpened) {
taosArrayPush(channelArray, &fset->channel); if (taosArrayPush(channelArray, &fset->channel) == NULL) {
taosArrayDestroy(channelArray);
taosThreadMutexUnlock(&pTsdb->mutex);
return terrno;
}
fset->channel = (SVAChannelID){0}; fset->channel = (SVAChannelID){0};
fset->mergeScheduled = false; fset->mergeScheduled = false;
tsdbFSSetBlockCommit(fset, false); tsdbFSSetBlockCommit(fset, false);

View File

@ -88,6 +88,9 @@ int32_t ensureBlockScanInfoBuf(SBlockInfoBuf* pBuf, int32_t numOfTables) {
int32_t remainder = (numOfTables - pBuf->numOfTables) % pBuf->numPerBucket; int32_t remainder = (numOfTables - pBuf->numOfTables) % pBuf->numPerBucket;
if (pBuf->pData == NULL) { if (pBuf->pData == NULL) {
pBuf->pData = taosArrayInit(num + 1, POINTER_BYTES); pBuf->pData = taosArrayInit(num + 1, POINTER_BYTES);
if (pBuf->pData == NULL) {
return terrno;
}
} }
for (int32_t i = 0; i < num; ++i) { for (int32_t i = 0; i < num; ++i) {
@ -163,22 +166,22 @@ int32_t initRowKey(SRowKey* pKey, int64_t ts, int32_t numOfPks, int32_t type, in
if (IS_NUMERIC_TYPE(type)) { if (IS_NUMERIC_TYPE(type)) {
if (asc) { if (asc) {
switch(type) { switch (type) {
case TSDB_DATA_TYPE_BIGINT: { case TSDB_DATA_TYPE_BIGINT: {
pKey->pks[0].val = INT64_MIN; pKey->pks[0].val = INT64_MIN;
break; break;
} }
case TSDB_DATA_TYPE_INT:{ case TSDB_DATA_TYPE_INT: {
int32_t min = INT32_MIN; int32_t min = INT32_MIN;
(void)memcpy(&pKey->pks[0].val, &min, tDataTypes[type].bytes); (void)memcpy(&pKey->pks[0].val, &min, tDataTypes[type].bytes);
break; break;
} }
case TSDB_DATA_TYPE_SMALLINT:{ case TSDB_DATA_TYPE_SMALLINT: {
int16_t min = INT16_MIN; int16_t min = INT16_MIN;
(void)memcpy(&pKey->pks[0].val, &min, tDataTypes[type].bytes); (void)memcpy(&pKey->pks[0].val, &min, tDataTypes[type].bytes);
break; break;
} }
case TSDB_DATA_TYPE_TINYINT:{ case TSDB_DATA_TYPE_TINYINT: {
int8_t min = INT8_MIN; int8_t min = INT8_MIN;
(void)memcpy(&pKey->pks[0].val, &min, tDataTypes[type].bytes); (void)memcpy(&pKey->pks[0].val, &min, tDataTypes[type].bytes);
break; break;
@ -194,15 +197,31 @@ int32_t initRowKey(SRowKey* pKey, int64_t ts, int32_t numOfPks, int32_t type, in
ASSERT(0); ASSERT(0);
} }
} else { } else {
switch(type) { switch (type) {
case TSDB_DATA_TYPE_BIGINT:pKey->pks[0].val = INT64_MAX;break; case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_INT:pKey->pks[0].val = INT32_MAX;break; pKey->pks[0].val = INT64_MAX;
case TSDB_DATA_TYPE_SMALLINT:pKey->pks[0].val = INT16_MAX;break; break;
case TSDB_DATA_TYPE_TINYINT:pKey->pks[0].val = INT8_MAX;break; case TSDB_DATA_TYPE_INT:
case TSDB_DATA_TYPE_UBIGINT:pKey->pks[0].val = UINT64_MAX;break; pKey->pks[0].val = INT32_MAX;
case TSDB_DATA_TYPE_UINT:pKey->pks[0].val = UINT32_MAX;break; break;
case TSDB_DATA_TYPE_USMALLINT:pKey->pks[0].val = UINT16_MAX;break; case TSDB_DATA_TYPE_SMALLINT:
case TSDB_DATA_TYPE_UTINYINT:pKey->pks[0].val = UINT8_MAX;break; pKey->pks[0].val = INT16_MAX;
break;
case TSDB_DATA_TYPE_TINYINT:
pKey->pks[0].val = INT8_MAX;
break;
case TSDB_DATA_TYPE_UBIGINT:
pKey->pks[0].val = UINT64_MAX;
break;
case TSDB_DATA_TYPE_UINT:
pKey->pks[0].val = UINT32_MAX;
break;
case TSDB_DATA_TYPE_USMALLINT:
pKey->pks[0].val = UINT16_MAX;
break;
case TSDB_DATA_TYPE_UTINYINT:
pKey->pks[0].val = UINT8_MAX;
break;
default: default:
ASSERT(0); ASSERT(0);
} }
@ -232,7 +251,7 @@ void clearRowKey(SRowKey* pKey) {
taosMemoryFreeClear(pKey->pks[0].pData); taosMemoryFreeClear(pKey->pks[0].pData);
} }
static int32_t initLastProcKey(STableBlockScanInfo *pScanInfo, STsdbReader* pReader) { static int32_t initLastProcKey(STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
int32_t code = 0; int32_t code = 0;
int32_t numOfPks = pReader->suppInfo.numOfPks; int32_t numOfPks = pReader->suppInfo.numOfPks;
bool asc = ASCENDING_TRAVERSE(pReader->info.order); bool asc = ASCENDING_TRAVERSE(pReader->info.order);
@ -448,8 +467,8 @@ void cleanupInfoForNextFileset(SSHashObj* pTableMap) {
// brin records iterator // brin records iterator
void initBrinRecordIter(SBrinRecordIter* pIter, SDataFileReader* pReader, SArray* pList) { void initBrinRecordIter(SBrinRecordIter* pIter, SDataFileReader* pReader, SArray* pList) {
(void) memset(&pIter->block, 0, sizeof(SBrinBlock)); (void)memset(&pIter->block, 0, sizeof(SBrinBlock));
(void) memset(&pIter->record, 0, sizeof(SBrinRecord)); (void)memset(&pIter->record, 0, sizeof(SBrinRecord));
pIter->blockIndex = -1; pIter->blockIndex = -1;
pIter->recordIndex = -1; pIter->recordIndex = -1;
@ -471,7 +490,7 @@ int32_t getNextBrinRecord(SBrinRecordIter* pIter, SBrinRecord** pRecord) {
return TSDB_CODE_INVALID_PARA; return TSDB_CODE_INVALID_PARA;
} }
(void) tBrinBlockClear(&pIter->block); (void)tBrinBlockClear(&pIter->block);
int32_t code = tsdbDataFileReadBrinBlock(pIter->pReader, pIter->pCurrentBlk, &pIter->block); int32_t code = tsdbDataFileReadBrinBlock(pIter->pReader, pIter->pCurrentBlk, &pIter->block);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tsdbError("failed to read brinBlock from file, code:%s", tstrerror(code)); tsdbError("failed to read brinBlock from file, code:%s", tstrerror(code));
@ -488,7 +507,7 @@ int32_t getNextBrinRecord(SBrinRecordIter* pIter, SBrinRecord** pRecord) {
return code; return code;
} }
void clearBrinBlockIter(SBrinRecordIter* pIter) { (void) tBrinBlockDestroy(&pIter->block); } void clearBrinBlockIter(SBrinRecordIter* pIter) { (void)tBrinBlockDestroy(&pIter->block); }
// initialize the file block access order // initialize the file block access order
// sort the file blocks according to the offset of each data block in the files // sort the file blocks according to the offset of each data block in the files
@ -658,7 +677,7 @@ int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIter, int3
STableBlockScanInfo* pTableScanInfo = taosArrayGetP(pTableList, 0); STableBlockScanInfo* pTableScanInfo = taosArrayGetP(pTableList, 0);
for (int32_t i = 0; i < numOfBlocks; ++i) { for (int32_t i = 0; i < numOfBlocks; ++i) {
STableDataBlockIdx tableDataBlockIdx = {.globalIndex = i}; STableDataBlockIdx tableDataBlockIdx = {.globalIndex = i};
void* px = taosArrayPush(pTableScanInfo->pBlockIdxList, &tableDataBlockIdx); void* px = taosArrayPush(pTableScanInfo->pBlockIdxList, &tableDataBlockIdx);
if (px == NULL) { if (px == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -774,6 +793,9 @@ static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_
if (pScanInfo->pFileDelData == NULL) { if (pScanInfo->pFileDelData == NULL) {
pScanInfo->pFileDelData = taosArrayInit(4, sizeof(SDelData)); pScanInfo->pFileDelData = taosArrayInit(4, sizeof(SDelData));
if (pScanInfo->pFileDelData == NULL) {
return terrno;
}
} }
for (int32_t k = 0; k < pBlock->numOfRecords; ++k) { for (int32_t k = 0; k < pBlock->numOfRecords; ++k) {
@ -810,6 +832,9 @@ static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_
if (pScanInfo->pFileDelData == NULL) { if (pScanInfo->pFileDelData == NULL) {
pScanInfo->pFileDelData = taosArrayInit(4, sizeof(SDelData)); pScanInfo->pFileDelData = taosArrayInit(4, sizeof(SDelData));
if (pScanInfo->pFileDelData == NULL) {
return terrno;
}
} }
} }
@ -821,7 +846,7 @@ static int32_t doCheckTombBlock(STombBlock* pBlock, STsdbReader* pReader, int32_
if (record.version <= pReader->info.verRange.maxVer) { if (record.version <= pReader->info.verRange.maxVer) {
SDelData delData = {.version = record.version, .sKey = record.skey, .eKey = record.ekey}; SDelData delData = {.version = record.version, .sKey = record.skey, .eKey = record.ekey};
void* px = taosArrayPush(pScanInfo->pFileDelData, &delData); void* px = taosArrayPush(pScanInfo->pFileDelData, &delData);
if (px == NULL) { if (px == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -878,7 +903,7 @@ static int32_t doLoadTombDataFromTombBlk(const TTombBlkArray* pTombBlkArray, STs
ETombBlkCheckEnum ret = 0; ETombBlkCheckEnum ret = 0;
code = doCheckTombBlock(&block, pReader, numOfTables, &j, &ret); code = doCheckTombBlock(&block, pReader, numOfTables, &j, &ret);
(void) tTombBlockDestroy(&block); (void)tTombBlockDestroy(&block);
if (code != TSDB_CODE_SUCCESS || ret == BLK_CHECK_QUIT) { if (code != TSDB_CODE_SUCCESS || ret == BLK_CHECK_QUIT) {
return code; return code;
} }
@ -977,7 +1002,7 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
SStatisBlk* p = &pStatisBlkArray->data[i]; SStatisBlk* p = &pStatisBlkArray->data[i];
STbStatisBlock* pStatisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock)); STbStatisBlock* pStatisBlock = taosMemoryCalloc(1, sizeof(STbStatisBlock));
(void) tStatisBlockInit(pStatisBlock); (void)tStatisBlockInit(pStatisBlock);
int64_t st = taosGetTimestampMs(); int64_t st = taosGetTimestampMs();
int32_t code = tsdbSttFileReadStatisBlock(pSttFileReader, p, pStatisBlock); int32_t code = tsdbSttFileReadStatisBlock(pSttFileReader, p, pStatisBlock);
@ -995,7 +1020,7 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
} }
if (index >= pStatisBlock->numOfRecords) { if (index >= pStatisBlock->numOfRecords) {
(void) tStatisBlockDestroy(pStatisBlock); (void)tStatisBlockDestroy(pStatisBlock);
taosMemoryFreeClear(pStatisBlock); taosMemoryFreeClear(pStatisBlock);
return num; return num;
} }
@ -1005,7 +1030,7 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
while (i < TARRAY2_SIZE(pStatisBlkArray) && uidIndex < numOfTables) { while (i < TARRAY2_SIZE(pStatisBlkArray) && uidIndex < numOfTables) {
p = &pStatisBlkArray->data[i]; p = &pStatisBlkArray->data[i];
if (p->minTbid.suid > suid) { if (p->minTbid.suid > suid) {
(void) tStatisBlockDestroy(pStatisBlock); (void)tStatisBlockDestroy(pStatisBlock);
taosMemoryFreeClear(pStatisBlock); taosMemoryFreeClear(pStatisBlock);
return num; return num;
} }
@ -1025,7 +1050,7 @@ int32_t getNumOfRowsInSttBlock(SSttFileReader* pSttFileReader, SSttBlockLoadInfo
} }
} }
(void) tStatisBlockDestroy(pStatisBlock); (void)tStatisBlockDestroy(pStatisBlock);
taosMemoryFreeClear(pStatisBlock); taosMemoryFreeClear(pStatisBlock);
return num; return num;
} }
@ -1037,7 +1062,7 @@ static void loadNextStatisticsBlock(SSttFileReader* pSttFileReader, STbStatisBlo
(*i) += 1; (*i) += 1;
(*j) = 0; (*j) = 0;
if ((*i) < TARRAY2_SIZE(pStatisBlkArray)) { if ((*i) < TARRAY2_SIZE(pStatisBlkArray)) {
(void) tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[(*i)], pStatisBlock); (void)tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[(*i)], pStatisBlock);
} }
} }
} }
@ -1049,7 +1074,7 @@ int32_t doAdjustValidDataIters(SArray* pLDIterList, int32_t numOfFileObj) {
int32_t inc = numOfFileObj - size; int32_t inc = numOfFileObj - size;
for (int32_t k = 0; k < inc; ++k) { for (int32_t k = 0; k < inc; ++k) {
SLDataIter* pIter = taosMemoryCalloc(1, sizeof(SLDataIter)); SLDataIter* pIter = taosMemoryCalloc(1, sizeof(SLDataIter));
void* px = taosArrayPush(pLDIterList, &pIter); void* px = taosArrayPush(pLDIterList, &pIter);
if (px == NULL) { if (px == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -1073,6 +1098,9 @@ int32_t adjustSttDataIters(SArray* pSttFileBlockIterArray, STFileSet* pFileSet)
// add the list/iter placeholder // add the list/iter placeholder
while (taosArrayGetSize(pSttFileBlockIterArray) < numOfLevels) { while (taosArrayGetSize(pSttFileBlockIterArray) < numOfLevels) {
SArray* pList = taosArrayInit(4, POINTER_BYTES); SArray* pList = taosArrayInit(4, POINTER_BYTES);
if (pList == NULL) {
return terrno;
}
void* px = taosArrayPush(pSttFileBlockIterArray, &pList); void* px = taosArrayPush(pSttFileBlockIterArray, &pList);
if (px == NULL) { if (px == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
@ -1210,8 +1238,7 @@ static int32_t sortUidComparFn(const void* p1, const void* p2) {
return ret; return ret;
} }
bool isCleanSttBlock(SArray* pKeyRangeList, STimeWindow* pQueryWindow, STableBlockScanInfo* pScanInfo, bool isCleanSttBlock(SArray* pKeyRangeList, STimeWindow* pQueryWindow, STableBlockScanInfo* pScanInfo, int32_t order) {
int32_t order) {
// check if it overlap with del skyline // check if it overlap with del skyline
taosArraySort(pKeyRangeList, sortUidComparFn); taosArraySort(pKeyRangeList, sortUidComparFn);
@ -1242,7 +1269,7 @@ bool isCleanSttBlock(SArray* pKeyRangeList, STimeWindow* pQueryWindow, STableBlo
} }
STimeWindow w2 = {.skey = p2->skey.ts, .ekey = p2->ekey.ts}; STimeWindow w2 = {.skey = p2->skey.ts, .ekey = p2->ekey.ts};
bool overlap = overlapWithTimeWindow(&w2, pQueryWindow, pScanInfo, order); bool overlap = overlapWithTimeWindow(&w2, pQueryWindow, pScanInfo, order);
if (overlap) { if (overlap) {
return false; return false;
} }

View File

@ -1124,7 +1124,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name); sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
if (vnodeValidateTableHash(pVnode, tbName) < 0) { if (vnodeValidateTableHash(pVnode, tbName) < 0) {
cRsp.code = TSDB_CODE_VND_HASH_MISMATCH; cRsp.code = TSDB_CODE_VND_HASH_MISMATCH;
taosArrayPush(rsp.pArray, &cRsp); if (taosArrayPush(rsp.pArray, &cRsp) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
rcode = -1;
goto _exit;
}
vError("vgId:%d create-table:%s failed due to hash value mismatch", TD_VID(pVnode), tbName); vError("vgId:%d create-table:%s failed due to hash value mismatch", TD_VID(pVnode), tbName);
continue; continue;
} }
@ -1139,11 +1143,19 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
} else { } else {
cRsp.code = TSDB_CODE_SUCCESS; cRsp.code = TSDB_CODE_SUCCESS;
tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid);
taosArrayPush(tbUids, &pCreateReq->uid); if (taosArrayPush(tbUids, &pCreateReq->uid) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
rcode = -1;
goto _exit;
}
vnodeUpdateMetaRsp(pVnode, cRsp.pMeta); vnodeUpdateMetaRsp(pVnode, cRsp.pMeta);
} }
taosArrayPush(rsp.pArray, &cRsp); if (taosArrayPush(rsp.pArray, &cRsp) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
rcode = -1;
goto _exit;
}
} }
vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids)); vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids));
@ -1375,12 +1387,20 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
if (tbUid > 0) tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid); if (tbUid > 0) tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid);
} }
taosArrayPush(rsp.pArray, &dropTbRsp); if (taosArrayPush(rsp.pArray, &dropTbRsp) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
pRsp->code = terrno;
goto _exit;
}
if (tsEnableAuditCreateTable) { if (tsEnableAuditCreateTable) {
char *str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); char *str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN);
strcpy(str, pDropTbReq->name); strcpy(str, pDropTbReq->name);
taosArrayPush(tbNames, &str); if (taosArrayPush(tbNames, &str) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
pRsp->code = terrno;
goto _exit;
}
} }
} }
@ -1499,11 +1519,13 @@ static int32_t vnodeResetTableCxt(SMeta *pMeta, SSubmitReqConvertCxt *pCxt) {
taosArrayDestroy(pCxt->pColValues); taosArrayDestroy(pCxt->pColValues);
pCxt->pColValues = taosArrayInit(pCxt->pTbSchema->numOfCols, sizeof(SColVal)); pCxt->pColValues = taosArrayInit(pCxt->pTbSchema->numOfCols, sizeof(SColVal));
if (NULL == pCxt->pColValues) { if (NULL == pCxt->pColValues) {
return TSDB_CODE_OUT_OF_MEMORY; return terrno;
} }
for (int32_t i = 0; i < pCxt->pTbSchema->numOfCols; ++i) { for (int32_t i = 0; i < pCxt->pTbSchema->numOfCols; ++i) {
SColVal val = COL_VAL_NONE(pCxt->pTbSchema->columns[i].colId, pCxt->pTbSchema->columns[i].type); SColVal val = COL_VAL_NONE(pCxt->pTbSchema->columns[i].colId, pCxt->pTbSchema->columns[i].type);
taosArrayPush(pCxt->pColValues, &val); if (taosArrayPush(pCxt->pColValues, &val) == NULL) {
return terrno;
}
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -1819,7 +1841,10 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
goto _exit; goto _exit;
} }
taosArrayPush(newTbUids, &pSubmitTbData->uid); if (taosArrayPush(newTbUids, &pSubmitTbData->uid) == NULL) {
code = terrno;
goto _exit;
}
if (pCreateTbRsp->pMeta) { if (pCreateTbRsp->pMeta) {
vnodeUpdateMetaRsp(pVnode, pCreateTbRsp->pMeta); vnodeUpdateMetaRsp(pVnode, pCreateTbRsp->pMeta);

View File

@ -142,7 +142,9 @@ static int32_t syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
int64_t nowMS = taosGetTimestampMs(); int64_t nowMS = taosGetTimestampMs();
if (nowMS - pStub->createTime > ttl || -1 == ttl) { if (nowMS - pStub->createTime > ttl || -1 == ttl) {
taosArrayPush(delIndexArray, pSeqNum); if (taosArrayPush(delIndexArray, pSeqNum) == NULL) {
return terrno;
}
cnt++; cnt++;
SFsmCbMeta cbMeta = { SFsmCbMeta cbMeta = {

View File

@ -1366,11 +1366,6 @@ static int tdbBtreeDecodePayload(SPage *pPage, const SCell *pCell, int nHeader,
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
/*
if (pDecoder->ofps) {
taosArrayPush(pDecoder->ofps, &ofp);
}
*/
ofpCell = tdbPageGetCell(ofp, 0); ofpCell = tdbPageGetCell(ofp, 0);
if (nLeft <= ofp->maxLocal - sizeof(SPgno)) { if (nLeft <= ofp->maxLocal - sizeof(SPgno)) {
@ -1411,11 +1406,6 @@ static int tdbBtreeDecodePayload(SPage *pPage, const SCell *pCell, int nHeader,
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
/*
if (pDecoder->ofps) {
taosArrayPush(pDecoder->ofps, &ofp);
}
*/
ofpCell = tdbPageGetCell(ofp, 0); ofpCell = tdbPageGetCell(ofp, 0);
int lastKeyPage = 0; int lastKeyPage = 0;
@ -1642,7 +1632,10 @@ static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell, int dropOfp, TXN *
SArray *ofps = pPage->pPager->ofps; SArray *ofps = pPage->pPager->ofps;
if (ofps) { if (ofps) {
taosArrayPush(ofps, &ofp); if (taosArrayPush(ofps, &ofp) == NULL) {
ASSERT(0);
return terrno;
}
} }
tdbPagerReturnPage(pPage->pPager, ofp, pTxn); tdbPagerReturnPage(pPage->pPager, ofp, pTxn);

View File

@ -34,14 +34,12 @@ SArray* taosArrayInit(size_t size, size_t elemSize) {
SArray* pArray = taosMemoryMalloc(sizeof(SArray)); SArray* pArray = taosMemoryMalloc(sizeof(SArray));
if (pArray == NULL) { if (pArray == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
pArray->size = 0; pArray->size = 0;
pArray->pData = taosMemoryCalloc(size, elemSize); pArray->pData = taosMemoryCalloc(size, elemSize);
if (pArray->pData == NULL) { if (pArray->pData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFree(pArray); taosMemoryFree(pArray);
return NULL; return NULL;
} }

View File

@ -169,7 +169,7 @@ TdThread doRegisterCacheObj(SCacheObj *pCacheObj) {
taosThreadOnce(&cacheThreadInit, doInitRefreshThread); taosThreadOnce(&cacheThreadInit, doInitRefreshThread);
taosThreadMutexLock(&guard); taosThreadMutexLock(&guard);
taosArrayPush(pCacheArrayList, &pCacheObj); (void)taosArrayPush(pCacheArrayList, &pCacheObj);
taosThreadMutexUnlock(&guard); taosThreadMutexUnlock(&guard);
return cacheRefreshWorker; return cacheRefreshWorker;

View File

@ -326,7 +326,7 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr
ASSERT(shard->usage >= old->totalCharge); ASSERT(shard->usage >= old->totalCharge);
shard->usage -= old->totalCharge; shard->usage -= old->totalCharge;
taosArrayPush(deleted, &old); (void)taosArrayPush(deleted, &old);
} }
} }
@ -392,7 +392,7 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *
if (shard->usage + e->totalCharge > shard->capacity && (shard->strictCapacity || handle == NULL)) { if (shard->usage + e->totalCharge > shard->capacity && (shard->strictCapacity || handle == NULL)) {
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
if (handle == NULL) { if (handle == NULL) {
taosArrayPush(lastReferenceList, &e); (void)taosArrayPush(lastReferenceList, &e);
} else { } else {
if (freeOnFail) { if (freeOnFail) {
taosMemoryFree(e); taosMemoryFree(e);
@ -415,7 +415,7 @@ static LRUStatus taosLRUCacheShardInsertEntry(SLRUCacheShard *shard, SLRUEntry *
ASSERT(shard->usage >= old->totalCharge); ASSERT(shard->usage >= old->totalCharge);
shard->usage -= old->totalCharge; shard->usage -= old->totalCharge;
taosArrayPush(lastReferenceList, &old); (void)taosArrayPush(lastReferenceList, &old);
} }
} }
if (handle == NULL) { if (handle == NULL) {
@ -536,7 +536,7 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
ASSERT(shard->usage >= old->totalCharge); ASSERT(shard->usage >= old->totalCharge);
shard->usage -= old->totalCharge; shard->usage -= old->totalCharge;
taosArrayPush(lastReferenceList, &old); (void)taosArrayPush(lastReferenceList, &old);
} }
(void)taosThreadMutexUnlock(&shard->mutex); (void)taosThreadMutexUnlock(&shard->mutex);