Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d72580da
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看板
提交
d72580da
编写于
7月 31, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream): transfer the state for agg tasks.
上级
d45596bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
18 deletion
+40
-18
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+40
-18
未找到文件。
source/libs/stream/src/streamExec.c
浏览文件 @
d72580da
...
@@ -292,12 +292,12 @@ static void waitForTaskIdle(SStreamTask* pTask, SStreamTask* pStreamTask) {
...
@@ -292,12 +292,12 @@ static void waitForTaskIdle(SStreamTask* pTask, SStreamTask* pStreamTask) {
}
}
}
}
static
int32_t
streamTransferStateToStreamTask
(
SStreamTask
*
pTask
)
{
static
int32_t
stream
Do
TransferStateToStreamTask
(
SStreamTask
*
pTask
)
{
SStreamMeta
*
pMeta
=
pTask
->
pMeta
;
SStreamMeta
*
pMeta
=
pTask
->
pMeta
;
SStreamTask
*
pStreamTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
streamTaskId
.
taskId
);
SStreamTask
*
pStreamTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
streamTaskId
.
taskId
);
if
(
pStreamTask
==
NULL
)
{
if
(
pStreamTask
==
NULL
)
{
// todo: destroy th
is
task here
// todo: destroy th
e fill-history
task here
qError
(
"s-task:%s failed to find related stream task:0x%x, it may have been destroyed or closed"
,
pTask
->
id
.
idStr
,
qError
(
"s-task:%s failed to find related stream task:0x%x, it may have been destroyed or closed"
,
pTask
->
id
.
idStr
,
pTask
->
streamTaskId
.
taskId
);
pTask
->
streamTaskId
.
taskId
);
return
TSDB_CODE_STREAM_TASK_NOT_EXIST
;
return
TSDB_CODE_STREAM_TASK_NOT_EXIST
;
...
@@ -338,34 +338,36 @@ static int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
...
@@ -338,34 +338,36 @@ static int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
qDebug
(
"s-task:%s no need to update time window for non-source task"
,
pStreamTask
->
id
.
idStr
);
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
//
1. expand the query time window for stream task of WAL
scanner
pTimeWindow
->
skey
=
INT64_MIN
;
pTimeWindow
->
skey
=
INT64_MIN
;
qStreamInfoResetTimewindowFilter
(
pStreamTask
->
exec
.
pExecutor
);
qStreamInfoResetTimewindowFilter
(
pStreamTask
->
exec
.
pExecutor
);
// transfer the ownership of executor state
//
2.
transfer the ownership of executor state
streamTaskReleaseState
(
pTask
);
streamTaskReleaseState
(
pTask
);
streamTaskReloadState
(
pStreamTask
);
streamTaskReloadState
(
pStreamTask
);
// clear the link between fill-history task and stream task info
//
3.
clear the link between fill-history task and stream task info
pStreamTask
->
historyTaskId
.
taskId
=
0
;
pStreamTask
->
historyTaskId
.
taskId
=
0
;
// 4. resume the state of stream task, after this function, the stream task will run immidately. But it can not be
// pause, since the pause allowed attribute is not set yet.
streamTaskResumeFromHalt
(
pStreamTask
);
streamTaskResumeFromHalt
(
pStreamTask
);
qDebug
(
"s-task:%s fill-history task set status to be dropping, save the state into disk"
,
pTask
->
id
.
idStr
);
qDebug
(
"s-task:%s fill-history task set status to be dropping, save the state into disk"
,
pTask
->
id
.
idStr
);
int32_t
taskId
=
pTask
->
id
.
taskId
;
int32_t
taskId
=
pTask
->
id
.
taskId
;
//
free it and remove it
from disk meta-store
//
5. free it and remove fill-history task
from disk meta-store
streamMetaUnregisterTask
(
pMeta
,
taskId
);
streamMetaUnregisterTask
(
pMeta
,
taskId
);
// save to disk
//
6.
save to disk
taosWLockLatch
(
&
pMeta
->
lock
);
taosWLockLatch
(
&
pMeta
->
lock
);
streamMetaSaveTask
(
pMeta
,
pStreamTask
);
streamMetaSaveTask
(
pMeta
,
pStreamTask
);
if
(
streamMetaCommit
(
pMeta
)
<
0
)
{
if
(
streamMetaCommit
(
pMeta
)
<
0
)
{
// persist to disk
// persist to disk
}
}
taosWUnLockLatch
(
&
pMeta
->
lock
);
taosWUnLockLatch
(
&
pMeta
->
lock
);
//
pause allowed
//
7. pause allowed.
streamTaskEnablePause
(
pStreamTask
);
streamTaskEnablePause
(
pStreamTask
);
streamSchedExec
(
pStreamTask
);
streamSchedExec
(
pStreamTask
);
...
@@ -373,6 +375,25 @@ static int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
...
@@ -373,6 +375,25 @@ static int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
streamTransferStateToStreamTask
(
SStreamTask
*
pTask
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
!
pTask
->
status
.
transferState
)
{
return
code
;
}
if
(
pTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
)
{
streamTaskFillHistoryFinished
(
pTask
);
streamTaskEndScanWAL
(
pTask
);
}
else
{
// do transfer task operator states.
code
=
streamDoTransferStateToStreamTask
(
pTask
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle this
return
code
;
}
}
return
code
;
}
static
int32_t
extractMsgFromInputQ
(
SStreamTask
*
pTask
,
SStreamQueueItem
**
pInput
,
int32_t
*
numOfBlocks
,
static
int32_t
extractMsgFromInputQ
(
SStreamTask
*
pTask
,
SStreamQueueItem
**
pInput
,
int32_t
*
numOfBlocks
,
const
char
*
id
)
{
const
char
*
id
)
{
int32_t
retryTimes
=
0
;
int32_t
retryTimes
=
0
;
...
@@ -526,17 +547,16 @@ int32_t streamTaskEndScanWAL(SStreamTask* pTask) {
...
@@ -526,17 +547,16 @@ int32_t streamTaskEndScanWAL(SStreamTask* pTask) {
double
el
=
(
taosGetTimestampMs
()
-
pTask
->
tsInfo
.
step2Start
)
/
1000
.
0
;
double
el
=
(
taosGetTimestampMs
()
-
pTask
->
tsInfo
.
step2Start
)
/
1000
.
0
;
qDebug
(
"s-task:%s scan-history from WAL stage(step 2) ended, elapsed time:%.2fs"
,
id
,
el
);
qDebug
(
"s-task:%s scan-history from WAL stage(step 2) ended, elapsed time:%.2fs"
,
id
,
el
);
// 3. notify downstream tasks to transfer executor state after handle all history blocks.
// 1. notify all downstream tasks to transfer executor state after handle all history blocks.
pTask
->
status
.
transferState
=
true
;
int32_t
code
=
streamDispatchTransferStateMsg
(
pTask
);
int32_t
code
=
streamDispatchTransferStateMsg
(
pTask
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle error
// todo handle error
}
}
// the last execution of fill-history task, in order to transfer task operator states.
// 2. do transfer stream task operator states.
code
=
streamTransferStateToStreamTask
(
pTask
);
pTask
->
status
.
transferState
=
true
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle this
code
=
streamDoTransferStateToStreamTask
(
pTask
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle error
return
code
;
return
code
;
}
}
...
@@ -560,9 +580,11 @@ int32_t streamTryExec(SStreamTask* pTask) {
...
@@ -560,9 +580,11 @@ int32_t streamTryExec(SStreamTask* pTask) {
// todo the task should be commit here
// todo the task should be commit here
if
(
taosQueueEmpty
(
pTask
->
inputQueue
->
queue
))
{
if
(
taosQueueEmpty
(
pTask
->
inputQueue
->
queue
))
{
// fill-history WAL scan has completed
// fill-history WAL scan has completed
if
(
pTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
&&
pTask
->
status
.
transferState
==
true
)
{
if
(
pTask
->
status
.
transferState
)
{
streamTaskFillHistoryFinished
(
pTask
);
code
=
streamTransferStateToStreamTask
(
pTask
);
streamTaskEndScanWAL
(
pTask
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
else
{
}
else
{
atomic_store_8
(
&
pTask
->
status
.
schedStatus
,
TASK_SCHED_STATUS__INACTIVE
);
atomic_store_8
(
&
pTask
->
status
.
schedStatus
,
TASK_SCHED_STATUS__INACTIVE
);
qDebug
(
"s-task:%s exec completed, status:%s, sched-status:%d"
,
id
,
streamGetTaskStatusStr
(
pTask
->
status
.
taskStatus
),
qDebug
(
"s-task:%s exec completed, status:%s, sched-status:%d"
,
id
,
streamGetTaskStatusStr
(
pTask
->
status
.
taskStatus
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录