From df76d0ade29c03100322c56c121d7c43882328bd Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Fri, 2 Sep 2022 15:34:44 +0800 Subject: [PATCH] fix: rlock for meta uid index querying from query related threads --- source/dnode/vnode/src/meta/metaQuery.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 7df355a59b..9cbacd4e36 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -129,10 +129,16 @@ _err: bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) { // query uid.idx + metaRLock(pMeta); + if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), NULL, NULL) < 0) { + metaULock(pMeta); + return false; } + metaULock(pMeta); + return true; } @@ -182,9 +188,14 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) { } int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) { + int code = 0; SMetaReader mr = {0}; metaReaderInit(&mr, (SMeta *)meta, 0); - metaGetTableEntryByUid(&mr, uid); + code = metaGetTableEntryByUid(&mr, uid); + if (code < 0) { + metaReaderClear(&mr); + return -1; + } STR_TO_VARSTR(tbName, mr.me.name); metaReaderClear(&mr); -- GitLab