Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b8101afb
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
b8101afb
编写于
8月 18, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream): refactor the tasks restart mechanism.
上级
41fe441d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
24 deletion
+42
-24
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+1
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+41
-24
未找到文件。
include/libs/stream/tstream.h
浏览文件 @
b8101afb
...
@@ -390,6 +390,7 @@ typedef struct SStreamMeta {
...
@@ -390,6 +390,7 @@ typedef struct SStreamMeta {
tmr_h
hbTmr
;
tmr_h
hbTmr
;
SMgmtInfo
mgmtInfo
;
SMgmtInfo
mgmtInfo
;
int32_t
closedTask
;
int32_t
chkptNotReadyTasks
;
int32_t
chkptNotReadyTasks
;
int64_t
chkpId
;
int64_t
chkpId
;
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
b8101afb
...
@@ -1855,13 +1855,12 @@ int32_t tqProcessStreamTaskCheckpointReadyMsg(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -1855,13 +1855,12 @@ int32_t tqProcessStreamTaskCheckpointReadyMsg(STQ* pTq, SRpcMsg* pMsg) {
}
}
int32_t
tqProcessTaskUpdateReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
int32_t
tqProcessTaskUpdateReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
bool
restartTasks
=
false
;
SStreamMeta
*
pMeta
=
pTq
->
pStreamMeta
;
SStreamMeta
*
pMeta
=
pTq
->
pStreamMeta
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
char
*
msg
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
char
*
msg
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
len
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
int32_t
len
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
SRpcMsg
rsp
=
{.
info
=
pMsg
->
info
,
.
code
=
TSDB_CODE_SUCCESS
};
bool
startTask
=
vnodeIsRoleLeader
(
pTq
->
pVnode
);
// in case of follower, do not launch task
SRpcMsg
rsp
=
{.
info
=
pMsg
->
info
,
.
code
=
TSDB_CODE_SUCCESS
};
SStreamTaskNodeUpdateMsg
req
=
{
0
};
SStreamTaskNodeUpdateMsg
req
=
{
0
};
...
@@ -1884,34 +1883,52 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -1884,34 +1883,52 @@ int32_t tqProcessTaskUpdateReq(STQ* pTq, SRpcMsg* pMsg) {
tqDebug
(
"s-task:%s receive task nodeEp update msg from mnode"
,
pTask
->
id
.
idStr
);
tqDebug
(
"s-task:%s receive task nodeEp update msg from mnode"
,
pTask
->
id
.
idStr
);
streamTaskUpdateEpsetInfo
(
pTask
,
req
.
pNodeList
);
streamTaskUpdateEpsetInfo
(
pTask
,
req
.
pNodeList
);
streamTaskStop
(
pTask
);
SStreamTask
*
pHistoryTask
=
NULL
;
taosWLockLatch
(
&
pMeta
->
lock
);
if
(
pTask
->
historyTaskId
.
taskId
!=
0
)
{
pHistoryTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
historyTaskId
.
streamId
,
pTask
->
historyTaskId
.
taskId
);
if
(
pHistoryTask
!=
NULL
)
{
tqDebug
(
"s-task:%s fill-history task handle task update along with related stream task"
,
pHistoryTask
->
id
.
idStr
);
streamTaskUpdateEpsetInfo
(
pHistoryTask
,
req
.
pNodeList
);
streamTaskRestart
(
pHistoryTask
,
NULL
,
startTask
);
int32_t
numOfCount
=
streamMetaGetNumOfTasks
(
pMeta
);
streamMetaReleaseTask
(
pMeta
,
pHistoryTask
);
pMeta
->
closedTask
+=
1
;
}
else
{
tqError
(
"vgId:%d failed to get fill-history task:0x%x when handling task update, it may have been dropped"
,
pMeta
->
vgId
,
pTask
->
historyTaskId
.
taskId
);
streamMetaReleaseTask
(
pMeta
,
pTask
);
}
}
streamTaskRestart
(
pTask
,
NULL
,
startTask
);
tqDebug
(
"s-task:%s task nodeEp update completed"
,
pTask
->
id
.
idStr
);
streamMetaReleaseTask
(
pMeta
,
pTask
);
streamMetaReleaseTask
(
pMeta
,
pTask
);
int32_t
code
=
rsp
.
code
;
// all tasks are closed, now let's restart the stream meta
if
(
pMeta
->
closedTask
==
numOfCount
)
{
if
(
streamMetaCommit
(
pMeta
)
<
0
)
{
// persist to disk
}
restartTasks
=
true
;
pMeta
->
closedTask
=
0
;
// reset value
}
taosWUnLockLatch
(
&
pMeta
->
lock
);
_end:
_end:
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
tqDebug
(
"s-task:%s task nodeEp update completed"
,
pTask
->
id
.
idStr
);
if
(
restartTasks
)
{
return
code
;
tqDebug
(
"vgId:%d all tasks are stopped, restart them"
,
vgId
);
streamMetaClose
(
pTask
->
pMeta
);
pTq
->
pStreamMeta
=
streamMetaOpen
(
pTq
->
path
,
pTq
,
(
FTaskExpand
*
)
tqExpandTask
,
pTq
->
pVnode
->
config
.
vgId
,
-
1
);
if
(
pTq
->
pStreamMeta
==
NULL
)
{
return
-
1
;
}
if
(
streamLoadTasks
(
pTq
->
pStreamMeta
)
<
0
)
{
return
-
1
;
}
if
(
vnodeIsRoleLeader
(
pTq
->
pVnode
)
&&
!
tsDisableStream
)
{
vInfo
(
"vgId:%d, restart to all stream tasks"
,
vgId
);
tqCheckStreamStatus
(
pTq
);
}
}
return
rsp
.
code
;
}
}
int32_t
tqProcessTaskStopReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
int32_t
tqProcessTaskStopReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录