From 4cb7b369ac3a803779eb434b6f33b115e4512fbe Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 17 Nov 2022 16:11:42 +0800 Subject: [PATCH] refactor: suppress one error. --- source/libs/executor/src/scanoperator.c | 45 ++++++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index d2e59ea8e1..96e31e69e1 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -337,9 +337,13 @@ static void doSetTagColumnData(STableScanInfo* pTableScanInfo, SSDataBlock* pBlo int32_t code = addTagPseudoColumnData(&pTableScanInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pBlock, rows, GET_TASKID(pTaskInfo), &pTableScanInfo->metaCache); - if (code != TSDB_CODE_SUCCESS) { + // ignore the table not exists error, since this table may have been dropped during the scan procedure. + if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_TDB_TABLE_NOT_EXIST) { T_LONG_JMP(pTaskInfo->env, code); } + + // reset the error code. + terrno = 0; } } @@ -513,6 +517,21 @@ static void freeTableCachedVal(void* param) { taosMemoryFree(pVal); } +static STableCachedVal* createTableCacheVal(const SMetaReader* pMetaReader) { + STableCachedVal* pVal = taosMemoryMalloc(sizeof(STableCachedVal)); + pVal->pName = strdup(pMetaReader->me.name); + pVal->pTags = NULL; + + // only child table has tag value + if (pMetaReader->me.type == TSDB_CHILD_TABLE) { + STag* pTag = (STag*) pMetaReader->me.ctbEntry.pTags; + pVal->pTags = taosMemoryMalloc(pTag->len); + memcpy(pVal->pTags, pTag, pTag->len); + } + + return pVal; +} + // const void *key, size_t keyLen, void *value static void freeCachedMetaItem(const void* key, size_t keyLen, void* value) { freeTableCachedVal(value); } @@ -540,7 +559,11 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int metaReaderInit(&mr, pHandle->meta, 0); code = metaGetTableEntryByUid(&mr, pBlock->info.uid); if (code != TSDB_CODE_SUCCESS) { - qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + if (code == TSDB_CODE_TDB_TABLE_NOT_EXIST) { + qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + } else { + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + } metaReaderClear(&mr); return terrno; } @@ -559,23 +582,18 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int metaReaderInit(&mr, pHandle->meta, 0); code = metaGetTableEntryByUid(&mr, pBlock->info.uid); if (code != TSDB_CODE_SUCCESS) { - qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + if (code == TSDB_CODE_TDB_TABLE_NOT_EXIST) { + qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + } else { + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.uid, tstrerror(terrno), idStr); + } metaReaderClear(&mr); return terrno; } metaReaderReleaseLock(&mr); - STableCachedVal* pVal = taosMemoryMalloc(sizeof(STableCachedVal)); - pVal->pName = strdup(mr.me.name); - pVal->pTags = NULL; - - // only child table has tag value - if (mr.me.type == TSDB_CHILD_TABLE) { - STag* pTag = (STag*)mr.me.ctbEntry.pTags; - pVal->pTags = taosMemoryMalloc(pTag->len); - memcpy(pVal->pTags, mr.me.ctbEntry.pTags, pTag->len); - } + STableCachedVal* pVal = createTableCacheVal(&mr); val = *pVal; freeReader = true; @@ -590,6 +608,7 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int pCache->cacheHit += 1; STableCachedVal* pVal = taosLRUCacheValue(pCache->pTableMetaEntryCache, h); val = *pVal; + taosLRUCacheRelease(pCache->pTableMetaEntryCache, h, false); }