From de113ccf5f5b6c58126faec2e53efd8dae92ae8e Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 11 Oct 2022 17:50:42 +0800 Subject: [PATCH] fix: use stable stats cache to get ctbNum --- source/dnode/vnode/src/meta/metaTable.c | 3 +++ source/dnode/vnode/src/vnd/vnodeQuery.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 361e453303..c8a4ff945d 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -362,6 +362,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { // update uid index metaUpdateUidIdx(pMeta, &nStbEntry); + metaStatsCacheDrop(pMeta, nStbEntry.uid); + metaULock(pMeta); if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); @@ -615,6 +617,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), &pMeta->txn); // drop schema.db (todo) + metaStatsCacheDrop(pMeta, uid); --pMeta->pVnode->config.vndStats.numOfSTables; } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 0d57c7bb74..a78ddbdc19 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -495,8 +495,11 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) { break; } - int64_t ctbNum = 0; - vnodeGetCtbNum(pVnode, id, &ctbNum); + SMetaStbStats stats = {0}; + metaGetStbStats(pVnode->pMeta, id, &stats); + int64_t ctbNum = stats.ctbNum; + // vnodeGetCtbNum(pVnode, id, &ctbNum); + int numOfCols = 0; vnodeGetStbColumnNum(pVnode, id, &numOfCols);