fix get table meta without meta lock

This commit is contained in:
wangjiaming0909 2024-05-14 15:20:49 +08:00
parent c87ced12b6
commit 876ea12bfa
1 changed files with 11 additions and 1 deletions

View File

@ -3226,14 +3226,24 @@ int32_t ctgGetTbTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, int32_t dbIdx
// get tb cache
pName = taosArrayGet(pList, i);
pTbCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname));
if (!pTbCache || !pTbCache->pMeta) {
if (!pTbCache) {
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
continue;
}
CTG_LOCK(CTG_READ, &pTbCache->metaLock);
if (!pTbCache->pMeta) {
CTG_UNLOCK(CTG_READ, &pTbCache->metaLock);
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
taosHashRelease(dbCache->tbCache, pTbCache);
continue;
}
uint64_t suid = pTbCache->pMeta->suid;
int8_t tbType = pTbCache->pMeta->tableType;
CTG_UNLOCK(CTG_READ, &pTbCache->metaLock);
taosHashRelease(dbCache->tbCache, pTbCache);
SName tsmaSourceTbName = *pName;