fix(tsdb/cache): check array init's retval

This commit is contained in:
Minglei Jin 2024-08-21 18:37:17 +08:00
parent 9b76e216a7
commit 59e2849756
1 changed files with 12 additions and 10 deletions

View File

@ -1413,7 +1413,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr
SIdxKey *idxKey = taosArrayGet(remainCols, 0); SIdxKey *idxKey = taosArrayGet(remainCols, 0);
if (idxKey->key.cid != PRIMARYKEY_TIMESTAMP_COL_ID) { if (idxKey->key.cid != PRIMARYKEY_TIMESTAMP_COL_ID) {
// ignore 'ts' loaded from cache and load it from tsdb // ignore 'ts' loaded from cache and load it from tsdb
SLastCol* pLastCol = taosArrayGet(pLastArray, 0); SLastCol *pLastCol = taosArrayGet(pLastArray, 0);
tsdbCacheUpdateLastColToNone(pLastCol, TSDB_LAST_CACHE_NO_CACHE); tsdbCacheUpdateLastColToNone(pLastCol, TSDB_LAST_CACHE_NO_CACHE);
SLastKey *key = &(SLastKey){.lflag = ltype, .uid = uid, .cid = PRIMARYKEY_TIMESTAMP_COL_ID}; SLastKey *key = &(SLastKey){.lflag = ltype, .uid = uid, .cid = PRIMARYKEY_TIMESTAMP_COL_ID};
@ -1745,12 +1745,12 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
goto _exit; goto _exit;
} }
} }
if (taosArrayPush(remainCols, &(SIdxKey){i, key}) ==NULL) { if (taosArrayPush(remainCols, &(SIdxKey){i, key}) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit; goto _exit;
} }
bool ignoreRocks = pLastCol ? (pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) : false; bool ignoreRocks = pLastCol ? (pLastCol->cacheStatus == TSDB_LAST_CACHE_NO_CACHE) : false;
if (taosArrayPush(ignoreFromRocks, &ignoreRocks) ==NULL) { if (taosArrayPush(ignoreFromRocks, &ignoreRocks) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit; goto _exit;
} }
@ -1802,12 +1802,12 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache
} }
_exit: _exit:
if (remainCols) { if (remainCols) {
taosArrayDestroy(remainCols); taosArrayDestroy(remainCols);
} }
if (ignoreFromRocks) { if (ignoreFromRocks) {
taosArrayDestroy(ignoreFromRocks); taosArrayDestroy(ignoreFromRocks);
} }
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -2368,6 +2368,9 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie
if (!state->pIndexList) { if (!state->pIndexList) {
state->pIndexList = taosArrayInit(1, sizeof(SBrinBlk)); state->pIndexList = taosArrayInit(1, sizeof(SBrinBlk));
if (!state->pIndexList) {
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _err);
}
} else { } else {
taosArrayClear(state->pIndexList); taosArrayClear(state->pIndexList);
} }
@ -2653,7 +2656,6 @@ static int32_t getNextRowFromMem(void *iter, TSDBROW **ppRow, bool *pIgnoreEarli
TAOS_RETURN(code); TAOS_RETURN(code);
} }
default: default:
ASSERT(0);
break; break;
} }