Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9cf1cb78
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看板
提交
9cf1cb78
编写于
5月 09, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature(udf):move start/stop udfd out of dnode management preparation
上级
98582265
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
21 deletion
+21
-21
source/dnode/mgmt/implement/src/dmHandle.c
source/dnode/mgmt/implement/src/dmHandle.c
+19
-21
source/dnode/mgmt/interface/inc/dmDef.h
source/dnode/mgmt/interface/inc/dmDef.h
+2
-0
未找到文件。
source/dnode/mgmt/implement/src/dmHandle.c
浏览文件 @
9cf1cb78
...
...
@@ -217,20 +217,20 @@ static void dmStopMgmt(SMgmtWrapper *pWrapper) {
dmStopStatusThread
(
pWrapper
->
pDnode
);
}
static
int32_t
dmSpawnUdfd
(
S
Dnode
*
pDnode
);
static
int32_t
dmSpawnUdfd
(
S
UdfdData
*
pData
);
void
dmUdfdExit
(
uv_process_t
*
process
,
int64_t
exitStatus
,
int
termSignal
)
{
dInfo
(
"udfd process exited with status %"
PRId64
", signal %d"
,
exitStatus
,
termSignal
);
S
Dnode
*
pDnode
=
process
->
data
;
if
(
exitStatus
==
0
&&
termSignal
==
0
||
atomic_load_32
(
&
pD
node
->
udfdData
.
stopCalled
))
{
S
UdfdData
*
pData
=
process
->
data
;
if
(
exitStatus
==
0
&&
termSignal
==
0
||
atomic_load_32
(
&
pD
ata
->
stopCalled
))
{
dInfo
(
"udfd process exit due to SIGINT or dnode-mgmt called stop"
);
}
else
{
dInfo
(
"udfd process restart"
);
dmSpawnUdfd
(
pD
node
);
dmSpawnUdfd
(
pD
ata
);
}
}
static
int32_t
dmSpawnUdfd
(
S
Dnode
*
pDnode
)
{
static
int32_t
dmSpawnUdfd
(
S
UdfdData
*
pData
)
{
dInfo
(
"dnode start spawning udfd"
);
uv_process_options_t
options
=
{
0
};
...
...
@@ -252,7 +252,6 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
options
.
exit_cb
=
dmUdfdExit
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_pipe_init
(
&
pData
->
loop
,
&
pData
->
ctrlPipe
,
1
);
uv_stdio_container_t
child_stdio
[
3
];
...
...
@@ -268,7 +267,7 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
char
dnodeIdEnvItem
[
32
]
=
{
0
};
char
thrdPoolSizeEnvItem
[
32
]
=
{
0
};
snprintf
(
dnodeIdEnvItem
,
32
,
"%s=%d"
,
"DNODE_ID"
,
pD
node
->
data
.
dnodeId
);
snprintf
(
dnodeIdEnvItem
,
32
,
"%s=%d"
,
"DNODE_ID"
,
pD
ata
->
dnodeId
);
float
numCpuCores
=
4
;
taosGetCpuCores
(
&
numCpuCores
);
snprintf
(
thrdPoolSizeEnvItem
,
32
,
"%s=%d"
,
"UV_THREADPOOL_SIZE"
,
(
int
)
numCpuCores
*
2
);
...
...
@@ -276,7 +275,7 @@ static int32_t dmSpawnUdfd(SDnode *pDnode) {
options
.
env
=
envUdfd
;
int
err
=
uv_spawn
(
&
pData
->
loop
,
&
pData
->
process
,
&
options
);
pData
->
process
.
data
=
(
void
*
)
pD
node
;
pData
->
process
.
data
=
(
void
*
)
pD
ata
;
if
(
err
!=
0
)
{
dError
(
"can not spawn udfd. path: %s, error: %s"
,
path
,
uv_strerror
(
err
));
...
...
@@ -291,18 +290,16 @@ static void dmUdfdCloseWalkCb(uv_handle_t* handle, void* arg) {
}
static
void
dmUdfdStopAsyncCb
(
uv_async_t
*
async
)
{
SDnode
*
pDnode
=
async
->
data
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
SUdfdData
*
pData
=
async
->
data
;
uv_stop
(
&
pData
->
loop
);
}
static
void
dmWatchUdfd
(
void
*
args
)
{
SDnode
*
pDnode
=
args
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
SUdfdData
*
pData
=
args
;
uv_loop_init
(
&
pData
->
loop
);
uv_async_init
(
&
pData
->
loop
,
&
pData
->
stopAsync
,
dmUdfdStopAsyncCb
);
pData
->
stopAsync
.
data
=
pD
node
;
int32_t
err
=
dmSpawnUdfd
(
pD
node
);
pData
->
stopAsync
.
data
=
pD
ata
;
int32_t
err
=
dmSpawnUdfd
(
pD
ata
);
atomic_store_32
(
&
pData
->
spawnErr
,
err
);
uv_barrier_wait
(
&
pData
->
barrier
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
...
...
@@ -314,18 +311,19 @@ static void dmWatchUdfd(void *args) {
return
;
}
static
int32_t
dmStartUdfd
(
SDnode
*
pDnode
)
{
static
int32_t
dmStartUdfd
(
SDnode
*
pDnode
,
int32_t
startDnodeId
)
{
char
dnodeId
[
8
]
=
{
0
};
snprintf
(
dnodeId
,
sizeof
(
dnodeId
),
"%d"
,
pDnode
->
data
.
dnodeId
);
uv_os_setenv
(
"DNODE_ID"
,
dnodeId
);
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
pData
->
dnodeId
=
startDnodeId
;
if
(
pData
->
startCalled
)
{
dInfo
(
"dnode-mgmt start udfd already called"
);
return
0
;
}
pData
->
startCalled
=
true
;
uv_barrier_init
(
&
pData
->
barrier
,
2
);
uv_thread_create
(
&
pData
->
thread
,
dmWatchUdfd
,
pD
node
);
uv_thread_create
(
&
pData
->
thread
,
dmWatchUdfd
,
pD
ata
);
uv_barrier_wait
(
&
pData
->
barrier
);
int32_t
err
=
atomic_load_32
(
&
pData
->
spawnErr
);
if
(
err
!=
0
)
{
...
...
@@ -340,10 +338,10 @@ static int32_t dmStartUdfd(SDnode *pDnode) {
return
err
;
}
static
int32_t
dmStopUdfd
(
S
Dnode
*
pDnode
)
{
static
int32_t
dmStopUdfd
(
S
UdfdData
*
udfdData
)
{
dInfo
(
"dnode-mgmt to stop udfd. need cleanup: %d, spawn err: %d"
,
pDnode
->
udfdData
.
needCleanUp
,
pDnode
->
udfdData
.
spawnErr
);
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
udfdData
->
needCleanUp
,
udfdData
->
spawnErr
);
SUdfdData
*
pData
=
udfdData
;
if
(
!
pData
->
needCleanUp
||
atomic_load_32
(
&
pData
->
stopCalled
))
{
return
0
;
}
...
...
@@ -387,7 +385,7 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
}
dmReportStartup
(
pDnode
,
"dnode-transport"
,
"initialized"
);
if
(
dmStartUdfd
(
pDnode
)
!=
0
)
{
if
(
dmStartUdfd
(
pDnode
,
pDnode
->
data
.
dnodeId
)
!=
0
)
{
dError
(
"failed to start udfd"
);
}
...
...
@@ -398,7 +396,7 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
static
void
dmCleanupMgmt
(
SMgmtWrapper
*
pWrapper
)
{
dInfo
(
"dnode-mgmt start to clean up"
);
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
dmStopUdfd
(
pDnode
);
dmStopUdfd
(
&
pDnode
->
udfdData
);
dmStopWorker
(
pDnode
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
...
...
source/dnode/mgmt/interface/inc/dmDef.h
浏览文件 @
9cf1cb78
...
...
@@ -156,6 +156,8 @@ typedef struct SUdfdData {
uv_pipe_t
ctrlPipe
;
uv_async_t
stopAsync
;
int32_t
stopCalled
;
int32_t
dnodeId
;
}
SUdfdData
;
typedef
struct
SDnode
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录