Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
51d81f08
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
51d81f08
编写于
3月 02, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add stat info
上级
3fd02e19
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
117 addition
and
127 deletion
+117
-127
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+58
-87
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+9
-3
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+18
-4
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+18
-16
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+14
-17
未找到文件。
source/libs/catalog/inc/catalogInt.h
浏览文件 @
51d81f08
...
...
@@ -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)
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
51d81f08
...
...
@@ -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
));
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
51d81f08
...
...
@@ -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
;
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
51d81f08
...
...
@@ -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
);
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
51d81f08
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录