Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
6ef580b4
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6ef580b4
编写于
6月 28, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-777] use multi-threads to open vnodes
上级
99bc6a5f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
10 deletion
+76
-10
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+76
-10
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
6ef580b4
...
...
@@ -39,6 +39,15 @@
#define MPEER_CONTENT_LEN 2000
typedef
struct
{
pthread_t
thread
;
int32_t
threadIndex
;
int32_t
failed
;
int32_t
opened
;
int32_t
vnodeNum
;
int32_t
*
vnodeList
;
}
SOpenVnodeThread
;
void
*
tsDnodeTmr
=
NULL
;
static
void
*
tsStatusTimer
=
NULL
;
static
uint32_t
tsRebootTime
;
...
...
@@ -242,14 +251,33 @@ static int32_t dnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
dnodeOpenVnodes
()
{
static
void
*
dnodeOpenVnode
(
void
*
param
)
{
SOpenVnodeThread
*
pThread
=
param
;
char
vnodeDir
[
TSDB_FILENAME_LEN
*
3
];
int32_t
failed
=
0
;
int32_t
*
vnodeList
=
(
int32_t
*
)
malloc
(
sizeof
(
int32_t
)
*
TSDB_MAX_VNODES
);
int32_t
numOfVnodes
;
int32_t
status
;
status
=
dnodeGetVnodeList
(
vnodeList
,
&
numOfVnodes
);
dDebug
(
"thread:%d, start to open %d vnodes"
,
pThread
->
threadIndex
,
pThread
->
vnodeNum
);
for
(
int32_t
v
=
0
;
v
<
pThread
->
vnodeNum
;
++
v
)
{
int32_t
vgId
=
pThread
->
vnodeList
[
v
];
snprintf
(
vnodeDir
,
TSDB_FILENAME_LEN
*
3
,
"%s/vnode%d"
,
tsVnodeDir
,
vgId
);
if
(
vnodeOpen
(
vgId
,
vnodeDir
)
<
0
)
{
dError
(
"vgId:%d, failed to open vnode by thread:%d"
,
vgId
,
pThread
->
threadIndex
);
pThread
->
failed
++
;
}
else
{
dDebug
(
"vgId:%d, is openned by thread:%d"
,
vgId
,
pThread
->
threadIndex
);
pThread
->
opened
++
;
}
}
dDebug
(
"thread:%d, total vnodes:%d, openned:%d failed:%d"
,
pThread
->
threadIndex
,
pThread
->
vnodeNum
,
pThread
->
opened
,
pThread
->
failed
);
return
NULL
;
}
static
int32_t
dnodeOpenVnodes
()
{
int32_t
*
vnodeList
=
calloc
(
TSDB_MAX_VNODES
,
sizeof
(
int32_t
));
int32_t
numOfVnodes
;
int32_t
status
=
dnodeGetVnodeList
(
vnodeList
,
&
numOfVnodes
);
if
(
status
!=
TSDB_CODE_SUCCESS
)
{
dInfo
(
"Get dnode list failed"
);
...
...
@@ -257,13 +285,51 @@ static int32_t dnodeOpenVnodes() {
return
status
;
}
for
(
int32_t
i
=
0
;
i
<
numOfVnodes
;
++
i
)
{
snprintf
(
vnodeDir
,
TSDB_FILENAME_LEN
*
3
,
"%s/vnode%d"
,
tsVnodeDir
,
vnodeList
[
i
]);
if
(
vnodeOpen
(
vnodeList
[
i
],
vnodeDir
)
<
0
)
failed
++
;
int32_t
threadNum
=
tsNumOfCores
;
int32_t
vnodesPerThread
=
numOfVnodes
/
threadNum
+
1
;
SOpenVnodeThread
*
threads
=
calloc
(
threadNum
,
sizeof
(
SOpenVnodeThread
));
for
(
int32_t
t
=
0
;
t
<
threadNum
;
++
t
)
{
threads
[
t
].
threadIndex
=
t
;
threads
[
t
].
vnodeList
=
calloc
(
vnodesPerThread
,
sizeof
(
int32_t
));
}
for
(
int32_t
v
=
0
;
v
<
numOfVnodes
;
++
v
)
{
int32_t
t
=
v
%
threadNum
;
SOpenVnodeThread
*
pThread
=
&
threads
[
t
];
pThread
->
vnodeList
[
pThread
->
vnodeNum
++
]
=
vnodeList
[
v
];
}
dInfo
(
"start %d threads to open %d vnodes"
,
threadNum
,
numOfVnodes
);
for
(
int32_t
t
=
0
;
t
<
threadNum
;
++
t
)
{
SOpenVnodeThread
*
pThread
=
&
threads
[
t
];
if
(
pThread
->
vnodeNum
==
0
)
continue
;
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
pThread
->
thread
,
&
thAttr
,
dnodeOpenVnode
,
pThread
)
!=
0
)
{
dError
(
"thread:%d, failed to create thread to open vnode, reason:%s"
,
pThread
->
threadIndex
,
strerror
(
errno
));
}
pthread_attr_destroy
(
&
thAttr
);
}
int32_t
openVnodes
=
0
;
int32_t
failedVnodes
=
0
;
for
(
int32_t
t
=
0
;
t
<
threadNum
;
++
t
)
{
SOpenVnodeThread
*
pThread
=
&
threads
[
t
];
if
(
pThread
->
thread
)
{
pthread_join
(
pThread
->
thread
,
NULL
);
}
openVnodes
+=
pThread
->
opened
;
failedVnodes
+=
pThread
->
failed
;
free
(
pThread
->
vnodeList
);
}
free
(
vnodeList
);
dInfo
(
"there are total vnodes:%d, openned:%d failed:%d"
,
numOfVnodes
,
numOfVnodes
-
failed
,
failed
);
dInfo
(
"there are total vnodes:%d, openned:%d failed:%d"
,
numOfVnodes
,
openVnodes
,
failedVnodes
);
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录