Skip to content

Commit 126c7fa

Browse files
authored
Merge pull request #25771 from taosdata/fix/3.0/TD-30037
fix get table meta without meta lock
2 parents 3c4e9a6 + 876ea12 commit 126c7fa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

source/libs/catalog/src/ctgCache.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -3226,14 +3226,24 @@ int32_t ctgGetTbTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, int32_t dbIdx
32263226
// get tb cache
32273227
pName = taosArrayGet(pList, i);
32283228
pTbCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname));
3229-
if (!pTbCache || !pTbCache->pMeta) {
3229+
if (!pTbCache) {
32303230
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
32313231
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
32323232
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
32333233
continue;
32343234
}
3235+
CTG_LOCK(CTG_READ, &pTbCache->metaLock);
3236+
if (!pTbCache->pMeta) {
3237+
CTG_UNLOCK(CTG_READ, &pTbCache->metaLock);
3238+
ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname);
3239+
ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL);
3240+
taosArrayPush(pCtx->pResList, &(SMetaRes){0});
3241+
taosHashRelease(dbCache->tbCache, pTbCache);
3242+
continue;
3243+
}
32353244
uint64_t suid = pTbCache->pMeta->suid;
32363245
int8_t tbType = pTbCache->pMeta->tableType;
3246+
CTG_UNLOCK(CTG_READ, &pTbCache->metaLock);
32373247
taosHashRelease(dbCache->tbCache, pTbCache);
32383248
SName tsmaSourceTbName = *pName;
32393249

0 commit comments

Comments
 (0)