Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
06c52af2
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
06c52af2
编写于
7月 07, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: exclude tk_log from timeseries check
上级
85782bbf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
130 addition
and
30 deletion
+130
-30
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+4
-1
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+41
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+1
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+2
-2
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+82
-27
未找到文件。
source/dnode/vnode/inc/vnode.h
浏览文件 @
06c52af2
...
...
@@ -124,8 +124,11 @@ int32_t metaUidFilterCachePut(void *pVnode, uint64_t suid, const void *pKey, in
int32_t
payloadLen
,
double
selectivityRatio
);
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
metaPutTbGroupToCache
(
void
*
pVnode
,
uint64_t
suid
,
const
void
*
pKey
,
int32_t
keyLen
,
void
*
pPayload
,
int32_t
payloadLen
);
bool
metaTbInFilterCache
(
void
*
pVnode
,
tb_uid_t
suid
,
int8_t
type
);
int32_t
metaPutTbToFilterCache
(
void
*
pVnode
,
tb_uid_t
suid
,
int8_t
type
);
int32_t
metaSizeOfTbFilterCache
(
void
*
pVnode
,
int8_t
type
);
int32_t
metaGetStbStats
(
void
*
pVnode
,
int64_t
uid
,
int64_t
*
numOfTables
);
...
...
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
06c52af2
...
...
@@ -66,6 +66,10 @@ struct SMetaCache {
SHashObj
*
pTableEntry
;
SLRUCache
*
pResCache
;
}
STbGroupResCache
;
struct
STbFilterCache
{
SHashObj
*
pTkLogStb
;
}
STbFilterCache
;
};
static
void
entryCacheClose
(
SMeta
*
pMeta
)
{
...
...
@@ -168,6 +172,13 @@ int32_t metaCacheOpen(SMeta* pMeta) {
taosHashSetFreeFp
(
pCache
->
STbGroupResCache
.
pTableEntry
,
freeCacheEntryFp
);
taosThreadMutexInit
(
&
pCache
->
STbGroupResCache
.
lock
,
NULL
);
pCache
->
STbFilterCache
.
pTkLogStb
=
taosHashInit
(
0
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
pCache
->
STbFilterCache
.
pTkLogStb
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err2
;
}
pMeta
->
pCache
=
pCache
;
return
code
;
...
...
@@ -193,6 +204,8 @@ void metaCacheClose(SMeta* pMeta) {
taosThreadMutexDestroy
(
&
pMeta
->
pCache
->
STbGroupResCache
.
lock
);
taosHashCleanup
(
pMeta
->
pCache
->
STbGroupResCache
.
pTableEntry
);
taosHashCleanup
(
pMeta
->
pCache
->
STbFilterCache
.
pTkLogStb
);
taosMemoryFree
(
pMeta
->
pCache
);
pMeta
->
pCache
=
NULL
;
}
...
...
@@ -880,3 +893,31 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) {
metaDebug
(
"vgId:%d suid:%"
PRId64
" cached related tb group cleared"
,
vgId
,
suid
);
return
TSDB_CODE_SUCCESS
;
}
bool
metaTbInFilterCache
(
void
*
pVnode
,
tb_uid_t
suid
,
int8_t
type
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
if
(
type
==
0
&&
taosHashGet
(
pMeta
->
pCache
->
STbFilterCache
.
pTkLogStb
,
&
suid
,
sizeof
(
suid
)))
{
return
true
;
}
return
false
;
}
int32_t
metaPutTbToFilterCache
(
void
*
pVnode
,
tb_uid_t
suid
,
int8_t
type
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
if
(
type
==
0
)
{
return
taosHashPut
(
pMeta
->
pCache
->
STbFilterCache
.
pTkLogStb
,
&
suid
,
sizeof
(
suid
),
NULL
,
0
);
}
return
0
;
}
int32_t
metaSizeOfTbFilterCache
(
void
*
pVnode
,
int8_t
type
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
if
(
type
==
0
)
{
return
taosHashGetSize
(
pMeta
->
pCache
->
STbFilterCache
.
pTkLogStb
);
}
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
06c52af2
...
...
@@ -671,6 +671,7 @@ int64_t metaGetTbNum(SMeta *pMeta) {
// N.B. Called by statusReq per second
int64_t
metaGetTimeSeriesNum
(
SMeta
*
pMeta
)
{
fprintf
(
stderr
,
"@@@@@@@ %s:%d called @@@@@@@@@: vgId:%d, second:%d
\n
"
,
__func__
,
__LINE__
,
TD_VID
(
pMeta
->
pVnode
),
taosGetTimestampSec
());
// sum of (number of columns of stable - 1) * number of ctables (excluding timestamp column)
if
(
pMeta
->
pVnode
->
config
.
vndStats
.
numOfTimeSeries
<=
0
||
++
pMeta
->
pVnode
->
config
.
vndStats
.
itvTimeSeries
%
(
60
*
5
)
==
0
)
{
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
06c52af2
...
...
@@ -232,7 +232,7 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
++
pMeta
->
pVnode
->
config
.
vndStats
.
numOfSTables
;
meta
Debug
(
"vgId:%d, stb:%s is created, suid:%"
PRId64
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
suid
);
meta
Error
(
"vgId:%d, stb:%s is created, suid:%"
PRId64
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
suid
);
return
0
;
...
...
@@ -798,7 +798,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
}
}
meta
Debug
(
"vgId:%d, table:%s uid %"
PRId64
" is created, type:%"
PRId8
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
uid
,
meta
Error
(
"vgId:%d, table:%s uid %"
PRId64
" is created, type:%"
PRId8
,
TD_VID
(
pMeta
->
pVnode
),
pReq
->
name
,
pReq
->
uid
,
pReq
->
type
);
return
0
;
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
06c52af2
...
...
@@ -410,9 +410,9 @@ void vnodeResetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
"nBatchInsertSuccess"
);
}
void
vnodeGetInfo
(
void
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
,
int64_t
*
numOfTables
,
int64_t
*
numOfNormalTables
)
{
SVnode
*
pVnodeObj
=
pVnode
;
SVnodeCfg
*
pConf
=
&
pVnodeObj
->
config
;
void
vnodeGetInfo
(
void
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
,
int64_t
*
numOfTables
,
int64_t
*
numOfNormalTables
)
{
SVnode
*
pVnodeObj
=
pVnode
;
SVnodeCfg
*
pConf
=
&
pVnodeObj
->
config
;
if
(
dbname
)
{
*
dbname
=
pConf
->
dbname
;
...
...
@@ -431,7 +431,7 @@ void vnodeGetInfo(void *pVnode, const char **dbname, int32_t *vgId, int64_t* num
}
}
int32_t
vnodeGetTableList
(
void
*
pVnode
,
int8_t
type
,
SArray
*
pList
)
{
int32_t
vnodeGetTableList
(
void
*
pVnode
,
int8_t
type
,
SArray
*
pList
)
{
if
(
type
==
TSDB_SUPER_TABLE
)
{
return
vnodeGetStbIdList
(
pVnode
,
0
,
pList
);
}
else
{
...
...
@@ -531,32 +531,87 @@ static int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
return
TSDB_CODE_SUCCESS
;
}
// #ifndef TD_ENTERPRISE
#define TK_LOG_STB_NUM 19
static
const
char
*
tkLogStb
[
TK_LOG_STB_NUM
]
=
{
"cluster_info"
,
"data_dir"
,
"dnodes_info"
,
"d_info"
,
"grants_info"
,
"keeper_monitor"
,
"logs"
,
"log_dir"
,
"log_summary"
,
"m_info"
,
"taosadapter_restful_http_request_fail"
,
"taosadapter_restful_http_request_in_flight"
,
"taosadapter_restful_http_request_summary_milliseconds"
,
"taosadapter_restful_http_request_total"
,
"taosadapter_system_cpu_percent"
,
"taosadapter_system_mem_percent"
,
"temp_dir"
,
"vgroups_info"
,
"vnodes_role"
};
// exclude stbs of taoskeeper log
static
int32_t
vnodeTimeSeriesFilter
(
SVnode
*
pVnode
,
SArray
*
suidList
)
{
char
*
dbName
=
strchr
(
pVnode
->
config
.
dbname
,
'.'
);
if
(
!
dbName
||
0
!=
strncmp
(
dbName
,
"log"
,
TSDB_DB_NAME_LEN
))
{
goto
_exit
;
}
int32_t
tbSize
=
metaSizeOfTbFilterCache
(
pVnode
,
0
);
if
(
tbSize
<
TK_LOG_STB_NUM
)
{
for
(
int32_t
i
=
0
;
i
<
TK_LOG_STB_NUM
;
++
i
)
{
tb_uid_t
suid
=
metaGetTableEntryUidByName
(
pVnode
->
pMeta
,
tkLogStb
[
i
]);
if
(
suid
!=
0
)
{
metaPutTbToFilterCache
(
pVnode
,
suid
,
0
);
}
}
if
(
metaSizeOfTbFilterCache
(
pVnode
,
0
)
<=
0
)
goto
_exit
;
}
for
(
int64_t
i
=
0
;
i
<
TARRAY_SIZE
(
suidList
);)
{
if
(
metaTbInFilterCache
(
pVnode
,
*
(
tb_uid_t
*
)
TARRAY_GET_ELEM
(
suidList
,
i
),
sizeof
(
tb_uid_t
)))
{
taosArrayRemove
(
suidList
,
i
);
continue
;
}
}
_exit:
return
0
;
}
// #endif
int32_t
vnodeGetTimeSeriesNum
(
SVnode
*
pVnode
,
int64_t
*
num
)
{
SArray
*
suidList
=
NULL
;
if
(
!
(
suidList
=
taosArrayInit
(
1
,
sizeof
(
tb_uid_t
))))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
if
(
vnodeGetStbIdList
(
pVnode
,
0
,
suidList
)
<
0
)
{
qError
(
"vgId:%d, failed to get stb id list error: %s"
,
TD_VID
(
pVnode
),
terrstr
());
taosArrayDestroy
(
suidList
);
return
TSDB_CODE_FAILED
;
qError
(
"vgId:%d, failed to get stb id list error: %s"
,
TD_VID
(
pVnode
),
terrstr
());
taosArrayDestroy
(
suidList
);
return
TSDB_CODE_FAILED
;
}
// #ifdef TD_ENTERPRISE
vnodeTimeSeriesFilter
(
pVnode
,
suidList
);
// #endif
*
num
=
0
;
int64_t
arrSize
=
taosArrayGetSize
(
suidList
);
for
(
int64_t
i
=
0
;
i
<
arrSize
;
++
i
)
{
tb_uid_t
suid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
suidList
,
i
);
tb_uid_t
suid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
suidList
,
i
);
int64_t
ctbNum
=
0
;
metaGetStbStats
(
pVnode
,
suid
,
&
ctbNum
);
int64_t
ctbNum
=
0
;
metaGetStbStats
(
pVnode
,
suid
,
&
ctbNum
);
int
numOfCols
=
0
;
vnodeGetStbColumnNum
(
pVnode
,
suid
,
&
numOfCols
);
int
numOfCols
=
0
;
vnodeGetStbColumnNum
(
pVnode
,
suid
,
&
numOfCols
);
*
num
+=
ctbNum
*
(
numOfCols
-
1
);
*
num
+=
ctbNum
*
(
numOfCols
-
1
);
}
taosArrayDestroy
(
suidList
);
...
...
@@ -566,20 +621,20 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
int32_t
vnodeGetAllCtbNum
(
SVnode
*
pVnode
,
int64_t
*
num
)
{
SMStbCursor
*
pCur
=
metaOpenStbCursor
(
pVnode
->
pMeta
,
0
);
if
(
!
pCur
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
*
num
=
0
;
while
(
1
)
{
tb_uid_t
id
=
metaStbCursorNext
(
pCur
);
if
(
id
==
0
)
{
break
;
}
tb_uid_t
id
=
metaStbCursorNext
(
pCur
);
if
(
id
==
0
)
{
break
;
}
int64_t
ctbNum
=
0
;
vnodeGetCtbNum
(
pVnode
,
id
,
&
ctbNum
);
int64_t
ctbNum
=
0
;
vnodeGetCtbNum
(
pVnode
,
id
,
&
ctbNum
);
*
num
+=
ctbNum
;
*
num
+=
ctbNum
;
}
metaCloseStbCursor
(
pCur
);
...
...
@@ -588,15 +643,15 @@ int32_t vnodeGetAllCtbNum(SVnode *pVnode, int64_t *num) {
void
*
vnodeGetIdx
(
void
*
pVnode
)
{
if
(
pVnode
==
NULL
)
{
return
NULL
;
return
NULL
;
}
return
metaGetIdx
(((
SVnode
*
)
pVnode
)
->
pMeta
);
return
metaGetIdx
(((
SVnode
*
)
pVnode
)
->
pMeta
);
}
void
*
vnodeGetIvtIdx
(
void
*
pVnode
)
{
if
(
pVnode
==
NULL
)
{
return
NULL
;
return
NULL
;
}
return
metaGetIvtIdx
(((
SVnode
*
)
pVnode
)
->
pMeta
);
return
metaGetIvtIdx
(((
SVnode
*
)
pVnode
)
->
pMeta
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录