Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0d0e30b7
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看板
提交
0d0e30b7
编写于
8月 12, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream): fix the error.
上级
ce721a01
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
79 addition
and
41 deletion
+79
-41
include/common/tcommon.h
include/common/tcommon.h
+1
-0
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+78
-41
未找到文件。
include/common/tcommon.h
浏览文件 @
0d0e30b7
...
...
@@ -152,6 +152,7 @@ enum {
STREAM_INPUT__DATA_RETRIEVE
,
STREAM_INPUT__GET_RES
,
STREAM_INPUT__CHECKPOINT
,
STREAM_INPUT__CHECKPOINT_TRIGGER
,
STREAM_INPUT__TRANS_STATE
,
STREAM_INPUT__REF_DATA_BLOCK
,
STREAM_INPUT__DESTROY
,
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
0d0e30b7
...
...
@@ -334,6 +334,9 @@ static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) {
qDebug
(
"s-task:%s no need to update time window for non-source task"
,
pStreamTask
->
id
.
idStr
);
}
// todo check the output queue for fill-history task, and wait for it complete
// 1. expand the query time window for stream task of WAL scanner
pTimeWindow
->
skey
=
INT64_MIN
;
qStreamInfoResetTimewindowFilter
(
pStreamTask
->
exec
.
pExecutor
);
...
...
@@ -389,8 +392,6 @@ static int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
int32_t
level
=
pTask
->
info
.
taskLevel
;
if
(
level
==
TASK_LEVEL__SOURCE
)
{
streamTaskFillHistoryFinished
(
pTask
);
streamTaskEndScanWAL
(
pTask
);
code
=
streamDoTransferStateToStreamTask
(
pTask
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// todo handle this
return
code
;
...
...
@@ -405,14 +406,41 @@ static int32_t streamTransferStateToStreamTask(SStreamTask* pTask) {
return
code
;
}
static
int32_t
extractMsgFromInputQ
(
SStreamTask
*
pTask
,
SStreamQueueItem
**
pInput
,
int32_t
*
numOfBlocks
,
const
char
*
id
)
{
int32_t
retryTimes
=
0
;
int32_t
MAX_RETRY_TIMES
=
5
;
static
int32_t
extractBlocksFromInputQ
(
SStreamTask
*
pTask
,
SStreamQueueItem
**
pInput
,
int32_t
*
numOfBlocks
)
{
int32_t
retryTimes
=
0
;
int32_t
MAX_RETRY_TIMES
=
5
;
const
char
*
id
=
pTask
->
id
.
idStr
;
if
(
pTask
->
info
.
taskLevel
==
TASK_LEVEL__SINK
)
{
// extract block from inputQ, one-by-one
while
(
1
)
{
if
(
streamTaskShouldPause
(
&
pTask
->
status
)
||
streamTaskShouldStop
(
&
pTask
->
status
))
{
qDebug
(
"s-task:%s task should pause, extract input blocks:%d"
,
pTask
->
id
.
idStr
,
*
numOfBlocks
);
return
TSDB_CODE_SUCCESS
;
}
SStreamQueueItem
*
qItem
=
streamQueueNextItem
(
pTask
->
inputQueue
);
if
(
qItem
==
NULL
)
{
if
(
pTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
&&
(
++
retryTimes
)
<
MAX_RETRY_TIMES
)
{
taosMsleep
(
10
);
qDebug
(
"===stream===try again batchSize:%d, retry:%d, %s"
,
*
numOfBlocks
,
retryTimes
,
id
);
continue
;
}
qDebug
(
"===stream===break batchSize:%d, %s"
,
*
numOfBlocks
,
id
);
return
TSDB_CODE_SUCCESS
;
}
qDebug
(
"s-task:%s sink task handle result block one-by-one"
,
id
);
*
numOfBlocks
=
1
;
*
pInput
=
qItem
;
return
TSDB_CODE_SUCCESS
;
}
}
// non sink task
while
(
1
)
{
if
(
streamTaskShouldPause
(
&
pTask
->
status
))
{
qDebug
(
"s-task:%s task should pause, input blocks:%d"
,
pTask
->
id
.
idStr
,
*
numOfBlocks
);
if
(
streamTaskShouldPause
(
&
pTask
->
status
)
||
streamTaskShouldStop
(
&
pTask
->
status
)
)
{
qDebug
(
"s-task:%s task should pause,
extract
input blocks:%d"
,
pTask
->
id
.
idStr
,
*
numOfBlocks
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -420,47 +448,52 @@ static int32_t extractMsgFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu
if
(
qItem
==
NULL
)
{
if
(
pTask
->
info
.
taskLevel
==
TASK_LEVEL__SOURCE
&&
(
++
retryTimes
)
<
MAX_RETRY_TIMES
)
{
taosMsleep
(
10
);
qDebug
(
"===stream===try again batchSize:%d, retry:%d
"
,
*
numOfBlocks
,
retryTimes
);
qDebug
(
"===stream===try again batchSize:%d, retry:%d
, %s"
,
*
numOfBlocks
,
retryTimes
,
id
);
continue
;
}
qDebug
(
"===stream===break batchSize:%d"
,
*
numOfBlocks
);
return
TSDB_CODE_SUCCESS
;
}
// do not merge blocks for sink node
if
(
pTask
->
info
.
taskLevel
==
TASK_LEVEL__SINK
)
{
*
numOfBlocks
=
1
;
*
pInput
=
qItem
;
qDebug
(
"===stream===break batchSize:%d, %s"
,
*
numOfBlocks
,
id
);
return
TSDB_CODE_SUCCESS
;
}
if
(
*
pInput
==
NULL
)
{
ASSERT
((
*
numOfBlocks
)
==
0
);
*
pInput
=
qItem
;
}
else
{
// todo we need to sort the data block, instead of just appending into the array list.
void
*
newRet
=
streamMergeQueueItem
(
*
pInput
,
qItem
);
if
(
newRet
==
NULL
)
{
if
(
terrno
==
0
)
{
qDebug
(
"s-task:%s failed to merge blocks from inputQ, numOfBlocks:%d"
,
id
,
*
numOfBlocks
);
}
else
{
qDebug
(
"s-task:%s failed to merge blocks from inputQ, numOfBlocks:%d, code:%s"
,
id
,
*
numOfBlocks
,
tstrerror
(
terrno
));
}
// do not merge blocks for sink node and check point data block
if
(
qItem
->
type
==
STREAM_INPUT__CHECKPOINT
||
qItem
->
type
==
STREAM_INPUT__CHECKPOINT_TRIGGER
||
qItem
->
type
==
STREAM_INPUT__TRANS_STATE
)
{
if
(
*
pInput
==
NULL
)
{
qDebug
(
"s-task:%s checkpoint/transtate msg extracted, start to process immediately"
,
id
);
*
numOfBlocks
=
1
;
*
pInput
=
qItem
;
return
TSDB_CODE_SUCCESS
;
}
else
{
// previous existed blocks needs to be handle, before handle the checkpoint msg block
qDebug
(
"s-task:%s checkpoint/transtate msg extracted, handle previous block first, numOfBlocks:%d"
,
id
,
*
numOfBlocks
);
streamQueueProcessFail
(
pTask
->
inputQueue
);
return
TSDB_CODE_SUCCESS
;
}
}
else
{
if
(
*
pInput
==
NULL
)
{
ASSERT
((
*
numOfBlocks
)
==
0
);
*
pInput
=
qItem
;
}
else
{
// todo we need to sort the data block, instead of just appending into the array list.
void
*
newRet
=
streamMergeQueueItem
(
*
pInput
,
qItem
);
if
(
newRet
==
NULL
)
{
qError
(
"s-task:%s failed to merge blocks from inputQ, numOfBlocks:%d"
,
id
,
*
numOfBlocks
);
streamQueueProcessFail
(
pTask
->
inputQueue
);
return
TSDB_CODE_SUCCESS
;
}
*
pInput
=
newRet
;
}
*
pInput
=
newRet
;
}
*
numOfBlocks
+=
1
;
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
*
numOfBlocks
+=
1
;
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
if
(
*
numOfBlocks
>=
MAX_STREAM_EXEC_BATCH_NUM
)
{
qDebug
(
"s-task:%s batch size limit:%d reached, start to process blocks"
,
id
,
MAX_STREAM_EXEC_BATCH_NUM
);
return
TSDB_CODE_SUCCESS
;
if
(
*
numOfBlocks
>=
MAX_STREAM_EXEC_BATCH_NUM
)
{
qDebug
(
"s-task:%s batch size limit:%d reached, start to process blocks"
,
id
,
MAX_STREAM_EXEC_BATCH_NUM
);
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
...
@@ -476,14 +509,18 @@ int32_t streamProcessTranstateBlock(SStreamTask* pTask, SStreamDataBlock* pBlock
qDebug
(
"s-task:%s receive upstream transfer state msg, remain:%d"
,
id
,
remain
);
return
0
;
}
}
// transfer the ownership of executor state
// transfer the ownership of executor state
if
(
level
==
TASK_LEVEL__SOURCE
)
{
qDebug
(
"s-task:%s open transfer state flag for source task"
,
id
);
}
else
{
qDebug
(
"s-task:%s all upstream tasks send transfer msg, open transfer state flag"
,
id
);
ASSERT
(
pTask
->
streamTaskId
.
taskId
!=
0
&&
pTask
->
info
.
fillHistory
==
1
);
pTask
->
status
.
transferState
=
true
;
}
pTask
->
status
.
transferState
=
true
;
// dispatch the tran-state block to downstream task immediately
int32_t
type
=
pTask
->
outputInfo
.
type
;
if
((
level
==
TASK_LEVEL__AGG
||
level
==
TASK_LEVEL__SOURCE
)
&&
...
...
@@ -518,7 +555,7 @@ int32_t streamExecForAll(SStreamTask* pTask) {
// merge multiple input data if possible in the input queue.
qDebug
(
"s-task:%s start to extract data block from inputQ"
,
id
);
/*int32_t code = */
extract
MsgFromInputQ
(
pTask
,
&
pInput
,
&
batchSize
,
id
);
/*int32_t code = */
extract
BlocksFromInputQ
(
pTask
,
&
pInput
,
&
batchSize
);
if
(
pInput
==
NULL
)
{
ASSERT
(
batchSize
==
0
);
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录