Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9fcf56a4
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
9fcf56a4
编写于
5月 16, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: support meta cleanup
上级
daedb361
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
45 addition
and
14 deletion
+45
-14
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-1
source/client/src/clientHb.c
source/client/src/clientHb.c
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+1
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+25
-1
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+5
-4
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+9
-5
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+2
-0
未找到文件。
include/libs/catalog/catalog.h
浏览文件 @
9fcf56a4
...
...
@@ -210,7 +210,7 @@ int32_t catalogGetSTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const
int32_t
catalogUpdateTableMeta
(
SCatalog
*
pCatalog
,
STableMetaRsp
*
rspMsg
);
int32_t
catalog
UpdateTableMeta
(
SCatalog
*
pCatalog
,
STableMetaRsp
*
rs
pMsg
);
int32_t
catalog
AsyncUpdateTableMeta
(
SCatalog
*
pCtg
,
STableMetaRsp
*
pMsg
);
int32_t
catalogGetCachedTableMeta
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
);
...
...
source/client/src/clientHb.c
浏览文件 @
9fcf56a4
...
...
@@ -217,7 +217,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
catalogUpdateTableMeta
(
pCatalog
,
rsp
);
catalog
Async
UpdateTableMeta
(
pCatalog
,
rsp
);
}
}
...
...
source/client/src/clientImpl.c
浏览文件 @
9fcf56a4
...
...
@@ -815,7 +815,7 @@ int32_t handleAlterTbExecRes(void* res, SCatalog* pCatalog) {
}
int32_t
handleCreateTbExecRes
(
void
*
res
,
SCatalog
*
pCatalog
)
{
return
catalogUpdateTableMeta
(
pCatalog
,
(
STableMetaRsp
*
)
res
);
return
catalog
Async
UpdateTableMeta
(
pCatalog
,
(
STableMetaRsp
*
)
res
);
}
int32_t
handleQueryExecRsp
(
SRequestObj
*
pRequest
)
{
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
9fcf56a4
...
...
@@ -964,7 +964,7 @@ uint64_t ctgGetDbVgroupCacheSize(SDBVgInfo *pVg);
uint64_t
ctgGetUserCacheSize
(
SGetUserAuthRsp
*
pAuth
);
uint64_t
ctgGetClusterCacheSize
(
SCatalog
*
pCtg
);
void
ctgClearHandleMeta
(
SCatalog
*
pCtg
,
int64_t
*
pClearedSize
,
int64_t
*
pCleardNum
,
bool
*
roundDone
);
void
ctgClearAllHandleMeta
(
bool
*
roundDone
);
void
ctgClearAllHandleMeta
(
int64_t
*
clearedSize
,
int64_t
*
clearedNum
,
bool
*
roundDone
);
void
ctgProcessTimerEvent
(
void
*
param
,
void
*
tmrId
);
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
9fcf56a4
...
...
@@ -647,7 +647,8 @@ void ctgProcessTimerEvent(void *param, void *tmrId) {
goto
_return
;
}
}
qTrace
(
"reset catalog timer"
);
taosTmrReset
(
ctgProcessTimerEvent
,
CTG_DEFAULT_CACHE_MON_MSEC
,
NULL
,
gCtgMgmt
.
timer
,
&
gCtgMgmt
.
cacheTimer
);
_return:
...
...
@@ -1105,6 +1106,22 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogAsyncUpdateTableMeta
(
SCatalog
*
pCtg
,
STableMetaRsp
*
pMsg
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
pMsg
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
code
=
0
;
CTG_ERR_JRET
(
ctgUpdateTbMeta
(
pCtg
,
pMsg
,
false
));
_return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogChkTbMetaVersion
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SArray
*
pTables
)
{
CTG_API_ENTER
();
...
...
@@ -1571,6 +1588,13 @@ void catalogDestroy(void) {
return
;
}
if
(
gCtgMgmt
.
cacheTimer
)
{
taosTmrStop
(
gCtgMgmt
.
cacheTimer
);
gCtgMgmt
.
cacheTimer
=
NULL
;
taosTmrCleanUp
(
gCtgMgmt
.
timer
);
gCtgMgmt
.
timer
=
NULL
;
}
atomic_store_8
((
int8_t
*
)
&
gCtgMgmt
.
exit
,
true
);
if
(
!
taosCheckCurrentInDll
())
{
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
9fcf56a4
...
...
@@ -791,7 +791,7 @@ int32_t ctgEnqueue(SCatalog *pCtg, SCtgCacheOperation *operation) {
CTG_UNLOCK
(
CTG_WRITE
,
&
gCtgMgmt
.
queue
.
qlock
);
ctgDebug
(
"
action [%s] added into queue
"
,
opName
);
ctgDebug
(
"
%sync action [%s] added into queue"
,
syncOp
?
"S"
:
"As
"
,
opName
);
CTG_QUEUE_INC
();
CTG_STAT_RT_INC
(
numOfOpEnqueue
,
1
);
...
...
@@ -2286,21 +2286,22 @@ void ctgClearMetaCache(SCtgCacheOperation *operation) {
if
(
pCtg
)
{
ctgClearHandleMeta
(
pCtg
,
&
clearedSize
,
&
clearedNum
,
&
roundDone
);
}
else
{
ctgClearAllHandleMeta
(
&
roundDone
);
ctgClearAllHandleMeta
(
&
clearedSize
,
&
clearedNum
,
&
roundDone
);
}
qDebug
(
"catalog finish one round meta clear,
done:%d"
,
roundDone
);
qDebug
(
"catalog finish one round meta clear,
clearedSize:%"
PRId64
", clearedNum:%"
PRId64
", done:%d"
,
clearedSize
,
clearedNum
,
roundDone
);
ctgGetGlobalCacheSize
(
&
remainSize
);
int32_t
cacheMaxSize
=
atomic_load_32
(
&
tsMetaCacheMaxSize
);
if
(
!
CTG_CACHE_LOW
(
remainSize
,
cacheMaxSize
))
{
if
(
CTG_CACHE_LOW
(
remainSize
,
cacheMaxSize
))
{
qDebug
(
"catalog finish meta clear, remainSize:%"
PRId64
", cacheMaxSize:%dMB"
,
remainSize
,
cacheMaxSize
);
taosTmrReset
(
ctgProcessTimerEvent
,
CTG_DEFAULT_CACHE_MON_MSEC
,
NULL
,
gCtgMgmt
.
timer
,
&
gCtgMgmt
.
cacheTimer
);
return
;
}
if
(
!
roundDone
)
{
qDebug
(
"catalog all meta cleared, remainSize:%"
PRId64
", cacheMaxSize:%dMB, to clear handle"
,
remainSize
,
cacheMaxSize
);
ctgClearFreeCache
(
operation
);
taosTmrReset
(
ctgProcessTimerEvent
,
CTG_DEFAULT_CACHE_MON_MSEC
,
NULL
,
gCtgMgmt
.
timer
,
&
gCtgMgmt
.
cacheTimer
);
return
;
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
9fcf56a4
...
...
@@ -338,6 +338,7 @@ void ctgClearHandleMeta(SCatalog* pCtg, int64_t *pClearedSize, int64_t *pCleardN
void
*
key
=
taosHashGetKey
(
pCache
,
&
len
);
if
(
pCache
->
pMeta
&&
TSDB_SUPER_TABLE
==
pCache
->
pMeta
->
tableType
)
{
pCache
=
taosHashIterate
(
dbCache
->
tbCache
,
pCache
);
continue
;
}
...
...
@@ -346,10 +347,15 @@ void ctgClearHandleMeta(SCatalog* pCtg, int64_t *pClearedSize, int64_t *pCleardN
atomic_sub_fetch_64
(
&
dbCache
->
dbCacheSize
,
cacheSize
);
*
pClearedSize
+=
cacheSize
;
(
*
pCleardNum
)
++
;
if
(
pCache
->
pMeta
)
{
CTG_META_NUM_DEC
(
pCache
->
pMeta
->
tableType
);
}
ctgFreeTbCacheImpl
(
pCache
,
true
);
if
(
*
pCleardNum
>=
CTG_CLEAR_CACHE_ROUND_TB_NUM
)
{
taosHashCancelIterate
(
dbCache
->
tbCache
,
pCache
);
goto
_return
;
}
...
...
@@ -366,9 +372,7 @@ _return:
}
}
void
ctgClearAllHandleMeta
(
bool
*
roundDone
)
{
int64_t
clearedSize
=
0
;
int64_t
clearedNum
=
0
;
void
ctgClearAllHandleMeta
(
int64_t
*
clearedSize
,
int64_t
*
clearedNum
,
bool
*
roundDone
)
{
SCatalog
*
pCtg
=
NULL
;
void
*
pIter
=
taosHashIterate
(
gCtgMgmt
.
pCluster
,
NULL
);
...
...
@@ -376,7 +380,7 @@ void ctgClearAllHandleMeta(bool *roundDone) {
pCtg
=
*
(
SCatalog
**
)
pIter
;
if
(
pCtg
)
{
ctgClearHandleMeta
(
pCtg
,
&
clearedSize
,
&
clearedNum
,
roundDone
);
ctgClearHandleMeta
(
pCtg
,
clearedSize
,
clearedNum
,
roundDone
);
if
(
*
roundDone
)
{
taosHashCancelIterate
(
gCtgMgmt
.
pCluster
,
pIter
);
break
;
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
9fcf56a4
...
...
@@ -1746,6 +1746,8 @@ TEST(tableMeta, updateStbMeta) {
code
=
catalogUpdateTableMeta
(
pCtg
,
&
rsp
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogAsyncUpdateTableMeta
(
pCtg
,
&
rsp
);
ASSERT_EQ
(
code
,
0
);
taosMemoryFreeClear
(
rsp
.
pSchemas
);
while
(
true
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录