Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
54e59090
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看板
提交
54e59090
编写于
1月 24, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
e6f05d38
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
29 deletion
+59
-29
source/libs/qworker/inc/qworkerInt.h
source/libs/qworker/inc/qworkerInt.h
+0
-2
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+22
-15
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+37
-12
未找到文件。
source/libs/qworker/inc/qworkerInt.h
浏览文件 @
54e59090
...
...
@@ -86,8 +86,6 @@ typedef struct SQWPhaseInput {
int8_t
taskStatus
;
int8_t
taskType
;
int32_t
code
;
qTaskInfo_t
taskHandle
;
DataSinkHandle
sinkHandle
;
}
SQWPhaseInput
;
typedef
struct
SQWPhaseOutput
{
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
54e59090
...
...
@@ -456,13 +456,15 @@ _return:
QW_RET
(
code
);
}
int32_t
qwExecTask
(
QW_FPARAMS_DEF
,
qTaskInfo_t
*
taskHandle
,
DataSinkHandle
sinkHandle
,
int8_t
taskType
,
bool
shortRun
)
{
int32_t
qwExecTask
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
)
{
int32_t
code
=
0
;
bool
qcontinue
=
true
;
SSDataBlock
*
pRes
=
NULL
;
uint64_t
useconds
=
0
;
int32_t
i
=
0
;
int32_t
leftRun
=
QW_DEFAULT_SHORT_RUN_TIMES
;
int32_t
execNum
=
0
;
qTaskInfo_t
*
taskHandle
=
&
ctx
->
taskHandle
;
DataSinkHandle
sinkHandle
=
ctx
->
sinkHandle
;
while
(
true
)
{
QW_TASK_DLOG
(
"start to execTask in executor, loopIdx:%d"
,
i
++
);
...
...
@@ -473,12 +475,14 @@ int32_t qwExecTask(QW_FPARAMS_DEF, qTaskInfo_t *taskHandle, DataSinkHandle sinkH
QW_ERR_JRET
(
code
);
}
++
execNum
;
if
(
NULL
==
pRes
)
{
QW_TASK_DLOG
(
"task query done, useconds:%"
PRIu64
,
useconds
);
dsEndPut
(
sinkHandle
,
useconds
);
if
(
TASK_TYPE_TEMP
==
taskType
)
{
if
(
TASK_TYPE_TEMP
==
ctx
->
taskType
)
{
qwFreeTaskHandle
(
QW_FPARAMS
(),
taskHandle
);
}
...
...
@@ -498,7 +502,11 @@ int32_t qwExecTask(QW_FPARAMS_DEF, qTaskInfo_t *taskHandle, DataSinkHandle sinkH
break
;
}
if
(
shortRun
&&
((
--
leftRun
)
<=
0
))
{
if
(
QW_IS_EVENT_RECEIVED
(
ctx
,
QW_EVENT_READY
)
&&
execNum
>=
QW_DEFAULT_SHORT_RUN_TIMES
)
{
break
;
}
if
(
QW_IS_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
))
{
break
;
}
}
...
...
@@ -617,8 +625,6 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu
case
QW_PHASE_PRE_QUERY
:
{
atomic_store_8
(
&
ctx
->
phase
,
phase
);
atomic_store_8
(
&
ctx
->
taskType
,
input
->
taskType
);
if
(
QW_IS_EVENT_PROCESSED
(
ctx
,
QW_EVENT_CANCEL
)
||
QW_IS_EVENT_PROCESSED
(
ctx
,
QW_EVENT_DROP
))
{
QW_TASK_ELOG
(
"task already cancelled/dropped at wrong phase, phase:%d"
,
phase
);
...
...
@@ -842,9 +848,6 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp
}
if
(
QW_PHASE_POST_QUERY
==
phase
)
{
ctx
->
taskHandle
=
input
->
taskHandle
;
ctx
->
sinkHandle
=
input
->
sinkHandle
;
if
(
NULL
==
ctx
->
taskHandle
&&
NULL
==
ctx
->
sinkHandle
)
{
ctx
->
emptyRes
=
true
;
}
...
...
@@ -949,8 +952,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType) {
SQWPhaseOutput
output
=
{
0
};
qTaskInfo_t
pTaskInfo
=
NULL
;
DataSinkHandle
sinkHandle
=
NULL
;
input
.
taskType
=
taskType
;
SQWTaskCtx
*
ctx
=
NULL
;
QW_ERR_JRET
(
qwHandlePrePhaseEvents
(
QW_FPARAMS
(),
QW_PHASE_PRE_QUERY
,
&
input
,
&
output
));
...
...
@@ -961,6 +963,10 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType) {
QW_TASK_DLOG
(
"task need stop, phase:%d"
,
QW_PHASE_PRE_QUERY
);
QW_ERR_JRET
(
code
);
}
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
atomic_store_8
(
&
ctx
->
taskType
,
taskType
);
code
=
qStringToSubplan
(
qwMsg
->
msg
,
&
plan
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
...
@@ -986,8 +992,11 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType) {
queryRsped
=
true
;
atomic_store_ptr
(
&
ctx
->
taskHandle
,
pTaskInfo
);
atomic_store_ptr
(
&
ctx
->
sinkHandle
,
sinkHandle
);
if
(
pTaskInfo
&&
sinkHandle
)
{
QW_ERR_JRET
(
qwExecTask
(
QW_FPARAMS
(),
&
pTaskInfo
,
sinkHandle
,
taskType
,
true
));
QW_ERR_JRET
(
qwExecTask
(
QW_FPARAMS
(),
ctx
));
}
_return:
...
...
@@ -1002,8 +1011,6 @@ _return:
}
input
.
code
=
rspCode
;
input
.
taskHandle
=
pTaskInfo
;
input
.
sinkHandle
=
sinkHandle
;
input
.
taskStatus
=
rspCode
?
JOB_TASK_STATUS_FAILED
:
JOB_TASK_STATUS_PARTIAL_SUCCEED
;
QW_ERR_RET
(
qwHandlePostPhaseEvents
(
QW_FPARAMS
(),
QW_PHASE_POST_QUERY
,
&
input
,
&
output
));
...
...
@@ -1095,7 +1102,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
DataSinkHandle
sinkHandle
=
ctx
->
sinkHandle
;
QW_ERR_JRET
(
qwExecTask
(
QW_FPARAMS
(),
&
ctx
->
taskHandle
,
sinkHandle
,
ctx
->
taskType
,
QW_IS_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
)
));
QW_ERR_JRET
(
qwExecTask
(
QW_FPARAMS
(),
ctx
));
if
(
QW_IS_EVENT_RECEIVED
(
ctx
,
QW_EVENT_FETCH
))
{
SOutputData
sOutput
=
{
0
};
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
54e59090
...
...
@@ -722,7 +722,7 @@ void *queryQueueThread(void *param) {
while
(
true
)
{
tsem_wait
(
&
qwtTestQuerySem
);
if
(
qwtTestStop
&&
qwtTestQueryQueueNum
<=
0
)
{
if
(
qwtTestStop
&&
qwtTestQueryQueueNum
<=
0
&&
qwtTestCaseFinished
)
{
break
;
}
...
...
@@ -761,7 +761,7 @@ void *queryQueueThread(void *param) {
free
(
queryRpc
);
if
(
qwtTestStop
&&
qwtTestQueryQueueNum
<=
0
)
{
if
(
qwtTestStop
&&
qwtTestQueryQueueNum
<=
0
&&
qwtTestCaseFinished
)
{
break
;
}
}
...
...
@@ -779,6 +779,10 @@ void *fetchQueueThread(void *param) {
while
(
true
)
{
tsem_wait
(
&
qwtTestFetchSem
);
if
(
qwtTestStop
&&
qwtTestFetchQueueNum
<=
0
&&
qwtTestCaseFinished
)
{
break
;
}
taosWLockLatch
(
&
qwtTestFetchQueueLock
);
if
(
qwtTestFetchQueueNum
<=
0
||
qwtTestFetchQueueRIdx
==
qwtTestFetchQueueWIdx
)
{
printf
(
"Fetch queue is empty
\n
"
);
...
...
@@ -826,7 +830,7 @@ void *fetchQueueThread(void *param) {
free
(
fetchRpc
);
if
(
qwtTestStop
&&
qwtTestFetchQueueNum
<=
0
)
{
if
(
qwtTestStop
&&
qwtTestFetchQueueNum
<=
0
&&
qwtTestCaseFinished
)
{
break
;
}
}
...
...
@@ -1104,10 +1108,17 @@ TEST(rcTest, shortExecshortDelay) {
break
;
}
sleep
(
3
);
sleep
(
1
);
if
(
qwtTestCaseFinished
)
{
if
(
qwtTestQuitThreadNum
<
3
)
{
tsem_post
(
&
qwtTestQuerySem
);
tsem_post
(
&
qwtTestFetchSem
);
usleep
(
10
);
}
}
tsem_post
(
&
qwtTestQuerySem
);
usleep
(
10
);
}
qwtTestQueryQueueNum
=
0
;
...
...
@@ -1179,10 +1190,17 @@ TEST(rcTest, longExecshortDelay) {
break
;
}
sleep
(
3
);
sleep
(
1
);
if
(
qwtTestCaseFinished
)
{
if
(
qwtTestQuitThreadNum
<
3
)
{
tsem_post
(
&
qwtTestQuerySem
);
tsem_post
(
&
qwtTestFetchSem
);
usleep
(
10
);
}
}
tsem_post
(
&
qwtTestQuerySem
);
usleep
(
10
);
}
qwtTestQueryQueueNum
=
0
;
...
...
@@ -1255,10 +1273,17 @@ TEST(rcTest, shortExeclongDelay) {
break
;
}
sleep
(
3
);
sleep
(
1
);
if
(
qwtTestCaseFinished
)
{
if
(
qwtTestQuitThreadNum
<
3
)
{
tsem_post
(
&
qwtTestQuerySem
);
tsem_post
(
&
qwtTestFetchSem
);
usleep
(
10
);
}
}
tsem_post
(
&
qwtTestQuerySem
);
usleep
(
10
);
}
qwtTestQueryQueueNum
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录