fix(query): fix memory leak.

This commit is contained in:
Haojun Liao 2024-09-06 17:01:17 +08:00
parent 6470cfc26e
commit 6af9f279bc
1 changed files with 12 additions and 11 deletions

View File

@ -408,9 +408,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
for (int32_t k = startIndex; k < endIndex; ++k) { for (int32_t k = startIndex; k < endIndex; ++k) {
code = tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block); code = tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block);
if (code) { QUERY_CHECK_CODE(code, lino, _end);
return code;
}
int32_t i = 0; int32_t i = 0;
int32_t rows = block.numOfRecords; int32_t rows = block.numOfRecords;
@ -536,12 +534,15 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
} }
_end: _end:
(void)tStatisBlockDestroy(&block); (void) tStatisBlockDestroy(&block);
if (code != 0) {
tsdbError("%s error happens at:%s line number: %d, code:%s", id, __FUNCTION__, lino, tstrerror(code));
} else {
double el = (taosGetTimestampUs() - st) / 1000.0;
pBlockLoadInfo->cost.statisElapsedTime += el;
double el = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug("%s load %d statis blocks into buf, elapsed time:%.2fms", id, num, el);
pBlockLoadInfo->cost.statisElapsedTime += el; }
tsdbDebug("%s load %d statis blocks into buf, elapsed time:%.2fms", id, num, el);
return code; return code;
} }
@ -953,6 +954,7 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF
pMTree->pIter = NULL; pMTree->pIter = NULL;
pMTree->backward = pConf->backward; pMTree->backward = pConf->backward;
pMTree->idStr = pConf->idstr; pMTree->idStr = pConf->idstr;
int32_t lino = 0;
if (!pMTree->backward) { // asc if (!pMTree->backward) { // asc
tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn); tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
@ -1027,9 +1029,8 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF
// let's record the time window for current table of uid in the stt files // let's record the time window for current table of uid in the stt files
if (pSttDataInfo != NULL && numOfRows > 0) { if (pSttDataInfo != NULL && numOfRows > 0) {
void *px = taosArrayPush(pSttDataInfo->pKeyRangeList, &range); void *px = taosArrayPush(pSttDataInfo->pKeyRangeList, &range);
if (px == NULL) { QUERY_CHECK_NULL(px, code, lino, _end, terrno);
return terrno;
}
pSttDataInfo->numOfRows += numOfRows; pSttDataInfo->numOfRows += numOfRows;
} }
} else { } else {