diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 39c3a6c42d5980a95e6e80296f82cde49cb1f38c..1f5d6c60e4b6028dd4bd10b3abdc5dba2dfe87ee 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -19,9 +19,13 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) { memset(pReader, 0, sizeof(*pReader)); pReader->flags = flags; pReader->pMeta = pMeta; + metaRLock(pMeta); } void metaReaderClear(SMetaReader *pReader) { + if (pReader->pMeta) { + metaULock(pReader->pMeta); + } tDecoderClear(&pReader->coder); tdbFree(pReader->pBuf); } diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 7663047429297ce99b0142700bc8d7d87679d208..20248f39fb26c33bcef9e336d46493f10a7f9336 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -439,29 +439,36 @@ _exit: } static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) { + metaWLock(pMeta); + // save to table.db - if (metaSaveToTbDb(pMeta, pME) < 0) return -1; + if (metaSaveToTbDb(pMeta, pME) < 0) goto _err; // update uid.idx - if (metaUpdateUidIdx(pMeta, pME) < 0) return -1; + if (metaUpdateUidIdx(pMeta, pME) < 0) goto _err; // update name.idx - if (metaUpdateNameIdx(pMeta, pME) < 0) return -1; + if (metaUpdateNameIdx(pMeta, pME) < 0) goto _err; if (pME->type == TSDB_CHILD_TABLE) { // update ctb.idx - if (metaUpdateCtbIdx(pMeta, pME) < 0) return -1; + if (metaUpdateCtbIdx(pMeta, pME) < 0) goto _err; // update tag.idx - if (metaUpdateTagIdx(pMeta, pME) < 0) return -1; + if (metaUpdateTagIdx(pMeta, pME) < 0) goto _err; } else { // update schema.db - if (metaSaveToSkmDb(pMeta, pME) < 0) return -1; + if (metaSaveToSkmDb(pMeta, pME) < 0) goto _err; } if (pME->type != TSDB_SUPER_TABLE) { - if (metaUpdateTtlIdx(pMeta, pME) < 0) return -1; + if (metaUpdateTtlIdx(pMeta, pME) < 0) goto _err; } + metaULock(pMeta); return 0; + +_err: + metaULock(pMeta); + return -1; } \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 4638066935637bb502dee4831475e6861f667fc7..2511e3a570677db0f0ebee27cfe0b04a893d348a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -3870,6 +3870,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch if (metaGetTableEntryByUid(&mr, uid) < 0) { tsdbError("%p failed to get stable, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId, reqId); + metaReaderClear(&mr); terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; goto _error; } else { @@ -3880,6 +3881,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch tsdbError("%p query normal tag not allowed, uid:%" PRIu64 ", TID:0x%" PRIx64 " QID:0x%" PRIx64, pMeta, uid, taskId, reqId); terrno = TSDB_CODE_OPS_NOT_SUPPORT; // basically, this error is caused by invalid sql issued by client + metaReaderClear(&mr); goto _error; }