From 0417c8facc49fac91d44d9ad64991b6003991e95 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 30 Aug 2024 18:34:09 +0800 Subject: [PATCH] fix unit test --- source/libs/index/src/index.c | 6 +++++- source/libs/index/src/indexTfile.c | 8 ++++---- source/libs/index/src/indexUtil.c | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 4fc836b738..d38f4efddb 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -569,10 +569,11 @@ static int32_t idxMayMergeTempToFinalRslt(SArray* result, TFileValue* tfv, SIdxT indexFatal("failed to merge result since %s", tstrerror(code)); } } else { - return TSDB_CODE_INVALID_PARA; + return 0; } } else { if (taosArrayPush(result, &tfv) == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; } } return code; @@ -736,6 +737,9 @@ _exception: idxPost(sIdx); } idxReleaseRef(sIdx->refId); + if (code != 0) { + indexError("failed to merge since %s", tstrerror(code)); + } return code; } diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index cdaa5bfb7c..55a9bb06d9 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -133,9 +133,10 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) { int32_t sz = idxSerialCacheKey(&key, buf); code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); if (code != 0) { - tfileReaderRef(reader); + tfileReaderDestroy(reader); goto End; } + tfileReaderRef(reader); } taosArrayDestroyEx(files, tfileDestroyFileName); return tcache; @@ -172,6 +173,7 @@ TFileReader* tfileCacheGet(TFileCache* tcache, ICacheKey* key) { return *reader; } + int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) { int32_t code = 0; @@ -192,9 +194,7 @@ int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) { } code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*)); - if (code == 0) { - tfileReaderRef(reader); - } + tfileReaderRef(reader); return code; } int32_t tfileReaderCreate(IFileCtx* ctx, TFileReader** pReader) { diff --git a/source/libs/index/src/indexUtil.c b/source/libs/index/src/indexUtil.c index 9568e18a3e..6a52b7b5a4 100644 --- a/source/libs/index/src/indexUtil.c +++ b/source/libs/index/src/indexUtil.c @@ -214,7 +214,9 @@ int32_t idxTRsltMergeTo(SIdxTRslt *tr, SArray *result) { if (taosArrayGetSize(tr->total) == 0 || taosArrayGetSize(tr->add) == 0) { SArray *t = taosArrayGetSize(tr->total) == 0 ? tr->add : tr->total; - (void)taosArrayAddAll(result, t); + if (taosArrayAddAll(result, t) == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } else { SArray *arrs = taosArrayInit(2, sizeof(void *)); if (arrs == NULL) {