提交 51d81f08 编写于 作者: D dapan1121

fix: add stat info

上级 3fd02e19
......@@ -56,10 +56,9 @@ typedef enum {
CTG_CI_CTABLE_META,
CTG_CI_SYSTABLE_META,
CTG_CI_OTHERTABLE_META,
CTG_CI_TBL_INDEX,
CTG_CI_TBL_HASH_VGROUP,
CTG_CI_TBL_SMA,
CTG_CI_TBL_CFG,
CTG_CI_SMA,
CTG_CI_INDEX_INFO,
CTG_CI_USER,
CTG_CI_UDF,
CTG_CI_SVR_VER,
......@@ -99,9 +98,9 @@ typedef enum {
CTG_TASK_GET_DB_INFO,
CTG_TASK_GET_TB_META,
CTG_TASK_GET_TB_HASH,
CTG_TASK_GET_TB_INDEX,
CTG_TASK_GET_TB_SMA_INDEX,
CTG_TASK_GET_TB_CFG,
CTG_TASK_GET_INDEX,
CTG_TASK_GET_INDEX_INFO,
CTG_TASK_GET_UDF,
CTG_TASK_GET_USER,
CTG_TASK_GET_SVR_VER,
......@@ -214,12 +213,13 @@ typedef struct SCtgVgCache {
} SCtgVgCache;
typedef struct SCtgDBCache {
SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads
uint64_t dbId;
int8_t deleted;
SCtgVgCache vgCache;
SHashObj* tbCache; // key:tbname, value:SCtgTbCache
SHashObj* stbCache; // key:suid, value:char*
SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads
uint64_t dbId;
int8_t deleted;
SCtgVgCache vgCache;
SHashObj* tbCache; // key:tbname, value:SCtgTbCache
SHashObj* stbCache; // key:suid, value:char*
uint64_t dbCacheNum[CTG_CI_MAX_VALUE];
} SCtgDBCache;
typedef struct SCtgRentSlot {
......@@ -246,12 +246,13 @@ typedef struct SCtgUserAuth {
} SCtgUserAuth;
typedef struct SCatalog {
uint64_t clusterId;
bool stopUpdate;
SHashObj* userCache; // key:user, value:SCtgUserAuth
SHashObj* dbCache; // key:dbname, value:SCtgDBCache
SCtgRentMgmt dbRent;
SCtgRentMgmt stbRent;
uint64_t clusterId;
bool stopUpdate;
SHashObj* userCache; // key:user, value:SCtgUserAuth
SHashObj* dbCache; // key:dbname, value:SCtgDBCache
SCtgRentMgmt dbRent;
SCtgRentMgmt stbRent;
SCtgCacheStat cacheStat;
} SCatalog;
typedef struct SCtgBatch {
......@@ -508,118 +509,88 @@ typedef struct SCtgOperation {
#define CTG_STAT_DEC(_item, _n) atomic_sub_fetch_64(&(_item), _n)
#define CTG_STAT_GET(_item) atomic_load_64(&(_item))
#define CTG_RT_STAT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.runtime.item, n))
#define CTG_CACHE_STAT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.item, n))
#define CTG_CACHE_STAT_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.item, n))
#define CTG_CACHE_NUM_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.cacheNum[item], n))
#define CTG_CACHE_NUM_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.cacheNum[item], n))
#define CTG_CACHE_HIT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.cacheHit[item], n))
#define CTG_CACHE_HIT_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.cacheHit[item], n))
#define CTG_CACHE_NHIT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.cacheNHit[item], n))
#define CTG_CACHE_NHIT_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.cacheNHit[item], n))
#define CTG_META_NUM_INC(type, n) do { \
#define CTG_DB_NUM_INC(_item) dbCache->dbCacheNum[_itme] += 1
#define CTG_DB_NUM_DEC(_item) dbCache->dbCacheNum[_itme] -= 1
#define CTG_DB_NUM_SET(_item) dbCache->dbCacheNum[_itme] = 1
#define CTG_DB_NUM_RESET(_item) dbCache->dbCacheNum[_itme] = 0
#define CTG_STAT_API_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.api.item, n))
#define CTG_STAT_RT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.runtime.item, n))
#define CTG_STAT_NUM_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.cacheNum[item], n))
#define CTG_STAT_NUM_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.cacheNum[item], n))
#define CTG_STAT_HIT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.cacheHit[item], n))
#define CTG_STAT_HIT_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.cacheHit[item], n))
#define CTG_STAT_NHIT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.cacheNHit[item], n))
#define CTG_STAT_NHIT_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.cacheNHit[item], n))
#define CTG_CACHE_NUM_INC(item, n) (CTG_STAT_INC(pCtg->stat.cache.cacheNum[item], n))
#define CTG_CACHE_NUM_DEC(item, n) (CTG_STAT_DEC(pCtg->stat.cache.cacheNum[item], n))
#define CTG_CACHE_HIT_INC(item, n) (CTG_STAT_INC(pCtg->stat.cache.cacheHit[item], n))
#define CTG_CACHE_HIT_DEC(item, n) (CTG_STAT_DEC(pCtg->stat.cache.cacheHit[item], n))
#define CTG_CACHE_NHIT_INC(item, n) (CTG_STAT_INC(pCtg->stat.cache.cacheNHit[item], n))
#define CTG_CACHE_NHIT_DEC(item, n) (CTG_STAT_DEC(pCtg->stat.cache.cacheNHit[item], n))
#define CTG_META_NUM_INC(type) do { \
switch (type) { \
case TSDB_SUPER_TABLE: \
CTG_CACHE_NUM_INC(CTG_CI_STABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_STABLE_META, 1); \
break; \
case TSDB_CHILD_TABLE: \
CTG_CACHE_NUM_INC(CTG_CI_CTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_CTABLE_META, 1); \
break; \
case TSDB_NORMAL_TABLE: \
CTG_CACHE_NUM_INC(CTG_CI_NTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_NTABLE_META, 1); \
break; \
case TSDB_SYSTEM_TABLE: \
CTG_CACHE_NUM_INC(CTG_CI_SYSTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_SYSTABLE_META, 1); \
break; \
default: \
CTG_CACHE_NUM_INC(CTG_CI_OTHERTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_OTHERTABLE_META, 1); \
break; \
} \
} while (0)
#define CTG_META_NUM_DEC(type, n) do { \
#define CTG_META_NUM_DEC(type) do { \
switch (type) { \
case TSDB_SUPER_TABLE: \
CTG_CACHE_NUM_DEC(CTG_CI_STABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_STABLE_META, 1); \
break; \
case TSDB_CHILD_TABLE: \
CTG_CACHE_NUM_DEC(CTG_CI_CTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_CTABLE_META, 1); \
break; \
case TSDB_NORMAL_TABLE: \
CTG_CACHE_NUM_DEC(CTG_CI_NTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_NTABLE_META, 1); \
break; \
case TSDB_SYSTEM_TABLE: \
CTG_CACHE_NUM_DEC(CTG_CI_SYSTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_SYSTABLE_META, 1); \
break; \
default: \
CTG_CACHE_NUM_DEC(CTG_CI_OTHERTABLE_META, n); \
CTG_DB_NUM_INC(CTG_CI_OTHERTABLE_META, 1); \
break; \
} \
} while (0)
#define CTG_META_HIT_INC(type, n) do { \
switch (type) { \
case TSDB_SUPER_TABLE: \
CTG_CACHE_HIT_INC(CTG_CI_STABLE_META, n); \
break; \
case TSDB_CHILD_TABLE: \
CTG_CACHE_HIT_INC(CTG_CI_CTABLE_META, n); \
break; \
case TSDB_NORMAL_TABLE: \
CTG_CACHE_HIT_INC(CTG_CI_NTABLE_META, n); \
break; \
case TSDB_SYSTEM_TABLE: \
CTG_CACHE_HIT_INC(CTG_CI_SYSTABLE_META, n); \
break; \
default: \
CTG_CACHE_HIT_INC(CTG_CI_OTHERTABLE_META, n); \
break; \
} \
} while (0)
#define CTG_META_HIT_DEC(type, n) do { \
#define CTG_META_HIT_INC(type) do { \
switch (type) { \
case TSDB_SUPER_TABLE: \
CTG_CACHE_HIT_DEC(CTG_CI_STABLE_META, n); \
CTG_CACHE_HIT_INC(CTG_CI_STABLE_META, 1); \
break; \
case TSDB_CHILD_TABLE: \
CTG_CACHE_HIT_DEC(CTG_CI_CTABLE_META, n); \
CTG_CACHE_HIT_INC(CTG_CI_CTABLE_META, 1); \
break; \
case TSDB_NORMAL_TABLE: \
CTG_CACHE_HIT_DEC(CTG_CI_NTABLE_META, n); \
CTG_CACHE_HIT_INC(CTG_CI_NTABLE_META, 1); \
break; \
case TSDB_SYSTEM_TABLE: \
CTG_CACHE_HIT_DEC(CTG_CI_SYSTABLE_META, n); \
CTG_CACHE_HIT_INC(CTG_CI_SYSTABLE_META, 1); \
break; \
default: \
CTG_CACHE_HIT_DEC(CTG_CI_OTHERTABLE_META, n); \
CTG_CACHE_HIT_INC(CTG_CI_OTHERTABLE_META, 1); \
break; \
} \
} while (0)
#define CTG_META_NHIT_INC(n) CTG_CACHE_NHIT_INC(CTG_CI_OTHERTABLE_META, n)
#define CTG_META_NHIT_DEC(type, n) do { \
switch (type) { \
case TSDB_SUPER_TABLE: \
CTG_CACHE_NHIT_DEC(CTG_CI_STABLE_META, n); \
break; \
case TSDB_CHILD_TABLE: \
CTG_CACHE_NHIT_DEC(CTG_CI_CTABLE_META, n); \
break; \
case TSDB_NORMAL_TABLE: \
CTG_CACHE_NHIT_DEC(CTG_CI_NTABLE_META, n); \
break; \
case TSDB_SYSTEM_TABLE: \
CTG_CACHE_NHIT_DEC(CTG_CI_SYSTABLE_META, n); \
break; \
default: \
CTG_CACHE_NHIT_DEC(CTG_CI_OTHERTABLE_META, n); \
break; \
} \
} while (0)
#define CTG_META_NHIT_INC() CTG_CACHE_NHIT_INC(CTG_CI_OTHERTABLE_META, 1)
#define CTG_IS_META_NULL(type) ((type) == META_TYPE_NULL_TABLE)
......
......@@ -721,12 +721,12 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
if (ctg && (*ctg)) {
*catalogHandle = *ctg;
CTG_CACHE_HIT_INC(CTG_CI_CLUSTER, 1);
CTG_STAT_HIT_INC(CTG_CI_CLUSTER, 1);
qDebug("got catalog handle from cache, clusterId:0x%" PRIx64 ", CTG:%p", clusterId, *ctg);
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
}
CTG_CACHE_NHIT_INC(CTG_CI_CLUSTER, 1);
CTG_STAT_NHIT_INC(CTG_CI_CLUSTER, 1);
clusterCtg = taosMemoryCalloc(1, sizeof(SCatalog));
if (NULL == clusterCtg) {
......@@ -771,7 +771,7 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) {
*catalogHandle = clusterCtg;
CTG_CACHE_NUM_INC(CTG_CI_CLUSTER, 1);
CTG_STAT_NUM_INC(CTG_CI_CLUSTER, 1);
CTG_API_LEAVE(TSDB_CODE_SUCCESS);
......@@ -1393,6 +1393,8 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbF
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
}
CTG_CACHE_NHIT_INC(CTG_CI_DB_CFG, 1);
CTG_API_LEAVE(ctgGetDBCfgFromMnode(pCtg, pConn, dbFName, pDbCfg, NULL));
}
......@@ -1445,6 +1447,8 @@ int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* f
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
}
CTG_CACHE_NHIT_INC(CTG_CI_UDF, 1);
int32_t code = 0;
CTG_ERR_JRET(ctgGetUdfInfoFromMnode(pCtg, pConn, funcName, pInfo, NULL));
......@@ -1493,6 +1497,8 @@ int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo* pConn, char**
CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT);
}
CTG_CACHE_NHIT_INC(CTG_CI_SVR_VER, 1);
int32_t code = 0;
CTG_ERR_JRET(ctgGetSvrVerFromMnode(pCtg, pConn, pVersion, NULL));
......
......@@ -241,7 +241,7 @@ int32_t ctgInitGetIndexTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
char* name = (char*)param;
SCtgTask task = {0};
task.type = CTG_TASK_GET_INDEX;
task.type = CTG_TASK_GET_INDEX_INFO;
task.taskId = taskIdx;
task.pJob = pJob;
......@@ -330,7 +330,7 @@ int32_t ctgInitGetTbIndexTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
SName* name = (SName*)param;
SCtgTask task = {0};
task.type = CTG_TASK_GET_TB_INDEX;
task.type = CTG_TASK_GET_TB_SMA_INDEX;
task.taskId = taskIdx;
task.pJob = pJob;
......@@ -596,7 +596,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
for (int32_t i = 0; i < tbIndexNum; ++i) {
SName* name = taosArrayGet(pReq->pTableIndex, i);
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_INDEX, name, NULL));
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_SMA_INDEX, name, NULL));
}
for (int32_t i = 0; i < tbCfgNum; ++i) {
......@@ -606,7 +606,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
for (int32_t i = 0; i < indexNum; ++i) {
char* indexName = taosArrayGet(pReq->pIndex, i);
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_INDEX, indexName, NULL));
CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_INDEX_INFO, indexName, NULL));
}
for (int32_t i = 0; i < udfNum; ++i) {
......@@ -1925,6 +1925,8 @@ int32_t ctgLaunchGetTbCfgTask(SCtgTask* pTask) {
pMsgCtx->pBatchs = pJob->pBatchs;
}
CTG_CACHE_NHIT_INC(CTG_CI_TBL_CFG, 1);
if (pCtx->tbType <= 0) {
CTG_ERR_JRET(ctgReadTbTypeFromCache(pCtg, dbFName, pCtx->pName->tname, &pCtx->tbType));
if (pCtx->tbType <= 0) {
......@@ -1996,6 +1998,8 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask* pTask) {
pMsgCtx->pBatchs = pJob->pBatchs;
}
CTG_CACHE_NHIT_INC(CTG_CI_DB_CFG, 1);
CTG_ERR_RET(ctgGetDBCfgFromMnode(pCtg, pConn, pCtx->dbFName, NULL, pTask));
return TSDB_CODE_SUCCESS;
......@@ -2025,10 +2029,14 @@ int32_t ctgLaunchGetDbInfoTask(SCtgTask* pTask) {
pInfo->tbNum = dbCache->vgCache.vgInfo->numOfTable;
pInfo->stateTs = dbCache->vgCache.vgInfo->stateTs;
CTG_CACHE_HIT_INC(CTG_CI_DB_INFO, 1);
ctgReleaseVgInfoToCache(pCtg, dbCache);
dbCache = NULL;
} else {
pInfo->vgVer = CTG_DEFAULT_INVALID_VERSION;
CTG_CACHE_NHIT_INC(CTG_CI_DB_INFO, 1);
}
CTG_ERR_JRET(ctgHandleTaskEnd(pTask, 0));
......@@ -2048,6 +2056,8 @@ int32_t ctgLaunchGetIndexTask(SCtgTask* pTask) {
pMsgCtx->pBatchs = pJob->pBatchs;
}
CTG_CACHE_NHIT_INC(CTG_CI_INDEX_INFO, 1);
CTG_ERR_RET(ctgGetIndexInfoFromMnode(pCtg, pConn, pCtx->indexFName, NULL, pTask));
return TSDB_CODE_SUCCESS;
......@@ -2063,6 +2073,8 @@ int32_t ctgLaunchGetUdfTask(SCtgTask* pTask) {
pMsgCtx->pBatchs = pJob->pBatchs;
}
CTG_CACHE_NHIT_INC(CTG_CI_UDF, 1);
CTG_ERR_RET(ctgGetUdfInfoFromMnode(pCtg, pConn, pCtx->udfName, NULL, pTask));
return TSDB_CODE_SUCCESS;
......@@ -2106,6 +2118,8 @@ int32_t ctgLaunchGetSvrVerTask(SCtgTask* pTask) {
pMsgCtx->pBatchs = pJob->pBatchs;
}
CTG_CACHE_NHIT_INC(CTG_CI_SVR_VER, 1);
CTG_ERR_RET(ctgGetSvrVerFromMnode(pCtg, pConn, NULL, pTask));
return TSDB_CODE_SUCCESS;
......
......@@ -228,7 +228,7 @@ int32_t ctgAcquireTbMetaFromCache(SCatalog *pCtg, char *dbFName, char *tbName, S
ctgDebug("tb %s meta got in cache, dbFName:%s", tbName, dbFName);
CTG_META_HIT_INC(pCache->pMeta->tableType, 1);
CTG_META_HIT_INC(pCache->pMeta->tableType);
return TSDB_CODE_SUCCESS;
......@@ -236,7 +236,7 @@ _return:
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
CTG_META_NHIT_INC(1);
CTG_META_NHIT_INC();
return TSDB_CODE_SUCCESS;
}
......@@ -269,14 +269,14 @@ int32_t ctgAcquireVgMetaFromCache(SCatalog *pCtg, const char *dbFName, const cha
tbCache = taosHashAcquire(dbCache->tbCache, tbName, strlen(tbName));
if (NULL == tbCache) {
ctgDebug("tb %s not in cache, dbFName:%s", tbName, dbFName);
CTG_META_NHIT_INC(1);
CTG_META_NHIT_INC();
goto _return;
}
CTG_LOCK(CTG_READ, &tbCache->metaLock);
if (NULL == tbCache->pMeta) {
ctgDebug("tb %s meta not in cache, dbFName:%s", tbName, dbFName);
CTG_META_NHIT_INC(1);
CTG_META_NHIT_INC();
goto _return;
}
......@@ -284,7 +284,7 @@ int32_t ctgAcquireVgMetaFromCache(SCatalog *pCtg, const char *dbFName, const cha
ctgDebug("tb %s meta got in cache, dbFName:%s", tbName, dbFName);
CTG_META_HIT_INC(tbCache->pMeta->tableType, 1);
CTG_META_HIT_INC(tbCache->pMeta->tableType);
return TSDB_CODE_SUCCESS;
......@@ -390,7 +390,7 @@ int32_t ctgAcquireStbMetaFromCache(SCtgDBCache *dbCache, SCatalog *pCtg, char *d
ctgDebug("stb 0x%" PRIx64 " meta got in cache, dbFName:%s", suid, dbFName);
CTG_META_HIT_INC(pCache->pMeta->tableType, 1);
CTG_META_HIT_INC(pCache->pMeta->tableType);
return TSDB_CODE_SUCCESS;
......@@ -398,7 +398,7 @@ _return:
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
CTG_META_NHIT_INC(1);
CTG_META_NHIT_INC();
*pTb = NULL;
......@@ -432,7 +432,7 @@ int32_t ctgAcquireTbIndexFromCache(SCatalog *pCtg, char *dbFName, char *tbName,
ctgDebug("tb %s index got in cache, dbFName:%s", tbName, dbFName);
CTG_CACHE_HIT_INC(CTG_CI_TBL_INDEX, 1);
CTG_CACHE_HIT_INC(CTG_CI_TBL_SMA, 1);
return TSDB_CODE_SUCCESS;
......@@ -440,7 +440,7 @@ _return:
ctgReleaseTbIndexToCache(pCtg, dbCache, pCache);
CTG_CACHE_NHIT_INC(CTG_CI_TBL_INDEX, 1);
CTG_CACHE_NHIT_INC(CTG_CI_TBL_SMA, 1);
return TSDB_CODE_SUCCESS;
}
......@@ -1545,7 +1545,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
if (taosHashRemove(dbCache->stbCache, &orig->suid, sizeof(orig->suid))) {
ctgError("stb not exist in stbCache, dbFName:%s, stb:%s, suid:0x%" PRIx64, dbFName, tbName, orig->suid);
} else {
CTG_META_NUM_DEC(origType, 1);
CTG_META_NUM_DEC(origType);
ctgDebug("stb removed from stbCache, dbFName:%s, stb:%s, suid:0x%" PRIx64, dbFName, tbName, orig->suid);
}
}
......@@ -1569,7 +1569,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam
}
if (NULL == orig) {
CTG_META_NUM_INC(pCache->pMeta->tableType, 1);
CTG_META_NUM_INC(pCache->pMeta->tableType);
}
ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType);
......@@ -1616,6 +1616,8 @@ int32_t ctgWriteTbIndexToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNa
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
CTG_DB_NUM_INC(CTG_CI_TBL_SMA);
*index = NULL;
ctgDebug("table %s index updated to cache, ver:%d, num:%d", tbName, pIndex->version,
(int32_t)taosArrayGetSize(pIndex->pIndex));
......@@ -1767,12 +1769,12 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
}
freeVgInfo(vgInfo);
CTG_CACHE_NUM_DEC(CTG_CI_DB_VGROUP, 1);
CTG_DB_NUM_RESET(CTG_CI_DB_VGROUP);
}
vgCache->vgInfo = dbInfo;
msg->dbInfo = NULL;
CTG_CACHE_NUM_INC(CTG_CI_DB_VGROUP, 1);
CTG_DB_NUM_SET(CTG_CI_DB_VGROUP);
ctgDebug("db vgInfo updated, dbFName:%s, vgVer:%d, stateTs:%" PRId64 ", dbId:0x%" PRIx64, dbFName,
vgVersion.vgVersion, vgVersion.stateTs, vgVersion.dbId);
......@@ -1845,7 +1847,7 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
freeVgInfo(dbCache->vgCache.vgInfo);
dbCache->vgCache.vgInfo = NULL;
CTG_CACHE_NUM_DEC(CTG_CI_DB_VGROUP, 1);
CTG_DB_NUM_RESET(CTG_CI_DB_VGROUP);
ctgDebug("db vgInfo removed, dbFName:%s", msg->dbFName);
ctgWUnlockVgInfo(dbCache);
......@@ -1952,7 +1954,7 @@ int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) {
if (taosHashRemove(dbCache->tbCache, msg->stbName, strlen(msg->stbName))) {
ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:0x%" PRIx64, msg->dbFName, msg->stbName, msg->suid);
} else {
CTG_META_NUM_DEC(tblType, 1);
CTG_META_NUM_DEC(tblType);
}
ctgInfo("stb removed from cache, dbFName:%s, stbName:%s, suid:0x%" PRIx64, msg->dbFName, msg->stbName, msg->suid);
......@@ -2005,7 +2007,7 @@ int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) {
ctgError("tb %s not exist in cache, dbFName:%s", msg->tbName, msg->dbFName);
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
} else {
CTG_META_NUM_DEC(tblType, 1);
CTG_META_NUM_DEC(tblType);
}
ctgDebug("table %s removed from cache, dbFName:%s", msg->tbName, msg->dbFName);
......
......@@ -77,12 +77,12 @@ char* ctgTaskTypeStr(CTG_TASK_TYPE type) {
return "[get table meta]";
case CTG_TASK_GET_TB_HASH:
return "[get table hash]";
case CTG_TASK_GET_TB_INDEX:
return "[get table index]";
case CTG_TASK_GET_TB_SMA_INDEX:
return "[get table sma]";
case CTG_TASK_GET_TB_CFG:
return "[get table cfg]";
case CTG_TASK_GET_INDEX:
return "[get index]";
case CTG_TASK_GET_INDEX_INFO:
return "[get index info]";
case CTG_TASK_GET_UDF:
return "[get udf]";
case CTG_TASK_GET_USER:
......@@ -222,9 +222,6 @@ void ctgFreeTbCache(SCtgDBCache* dbCache) {
int32_t tblNum = taosHashGetSize(dbCache->tbCache);
SCtgTbCache* pCache = taosHashIterate(dbCache->tbCache, NULL);
while (NULL != pCache) {
if (pCache->pMeta) {
CTG_META_NUM_DEC(pCache->pMeta->tableType, 1);
}
ctgFreeTbCacheImpl(pCache);
pCache = taosHashIterate(dbCache->tbCache, pCache);
}
......@@ -281,8 +278,6 @@ void ctgFreeInstUserCache(SHashObj* pUserCache) {
}
taosHashCleanup(pUserCache);
CTG_CACHE_NUM_DEC(CTG_CI_USER, userNum);
}
void ctgFreeHandleImpl(SCatalog* pCtg) {
......@@ -308,7 +303,7 @@ void ctgFreeHandle(SCatalog* pCtg) {
ctgFreeInstDbCache(pCtg->dbCache);
ctgFreeInstUserCache(pCtg->userCache);
CTG_CACHE_NUM_DEC(CTG_CI_CLUSTER, 1);
CTG_STAT_NUM_DEC(CTG_CI_CLUSTER, 1);
taosMemoryFree(pCtg);
......@@ -343,7 +338,9 @@ void ctgClearHandle(SCatalog* pCtg) {
ctgError("taosHashInit %d user cache failed", gCtgMgmt.cfg.maxUserCacheNum);
}
CTG_RT_STAT_INC(numOfOpClearCache, 1);
memset(pCtg->cacheStat.cacheNum, 0, sizeof(pCtg->cacheStat.cacheNum));
CTG_STAT_RT_INC(numOfOpClearCache, 1);
ctgInfo("handle cleared, clusterId:0x%" PRIx64, clusterId);
}
......@@ -502,7 +499,7 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) {
}
break;
}
case CTG_TASK_GET_TB_INDEX: {
case CTG_TASK_GET_TB_SMA_INDEX: {
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
*pRes = NULL;
break;
......@@ -517,7 +514,7 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) {
}
case CTG_TASK_GET_TB_HASH:
case CTG_TASK_GET_DB_INFO:
case CTG_TASK_GET_INDEX:
case CTG_TASK_GET_INDEX_INFO:
case CTG_TASK_GET_UDF:
case CTG_TASK_GET_USER:
case CTG_TASK_GET_SVR_VER:
......@@ -572,7 +569,7 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void** pRes) {
}
break;
}
case CTG_TASK_GET_TB_INDEX: {
case CTG_TASK_GET_TB_SMA_INDEX: {
taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo);
*pRes = NULL;
break;
......@@ -588,7 +585,7 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void** pRes) {
case CTG_TASK_GET_TB_META:
case CTG_TASK_GET_DB_INFO:
case CTG_TASK_GET_TB_HASH:
case CTG_TASK_GET_INDEX:
case CTG_TASK_GET_INDEX_INFO:
case CTG_TASK_GET_UDF:
case CTG_TASK_GET_SVR_VER:
case CTG_TASK_GET_USER: {
......@@ -665,7 +662,7 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
taosMemoryFreeClear(pTask->taskCtx);
break;
}
case CTG_TASK_GET_TB_INDEX: {
case CTG_TASK_GET_TB_SMA_INDEX: {
SCtgTbIndexCtx* taskCtx = (SCtgTbIndexCtx*)pTask->taskCtx;
taosMemoryFreeClear(taskCtx->pName);
taosMemoryFreeClear(pTask->taskCtx);
......@@ -681,7 +678,7 @@ void ctgFreeTaskCtx(SCtgTask* pTask) {
case CTG_TASK_GET_DB_VGROUP:
case CTG_TASK_GET_DB_CFG:
case CTG_TASK_GET_DB_INFO:
case CTG_TASK_GET_INDEX:
case CTG_TASK_GET_INDEX_INFO:
case CTG_TASK_GET_UDF:
case CTG_TASK_GET_QNODE:
case CTG_TASK_GET_USER: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册