From 9a410b96efd9d216a666c24ef89236b5d25aeac1 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 10 Oct 2022 15:04:33 +0800 Subject: [PATCH] fix(query): new META_READER_NOLOCK flag for metaReaderInit --- source/dnode/vnode/inc/vnode.h | 2 ++ source/dnode/vnode/src/meta/metaQuery.c | 6 ++++-- source/libs/executor/src/scanoperator.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index ba16bad7cf..9926c5a8c4 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -91,6 +91,8 @@ typedef struct SMeta SMeta; // todo: remove typedef struct SMetaReader SMetaReader; typedef struct SMetaEntry SMetaEntry; +#define META_READER_NOLOCK 0x1 + void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags); void metaReaderClear(SMetaReader *pReader); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index d6c8b12f87..1b5d25974e 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -19,11 +19,13 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) { memset(pReader, 0, sizeof(*pReader)); pReader->flags = flags; pReader->pMeta = pMeta; - metaRLock(pMeta); + if (!(flags & META_READER_NOLOCK)) { + metaRLock(pMeta); + } } void metaReaderClear(SMetaReader *pReader) { - if (pReader->pMeta) { + if (pReader->pMeta && !(pReader->flags & META_READER_NOLOCK)) { metaULock(pReader->pMeta); } tDecoderClear(&pReader->coder); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index b055ba1ce5..76f45a1cef 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -2757,7 +2757,7 @@ static SSDataBlock* sysTableScanUserTables(SOperatorInfo* pOperator) { colDataAppend(pColInfoData, numOfRows, (char*)&ts, false); SMetaReader mr = {0}; - metaReaderInit(&mr, pInfo->readHandle.meta, 0); + metaReaderInit(&mr, pInfo->readHandle.meta, META_READER_NOLOCK); uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid; int32_t code = metaGetTableEntryByUid(&mr, suid); -- GitLab