diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index ce57ef3bbd..6ee6985e0c 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -132,8 +132,8 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name); int32_t metaGetCachedTbGroup(void *pVnode, tb_uid_t suid, const uint8_t *pKey, int32_t keyLen, SArray **pList); int32_t metaPutTbGroupToCache(void *pVnode, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload, int32_t payloadLen); -bool metaTbInFilterCache(void *pVnode, void* key, int8_t type); -int32_t metaPutTbToFilterCache(void *pVnode, void* key, int8_t type); +bool metaTbInFilterCache(void *pVnode, const void* key, int8_t type); +int32_t metaPutTbToFilterCache(void *pVnode, const void* key, int8_t type); int32_t metaSizeOfTbFilterCache(void *pVnode, int8_t type); int32_t metaInitTbFilterCache(void *pVnode); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 2fadccdf2d..9929b66932 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -98,6 +98,9 @@ typedef struct SQueryNode SQueryNode; #define VND_INFO_FNAME "vnode.json" #define VND_INFO_FNAME_TMP "vnode_tmp.json" +#define TK_LOG_STB_NUM 19 +#define TK_AUDIT_STB_NUM 1 + // vnd.h typedef int32_t (*_query_reseek_func_t)(void* pQHandle); struct SQueryNode { diff --git a/source/dnode/vnode/src/meta/metaCache.c b/source/dnode/vnode/src/meta/metaCache.c index a4a893c42d..1411285b42 100644 --- a/source/dnode/vnode/src/meta/metaCache.c +++ b/source/dnode/vnode/src/meta/metaCache.c @@ -14,6 +14,11 @@ */ #include "meta.h" +#ifdef TD_ENTERPRISE +extern const char* tkLogStb[]; +extern const char* tkAuditStb[]; +#endif + #define TAG_FILTER_RES_KEY_LEN 32 #define META_CACHE_BASE_BUCKET 1024 #define META_CACHE_STATS_BUCKET 16 @@ -185,9 +190,6 @@ int32_t metaCacheOpen(SMeta* pMeta) { code = TSDB_CODE_OUT_OF_MEMORY; goto _err2; } - if ((code = metaInitTbFilterCache(pMeta->pVnode)) != 0) { - goto _err2; - } pMeta->pCache = pCache; return code; @@ -905,7 +907,7 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) { return TSDB_CODE_SUCCESS; } -bool metaTbInFilterCache(void* pVnode, void* key, int8_t type) { +bool metaTbInFilterCache(void* pVnode, const void* key, int8_t type) { SMeta* pMeta = ((SVnode*)pVnode)->pMeta; if (type == 0 && taosHashGet(pMeta->pCache->STbFilterCache.pStb, key, sizeof(tb_uid_t))) { @@ -919,7 +921,7 @@ bool metaTbInFilterCache(void* pVnode, void* key, int8_t type) { return false; } -int32_t metaPutTbToFilterCache(void* pVnode, void* key, int8_t type) { +int32_t metaPutTbToFilterCache(void* pVnode, const void* key, int8_t type) { SMeta* pMeta = ((SVnode*)pVnode)->pMeta; if (type == 0) { @@ -939,4 +941,30 @@ int32_t metaSizeOfTbFilterCache(void* pVnode, int8_t type) { return taosHashGetSize(pMeta->pCache->STbFilterCache.pStb); } return 0; -} \ No newline at end of file +} + +int32_t metaInitTbFilterCache(void* pVnode) { +#ifdef TD_ENTERPRISE + int32_t tbNum = 0; + const char** pTbArr = NULL; + const char* dbName = NULL; + + if (!(dbName = strchr(((SVnode*)pVnode)->config.dbname, '.'))) return 0; + if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) { + tbNum = TK_LOG_STB_NUM; + pTbArr = (const char**)&tkLogStb; + } else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) { + tbNum = TK_AUDIT_STB_NUM; + pTbArr = (const char**)&tkAuditStb; + } + if (tbNum && pTbArr) { + for (int32_t i = 0; i < tbNum; ++i) { + if (metaPutTbToFilterCache(pVnode, pTbArr[i], 1) != 0) { + return terrno ? terrno : -1; + } + } + } +#else +#endif + return 0; +} diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 0ceeaffa05..d795afde74 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -764,6 +764,8 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs } metaReaderClear(&mr); + bool sysTbl = (pReq->type == TSDB_CHILD_TABLE) && metaTbInFilterCache(pMeta->pVnode, pReq->ctb.stbName, 1); + // build SMetaEntry SVnodeStats *pStats = &pMeta->pVnode->config.vndStats; me.version = ver; @@ -800,8 +802,8 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs #endif ++pStats->numOfCTables; - - if (!metaTbInFilterCache(pMeta->pVnode, pReq->ctb.stbName, 1)) { + + if (!sysTbl) { int32_t nCols = 0; metaGetStbStats(pMeta->pVnode, me.ctbEntry.suid, 0, &nCols); pStats->numOfTimeSeries += nCols - 1; @@ -826,7 +828,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs if (metaHandleEntry(pMeta, &me) < 0) goto _err; - metaTimeSeriesNotifyCheck(pMeta); + if(!sysTbl) metaTimeSeriesNotifyCheck(pMeta); if (pMetaRsp) { *pMetaRsp = taosMemoryCalloc(1, sizeof(STableMetaRsp)); diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index db94f32459..3797941e96 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -399,6 +399,10 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC goto _err; } + if (metaInitTbFilterCache(pVnode) != 0) { + goto _err; + } + if (metaUpgrade(pVnode, &pVnode->pMeta) < 0) { vError("vgId:%d, failed to upgrade meta since %s", TD_VID(pVnode), tstrerror(terrno)); } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 3a8ab824a1..d13d49fccc 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -566,9 +566,7 @@ int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) { } #ifdef TD_ENTERPRISE -#define TK_LOG_STB_NUM 19 -#define TK_AUDIT_STB_NUM 1 -static const char *tkLogStb[TK_LOG_STB_NUM] = {"cluster_info", +const char *tkLogStb[TK_LOG_STB_NUM] = {"cluster_info", "data_dir", "dnodes_info", "d_info", @@ -587,7 +585,7 @@ static const char *tkLogStb[TK_LOG_STB_NUM] = {"cluster_info", "temp_dir", "vgroups_info", "vnodes_role"}; -static const char *tkAuditStb[TK_AUDIT_STB_NUM] = {"operations"}; +const char *tkAuditStb[TK_AUDIT_STB_NUM] = {"operations"}; // exclude stbs of taoskeeper log static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) { @@ -619,32 +617,6 @@ static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) { return tbSize; } - -int32_t metaInitTbFilterCache(void *pVnode) { - int32_t tbNum = 0; - const char **pTbArr = NULL; - const char *dbName = NULL; - - if (!(dbName = strchr(((SVnode *)pVnode)->config.dbname, '.'))) return 0; - if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) { - tbNum = TK_LOG_STB_NUM; - pTbArr = (const char **)&tkLogStb; - } else if (0 == strncmp(dbName, "audit", TSDB_DB_NAME_LEN)) { - tbNum = TK_AUDIT_STB_NUM; - pTbArr = (const char **)&tkAuditStb; - } - if (tbNum && pTbArr) { - for (int32_t i = 0; i < tbNum; ++i) { - if (metaPutTbToFilterCache(pVnode, &pTbArr[i], strlen(pTbArr[i])) != 0) { - return terrno ? terrno : -1; - } - } - } - - return 0; -} -#else -int32_t metaInitTbFilterCache(void *pVnode) { return 0; } #endif static bool vnodeTimeSeriesFilter(void *arg1, void *arg2) {