Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
13028744
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
13028744
编写于
6月 15, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
53377c2c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
69 addition
and
54 deletion
+69
-54
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+4
-3
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+65
-51
未找到文件。
source/dnode/vnode/src/tq/tq.c
浏览文件 @
13028744
...
...
@@ -1177,12 +1177,13 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
tqDebug
(
"s-task:%s set status to be dropping"
,
pTask
->
id
.
idStr
);
streamMetaSaveTask
(
pMeta
,
pTask
);
streamMetaReleaseTask
(
pMeta
,
pTask
);
// streamMetaRemoveTask(pMeta, pTask->id.taskId);
streamMetaSaveTask
(
pMeta
,
pStreamTask
);
streamMetaReleaseTask
(
pMeta
,
pTask
);
streamMetaReleaseTask
(
pMeta
,
pStreamTask
);
if
(
streamMetaCommit
(
pTask
->
pMeta
)
<
0
)
{
if
(
streamMetaCommit
(
pTask
->
pMeta
)
<
0
)
{
// persist to disk
}
}
else
{
// todo update the chkInfo version for current task.
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
13028744
...
...
@@ -313,6 +313,69 @@ int32_t updateCheckPointInfo(SStreamTask* pTask) {
return
TSDB_CODE_SUCCESS
;
}
static
void
waitForTaskTobeIdle
(
SStreamTask
*
pTask
,
SStreamTask
*
pStreamTask
)
{
// wait for the stream task to be idle
int64_t
st
=
taosGetTimestampMs
();
while
(
!
streamTaskIsIdle
(
pStreamTask
))
{
qDebug
(
"s-task:%s level:%d wait for stream task:%s to be idle, check again in 100ms"
,
pTask
->
id
.
idStr
,
pTask
->
info
.
taskLevel
,
pStreamTask
->
id
.
idStr
);
taosMsleep
(
100
);
}
double
el
=
(
taosGetTimestampMs
()
-
st
)
/
1000
.
0
;
if
(
el
>
0
)
{
qDebug
(
"s-task:%s wait for stream task:%s for %.2fs to execute all data in inputQ"
,
pTask
->
id
.
idStr
,
pStreamTask
->
id
.
idStr
,
el
);
}
}
static
int32_t
streamTransferStateToStreamTask
(
SStreamTask
*
pTask
)
{
SStreamTask
*
pStreamTask
=
streamMetaAcquireTask
(
pTask
->
pMeta
,
pTask
->
streamTaskId
.
taskId
);
qDebug
(
"s-task:%s scan history task end, update stream task:%s info and launch it"
,
pTask
->
id
.
idStr
,
pStreamTask
->
id
.
idStr
);
// todo handle stream task is dropped here
ASSERT
(
pStreamTask
!=
NULL
&&
pStreamTask
->
historyTaskId
.
taskId
==
pTask
->
id
.
taskId
);
STimeWindow
*
pTimeWindow
=
&
pStreamTask
->
dataRange
.
window
;
// here we need to wait for the stream task handle all data in the input queue.
if
(
pStreamTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
)
{
ASSERT
(
pStreamTask
->
status
.
taskStatus
==
TASK_STATUS__HALT
);
}
else
{
ASSERT
(
pStreamTask
->
status
.
taskStatus
==
TASK_STATUS__NORMAL
);
pStreamTask
->
status
.
taskStatus
=
TASK_STATUS__HALT
;
}
// wait for the stream task to be idle
waitForTaskTobeIdle
(
pTask
,
pStreamTask
);
if
(
pStreamTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
)
{
// update the scan data range for source task.
qDebug
(
"s-task:%s level:%d stream task window %"
PRId64
" - %"
PRId64
" transfer to %"
PRId64
" - %"
PRId64
", status:%s, sched-status:%d"
,
pStreamTask
->
id
.
idStr
,
TASK_LEVEL__SOURCE
,
pTimeWindow
->
skey
,
pTimeWindow
->
ekey
,
INT64_MIN
,
pTimeWindow
->
ekey
,
streamGetTaskStatusStr
(
TASK_STATUS__NORMAL
),
pStreamTask
->
status
.
schedStatus
);
// todo transfer state
}
else
{
// for sink tasks, they are continue to execute, no need to be halt.
// the process should be stopped for a while, during the term of transfer task state.
// OR wait for the inputQ && outputQ of agg tasks are all consumed, and then start the state transfer
qDebug
(
"s-task:%s no need to update time window, for non-source task"
,
pStreamTask
->
id
.
idStr
);
// todo transfer state
}
// expand the query time window for stream scanner
pTimeWindow
->
skey
=
INT64_MIN
;
streamSetStatusNormal
(
pStreamTask
);
streamSchedExec
(
pStreamTask
);
streamMetaReleaseTask
(
pTask
->
pMeta
,
pStreamTask
);
return
TSDB_CODE_SUCCESS
;
}
/**
* todo: the batch of blocks should be tuned dynamic, according to the total elapsed time of each batch of blocks, the
* appropriate batch of blocks should be handled in 5 to 10 sec.
...
...
@@ -388,57 +451,8 @@ int32_t streamExecForAll(SStreamTask* pTask) {
}
if
(
pInput
==
NULL
)
{
if
(
pTask
->
info
.
fillHistory
&&
pTask
->
status
.
transferState
)
{
// todo transfer task state here
SStreamTask
*
pStreamTask
=
streamMetaAcquireTask
(
pTask
->
pMeta
,
pTask
->
streamTaskId
.
taskId
);
qDebug
(
"s-task:%s scan history task end, update stream task:%s info and launch it"
,
pTask
->
id
.
idStr
,
pStreamTask
->
id
.
idStr
);
ASSERT
(
pStreamTask
!=
NULL
&&
pStreamTask
->
historyTaskId
.
taskId
==
pTask
->
id
.
taskId
);
STimeWindow
*
pTimeWindow
=
&
pStreamTask
->
dataRange
.
window
;
// here we need to wait for the stream task handle all data in the input queue.
if
(
pStreamTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
)
{
ASSERT
(
pStreamTask
->
status
.
taskStatus
==
TASK_STATUS__HALT
);
}
else
{
ASSERT
(
pStreamTask
->
status
.
taskStatus
==
TASK_STATUS__NORMAL
);
pStreamTask
->
status
.
taskStatus
=
TASK_STATUS__HALT
;
}
{
// wait for the stream task to be idle
while
(
!
streamTaskIsIdle
(
pStreamTask
))
{
qDebug
(
"s-task:%s level:%d wait for stream task:%s to be idle, check again in 100ms"
,
pTask
->
id
.
idStr
,
pTask
->
info
.
taskLevel
,
pStreamTask
->
id
.
idStr
);
taosMsleep
(
100
);
}
}
if
(
pStreamTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
)
{
// update the scan data range for source task.
qDebug
(
"s-task:%s level:%d stream task window %"
PRId64
" - %"
PRId64
" transfer to %"
PRId64
" - %"
PRId64
", status:%s, sched-status:%d"
,
pStreamTask
->
id
.
idStr
,
TASK_LEVEL__SOURCE
,
pTimeWindow
->
skey
,
pTimeWindow
->
ekey
,
INT64_MIN
,
pTimeWindow
->
ekey
,
streamGetTaskStatusStr
(
TASK_STATUS__NORMAL
),
pStreamTask
->
status
.
schedStatus
);
}
else
{
// for sink tasks, they are continue to execute, no need to be halt.
// the process should be stopped for a while, during the term of transfer task state.
// OR wait for the inputQ && outputQ of agg tasks are all consumed, and then start the state transfer
qDebug
(
"s-task:%s no need to update time window, for non-source task"
,
pStreamTask
->
id
.
idStr
);
}
// expand the query time window for stream scanner
pTimeWindow
->
skey
=
INT64_MIN
;
streamSetStatusNormal
(
pStreamTask
);
streamMetaSaveTask
(
pTask
->
pMeta
,
pStreamTask
);
if
(
streamMetaCommit
(
pTask
->
pMeta
))
{
// persistent to disk
}
streamSchedExec
(
pStreamTask
);
streamMetaReleaseTask
(
pTask
->
pMeta
,
pStreamTask
);
if
(
pTask
->
info
.
fillHistory
&&
pTask
->
status
.
transferState
)
{
int32_t
code
=
streamTransferStateToStreamTask
(
pTask
);
}
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录