Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
76b8abe2
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76b8abe2
编写于
1月 19, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
c14b2463
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
33 deletion
+56
-33
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+38
-16
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+18
-17
未找到文件。
source/libs/scheduler/src/scheduler.c
浏览文件 @
76b8abe2
...
@@ -66,7 +66,6 @@ void schFreeTask(SSchTask* pTask) {
...
@@ -66,7 +66,6 @@ void schFreeTask(SSchTask* pTask) {
taosArrayDestroy
(
pTask
->
candidateAddrs
);
taosArrayDestroy
(
pTask
->
candidateAddrs
);
}
}
// TODO NEED TO VERFY WITH ASYNC_SEND MEMORY FREE
tfree
(
pTask
->
msg
);
tfree
(
pTask
->
msg
);
if
(
pTask
->
children
)
{
if
(
pTask
->
children
)
{
...
@@ -97,7 +96,7 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
...
@@ -97,7 +96,7 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%d, rspType:%d"
,
lastMsgType
,
msgType
);
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%d, rspType:%d"
,
lastMsgType
,
msgType
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
}
if
(
SCH_GET_TASK_STATUS
(
pTask
)
!=
JOB_TASK_STATUS_EXECUTING
&&
SCH_GET_TASK_STATUS
(
pTask
)
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
if
(
SCH_GET_TASK_STATUS
(
pTask
)
!=
JOB_TASK_STATUS_EXECUTING
&&
SCH_GET_TASK_STATUS
(
pTask
)
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%d, rspType:%d"
,
SCH_GET_TASK_STATUS
(
pTask
),
msgType
);
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%d, rspType:%d"
,
SCH_GET_TASK_STATUS
(
pTask
),
msgType
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
...
@@ -868,8 +867,18 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
...
@@ -868,8 +867,18 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
SCH_ERR_RET
(
schProcessOnTaskFailure
(
pJob
,
pTask
,
rspCode
));
SCH_ERR_RET
(
schProcessOnTaskFailure
(
pJob
,
pTask
,
rspCode
));
}
}
if
(
pJob
->
res
)
{
SCH_TASK_ELOG
(
"got fetch rsp while res already exists, res:%p"
,
pJob
->
res
);
tfree
(
rsp
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
atomic_store_ptr
(
&
pJob
->
res
,
rsp
);
atomic_store_ptr
(
&
pJob
->
res
,
rsp
);
atomic_store_32
(
&
pJob
->
resNumOfRows
,
rsp
->
numOfRows
);
atomic_store_32
(
&
pJob
->
resNumOfRows
,
rsp
->
numOfRows
);
if
(
rsp
->
completed
)
{
SCH_SET_TASK_STATUS
(
pTask
,
JOB_TASK_STATUS_SUCCEED
);
}
SCH_ERR_JRET
(
schProcessOnDataFetched
(
pJob
));
SCH_ERR_JRET
(
schProcessOnDataFetched
(
pJob
));
...
@@ -1067,7 +1076,13 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
...
@@ -1067,7 +1076,13 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
case
TDMT_VND_CREATE_TABLE
:
case
TDMT_VND_CREATE_TABLE
:
case
TDMT_VND_SUBMIT
:
{
case
TDMT_VND_SUBMIT
:
{
msgSize
=
pTask
->
msgLen
;
msgSize
=
pTask
->
msgLen
;
msg
=
pTask
->
msg
;
msg
=
calloc
(
1
,
msgSize
);
if
(
NULL
==
msg
)
{
SCH_TASK_ELOG
(
"calloc %d failed"
,
msgSize
);
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
memcpy
(
msg
,
pTask
->
msg
,
msgSize
);
break
;
break
;
}
}
...
@@ -1549,29 +1564,24 @@ int32_t scheduleFetchRows(SSchJob *pJob, void** pData) {
...
@@ -1549,29 +1564,24 @@ int32_t scheduleFetchRows(SSchJob *pJob, void** pData) {
int8_t
status
=
SCH_GET_JOB_STATUS
(
pJob
);
int8_t
status
=
SCH_GET_JOB_STATUS
(
pJob
);
if
(
status
==
JOB_TASK_STATUS_DROPPING
)
{
if
(
status
==
JOB_TASK_STATUS_DROPPING
)
{
SCH_JOB_ELOG
(
"job is dropping, status:%d"
,
status
);
SCH_JOB_ELOG
(
"job is dropping, status:%d"
,
status
);
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
SCH_ERR_JRET
(
TSDB_CODE_SCH_STATUS_ERROR
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
}
if
(
!
SCH_JOB_NEED_FETCH
(
&
pJob
->
attr
))
{
if
(
!
SCH_JOB_NEED_FETCH
(
&
pJob
->
attr
))
{
SCH_JOB_ELOG
(
"no need to fetch data, status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
));
SCH_JOB_ELOG
(
"no need to fetch data, status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
));
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
SCH_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
}
if
(
atomic_val_compare_exchange_8
(
&
pJob
->
userFetch
,
0
,
1
)
!=
0
)
{
if
(
atomic_val_compare_exchange_8
(
&
pJob
->
userFetch
,
0
,
1
)
!=
0
)
{
SCH_JOB_ELOG
(
"prior fetching not finished, userFetch:%d"
,
atomic_load_8
(
&
pJob
->
userFetch
));
SCH_JOB_ELOG
(
"prior fetching not finished, userFetch:%d"
,
atomic_load_8
(
&
pJob
->
userFetch
));
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
SCH_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
}
if
(
JOB_TASK_STATUS_FAILED
==
status
||
JOB_TASK_STATUS_DROPPING
==
status
)
{
if
(
JOB_TASK_STATUS_FAILED
==
status
||
JOB_TASK_STATUS_DROPPING
==
status
)
{
*
pData
=
atomic_load_ptr
(
&
pJob
->
res
);
SCH_JOB_ELOG
(
"job failed or dropping, status:%d"
,
status
);
atomic_store_ptr
(
&
pJob
->
res
,
NULL
);
SCH_ERR_JRET
(
atomic_load_32
(
&
pJob
->
errCode
));
SCH_ERR_JRET
(
atomic_load_32
(
&
pJob
->
errCode
));
}
else
if
(
status
==
JOB_TASK_STATUS_SUCCEED
)
{
}
else
if
(
status
==
JOB_TASK_STATUS_SUCCEED
)
{
*
pData
=
atomic_load_ptr
(
&
pJob
->
res
);
SCH_JOB_ELOG
(
"job already succeed, status:%d"
,
status
);
atomic_store_ptr
(
&
pJob
->
res
,
NULL
);
goto
_return
;
goto
_return
;
}
else
if
(
status
==
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
}
else
if
(
status
==
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
SCH_ERR_JRET
(
schFetchFromRemote
(
pJob
));
SCH_ERR_JRET
(
schFetchFromRemote
(
pJob
));
...
@@ -1582,14 +1592,16 @@ int32_t scheduleFetchRows(SSchJob *pJob, void** pData) {
...
@@ -1582,14 +1592,16 @@ int32_t scheduleFetchRows(SSchJob *pJob, void** pData) {
status
=
SCH_GET_JOB_STATUS
(
pJob
);
status
=
SCH_GET_JOB_STATUS
(
pJob
);
if
(
JOB_TASK_STATUS_FAILED
==
status
||
JOB_TASK_STATUS_DROPPING
==
status
)
{
if
(
JOB_TASK_STATUS_FAILED
==
status
||
JOB_TASK_STATUS_DROPPING
==
status
)
{
code
=
atomic_load_32
(
&
pJob
->
errCode
);
SCH_JOB_ELOG
(
"job failed or dropping, status:%d"
,
status
);
SCH_ERR_JRET
(
code
);
SCH_ERR_JRET
(
atomic_load_32
(
&
pJob
->
errCode
)
);
}
}
if
(
pJob
->
res
&&
((
SRetrieveTableRsp
*
)
pJob
->
res
)
->
completed
)
{
if
(
pJob
->
res
&&
((
SRetrieveTableRsp
*
)
pJob
->
res
)
->
completed
)
{
SCH_ERR_JRET
(
schCheckAndUpdateJobStatus
(
pJob
,
JOB_TASK_STATUS_SUCCEED
));
SCH_ERR_JRET
(
schCheckAndUpdateJobStatus
(
pJob
,
JOB_TASK_STATUS_SUCCEED
));
}
}
_return:
while
(
true
)
{
while
(
true
)
{
*
pData
=
atomic_load_ptr
(
&
pJob
->
res
);
*
pData
=
atomic_load_ptr
(
&
pJob
->
res
);
...
@@ -1600,10 +1612,19 @@ int32_t scheduleFetchRows(SSchJob *pJob, void** pData) {
...
@@ -1600,10 +1612,19 @@ int32_t scheduleFetchRows(SSchJob *pJob, void** pData) {
break
;
break
;
}
}
_return:
if
(
NULL
==
*
pData
)
{
SRetrieveTableRsp
*
rsp
=
(
SRetrieveTableRsp
*
)
calloc
(
1
,
sizeof
(
SRetrieveTableRsp
));
if
(
rsp
)
{
rsp
->
completed
=
1
;
}
*
pData
=
rsp
;
}
atomic_val_compare_exchange_8
(
&
pJob
->
userFetch
,
1
,
0
);
atomic_val_compare_exchange_8
(
&
pJob
->
userFetch
,
1
,
0
);
SCH_JOB_DLOG
(
"fetch done, code:%x"
,
code
);
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
atomic_sub_fetch_32
(
&
pJob
->
ref
,
1
);
SCH_RET
(
code
);
SCH_RET
(
code
);
...
@@ -1683,6 +1704,7 @@ void scheduleFreeJob(void *job) {
...
@@ -1683,6 +1704,7 @@ void scheduleFreeJob(void *job) {
taosHashCleanup
(
pJob
->
succTasks
);
taosHashCleanup
(
pJob
->
succTasks
);
taosArrayDestroy
(
pJob
->
levels
);
taosArrayDestroy
(
pJob
->
levels
);
taosArrayDestroy
(
pJob
->
nodeList
);
tfree
(
pJob
->
res
);
tfree
(
pJob
->
res
);
...
...
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
76b8abe2
...
@@ -49,7 +49,7 @@ uint64_t schtQueryId = 1;
...
@@ -49,7 +49,7 @@ uint64_t schtQueryId = 1;
bool
schtTestStop
=
false
;
bool
schtTestStop
=
false
;
bool
schtTestDeadLoop
=
false
;
bool
schtTestDeadLoop
=
false
;
int32_t
schtTestMTRunSec
=
6
0
;
int32_t
schtTestMTRunSec
=
1
0
;
int32_t
schtTestPrintNum
=
1000
;
int32_t
schtTestPrintNum
=
1000
;
int32_t
schtStartFetch
=
0
;
int32_t
schtStartFetch
=
0
;
...
@@ -187,8 +187,6 @@ void schtRpcSendRequest(void *shandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int6
...
@@ -187,8 +187,6 @@ void schtRpcSendRequest(void *shandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int6
}
}
void
schtSetPlanToString
()
{
void
schtSetPlanToString
()
{
static
Stub
stub
;
static
Stub
stub
;
stub
.
set
(
qSubPlanToString
,
schtPlanToString
);
stub
.
set
(
qSubPlanToString
,
schtPlanToString
);
...
@@ -228,7 +226,12 @@ void schtSetRpcSendRequest() {
...
@@ -228,7 +226,12 @@ void schtSetRpcSendRequest() {
}
}
}
}
int32_t
schtAsyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
)
{
int32_t
schtAsyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
SMsgSendInfo
*
pInfo
)
{
if
(
pInfo
)
{
tfree
(
pInfo
->
param
);
tfree
(
pInfo
->
msgInfo
.
pData
);
free
(
pInfo
);
}
return
0
;
return
0
;
}
}
...
@@ -284,7 +287,7 @@ void *schtCreateFetchRspThread(void *param) {
...
@@ -284,7 +287,7 @@ void *schtCreateFetchRspThread(void *param) {
rsp
->
completed
=
1
;
rsp
->
completed
=
1
;
rsp
->
numOfRows
=
10
;
rsp
->
numOfRows
=
10
;
code
=
schHandleResponseMsg
(
job
,
job
->
fetchTask
,
TDMT_VND_FETCH_RSP
,
(
char
*
)
rsp
,
sizeof
(
rsp
),
0
);
code
=
schHandleResponseMsg
(
job
,
job
->
fetchTask
,
TDMT_VND_FETCH_RSP
,
(
char
*
)
rsp
,
sizeof
(
*
rsp
),
0
);
assert
(
code
==
0
);
assert
(
code
==
0
);
}
}
...
@@ -344,12 +347,6 @@ void* schtRunJobThread(void *aa) {
...
@@ -344,12 +347,6 @@ void* schtRunJobThread(void *aa) {
schtInitLogFile
();
schtInitLogFile
();
SArray
*
qnodeList
=
taosArrayInit
(
1
,
sizeof
(
SEpAddr
));
SEpAddr
qnodeAddr
=
{
0
};
strcpy
(
qnodeAddr
.
fqdn
,
"qnode0.ep"
);
qnodeAddr
.
port
=
6031
;
taosArrayPush
(
qnodeList
,
&
qnodeAddr
);
int32_t
code
=
schedulerInit
(
NULL
);
int32_t
code
=
schedulerInit
(
NULL
);
assert
(
code
==
0
);
assert
(
code
==
0
);
...
@@ -368,6 +365,13 @@ void* schtRunJobThread(void *aa) {
...
@@ -368,6 +365,13 @@ void* schtRunJobThread(void *aa) {
while
(
!
schtTestStop
)
{
while
(
!
schtTestStop
)
{
schtBuildQueryDag
(
&
dag
);
schtBuildQueryDag
(
&
dag
);
SArray
*
qnodeList
=
taosArrayInit
(
1
,
sizeof
(
SEpAddr
));
SEpAddr
qnodeAddr
=
{
0
};
strcpy
(
qnodeAddr
.
fqdn
,
"qnode0.ep"
);
qnodeAddr
.
port
=
6031
;
taosArrayPush
(
qnodeList
,
&
qnodeAddr
);
code
=
scheduleAsyncExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
&
job
);
code
=
scheduleAsyncExecJob
(
mockPointer
,
qnodeList
,
&
dag
,
&
job
);
assert
(
code
==
0
);
assert
(
code
==
0
);
...
@@ -475,8 +479,6 @@ void* schtRunJobThread(void *aa) {
...
@@ -475,8 +479,6 @@ void* schtRunJobThread(void *aa) {
code
=
scheduleFetchRows
(
pQueryJob
,
&
data
);
code
=
scheduleFetchRows
(
pQueryJob
,
&
data
);
assert
(
code
==
0
||
code
);
assert
(
code
==
0
||
code
);
assert
(
data
==
(
void
*
)
NULL
);
schtFreeQueryJob
(
0
);
schtFreeQueryJob
(
0
);
taosHashCleanup
(
execTasks
);
taosHashCleanup
(
execTasks
);
...
@@ -496,7 +498,7 @@ void* schtRunJobThread(void *aa) {
...
@@ -496,7 +498,7 @@ void* schtRunJobThread(void *aa) {
void
*
schtFreeJobThread
(
void
*
aa
)
{
void
*
schtFreeJobThread
(
void
*
aa
)
{
while
(
!
schtTestStop
)
{
while
(
!
schtTestStop
)
{
usleep
(
rand
()
%
20
00
);
usleep
(
rand
()
%
1
00
);
schtFreeQueryJob
(
1
);
schtFreeQueryJob
(
1
);
}
}
}
}
...
@@ -592,11 +594,12 @@ TEST(queryTest, normalCase) {
...
@@ -592,11 +594,12 @@ TEST(queryTest, normalCase) {
SRetrieveTableRsp
*
pRsp
=
(
SRetrieveTableRsp
*
)
data
;
SRetrieveTableRsp
*
pRsp
=
(
SRetrieveTableRsp
*
)
data
;
ASSERT_EQ
(
pRsp
->
completed
,
1
);
ASSERT_EQ
(
pRsp
->
completed
,
1
);
ASSERT_EQ
(
pRsp
->
numOfRows
,
10
);
ASSERT_EQ
(
pRsp
->
numOfRows
,
10
);
tfree
(
data
);
data
=
NULL
;
data
=
NULL
;
code
=
scheduleFetchRows
(
job
,
&
data
);
code
=
scheduleFetchRows
(
job
,
&
data
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
ASSERT_
EQ
(
data
,
(
void
*
)
NULL
);
ASSERT_
TRUE
(
data
);
scheduleFreeJob
(
pJob
);
scheduleFreeJob
(
pJob
);
...
@@ -607,7 +610,6 @@ TEST(queryTest, normalCase) {
...
@@ -607,7 +610,6 @@ TEST(queryTest, normalCase) {
TEST
(
insertTest
,
normalCase
)
{
TEST
(
insertTest
,
normalCase
)
{
void
*
mockPointer
=
(
void
*
)
0x1
;
void
*
mockPointer
=
(
void
*
)
0x1
;
char
*
clusterId
=
"cluster1"
;
char
*
clusterId
=
"cluster1"
;
...
@@ -672,7 +674,6 @@ TEST(multiThread, forceFree) {
...
@@ -672,7 +674,6 @@ TEST(multiThread, forceFree) {
sleep
(
3
);
sleep
(
3
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
srand
(
time
(
NULL
));
srand
(
time
(
NULL
));
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录