Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
89dcffce
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看板
提交
89dcffce
编写于
1月 11, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
7850f2a9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
156 addition
and
96 deletion
+156
-96
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+1
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+1
-0
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+88
-62
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+65
-32
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+1
-1
未找到文件。
include/libs/scheduler/scheduler.h
浏览文件 @
89dcffce
...
...
@@ -89,7 +89,7 @@ int32_t scheduleFetchRows(void *pJob, void **data);
* @param pJob
* @return
*/
int32_t
scheduleCancelJob
(
void
*
pJob
);
//
int32_t scheduleCancelJob(void *pJob);
/**
* Free the query job
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
89dcffce
无法预览此类型文件
source/libs/scheduler/src/scheduler.c
浏览文件 @
89dcffce
...
...
@@ -87,68 +87,72 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
int32_t
schCheckAndUpdateJobStatus
(
SSchJob
*
pJob
,
int8_t
newStatus
)
{
int32_t
code
=
0
;
int8_t
oriStatus
=
SCH_GET_JOB_STATUS
(
pJob
)
;
int8_t
oriStatus
=
0
;
/*
if (oriStatus == newStatus) {
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
switch (oriStatus) {
case JOB_TASK_STATUS_NULL:
if (newStatus != JOB_TASK_STATUS_EXECUTING
&& newStatus != JOB_TASK_STATUS_FAILED
&& newStatus != JOB_TASK_STATUS_NOT_START) {
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
break;
case JOB_TASK_STATUS_NOT_START:
if (newStatus != JOB_TASK_STATUS_CANCELLED) {
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
break;
case JOB_TASK_STATUS_EXECUTING:
if (newStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED
&& newStatus != JOB_TASK_STATUS_FAILED
&& newStatus != JOB_TASK_STATUS_CANCELLING
&& newStatus != JOB_TASK_STATUS_CANCELLED
&& newStatus != JOB_TASK_STATUS_DROPPING) {
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
}
break;
case JOB_TASK_STATUS_PARTIAL_SUCCEED:
if (newStatus != JOB_TASK_STATUS_EXECUTING
&& newStatus != JOB_TASK_STATUS_SUCCEED
&& newStatus != JOB_TASK_STATUS_CANCELLED) {
while
(
true
)
{
oriStatus
=
SCH_GET_JOB_STATUS
(
pJob
);
if
(
oriStatus
==
newStatus
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
switch
(
oriStatus
)
{
case
JOB_TASK_STATUS_NULL
:
if
(
newStatus
!=
JOB_TASK_STATUS_NOT_START
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break
;
case
JOB_TASK_STATUS_NOT_START
:
if
(
newStatus
!=
JOB_TASK_STATUS_EXECUTING
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break
;
case
JOB_TASK_STATUS_EXECUTING
:
if
(
newStatus
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
&&
newStatus
!=
JOB_TASK_STATUS_FAILED
&&
newStatus
!=
JOB_TASK_STATUS_CANCELLING
&&
newStatus
!=
JOB_TASK_STATUS_CANCELLED
&&
newStatus
!=
JOB_TASK_STATUS_DROPPING
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break
;
case
JOB_TASK_STATUS_PARTIAL_SUCCEED
:
if
(
newStatus
!=
JOB_TASK_STATUS_FAILED
&&
newStatus
!=
JOB_TASK_STATUS_SUCCEED
&&
newStatus
!=
JOB_TASK_STATUS_DROPPING
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break
;
case
JOB_TASK_STATUS_SUCCEED
:
case
JOB_TASK_STATUS_FAILED
:
case
JOB_TASK_STATUS_CANCELLING
:
if
(
newStatus
!=
JOB_TASK_STATUS_DROPPING
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break
;
case
JOB_TASK_STATUS_CANCELLED
:
case
JOB_TASK_STATUS_DROPPING
:
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break;
case JOB_TASK_STATUS_SUCCEED:
case JOB_TASK_STATUS_FAILED:
case JOB_TASK_STATUS_CANCELLING:
if (newStatus != JOB_TASK_STATUS_CANCELLED) {
break
;
default:
SCH_JOB_ELOG
(
"invalid job status:%d"
,
oriStatus
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
break;
case JOB_TASK_STATUS_CANCELLED:
case JOB_TASK_STATUS_DROPPING:
SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR);
break;
default:
qError("invalid task status:%d", oriStatus);
return TSDB_CODE_QRY_APP_ERROR;
}
*/
}
if
(
oriStatus
!=
atomic_val_compare_exchange_8
(
&
pJob
->
status
,
oriStatus
,
newStatus
))
{
continue
;
}
SCH_SET_JOB_STATUS
(
pJob
,
newStatus
);
SCH_JOB_DLOG
(
"job status updated from %d to %d"
,
oriStatus
,
newStatus
);
SCH_JOB_DLOG
(
"status updated from %d to %d"
,
oriStatus
,
newStatus
);
break
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -507,6 +511,7 @@ int32_t schTaskCheckAndSetRetry(SSchJob *job, SSchTask *task, int32_t errCode, b
}
// Note: no more error processing, handled in function internal
int32_t
schFetchFromRemote
(
SSchJob
*
pJob
)
{
int32_t
code
=
0
;
...
...
@@ -515,7 +520,13 @@ int32_t schFetchFromRemote(SSchJob *pJob) {
return
TSDB_CODE_SUCCESS
;
}
if
(
atomic_load_ptr
(
&
pJob
->
res
))
void
*
res
=
atomic_load_ptr
(
&
pJob
->
res
);
if
(
res
)
{
atomic_val_compare_exchange_32
(
&
pJob
->
remoteFetch
,
1
,
0
);
SCH_JOB_DLOG
(
"res already fetched, res:%p"
,
res
);
return
TSDB_CODE_SUCCESS
;
}
SCH_ERR_JRET
(
schBuildAndSendMsg
(
pJob
,
pJob
->
fetchTask
,
&
pJob
->
resNode
,
TDMT_VND_FETCH
));
...
...
@@ -525,12 +536,15 @@ _return:
atomic_val_compare_exchange_32
(
&
pJob
->
remoteFetch
,
1
,
0
);
schProcessOnJobFailure
(
pJob
,
code
);
return
code
;
}
// Note: no more error processing, handled in function internal
int32_t
schProcessOnJobFailure
(
SSchJob
*
pJob
,
int32_t
errCode
)
{
// if already FAILED, no more processing
SCH_ERR_RET
(
schCheckAndUpdateJobStatus
(
pJob
,
JOB_TASK_STATUS_FAILED
));
if
(
errCode
)
{
...
...
@@ -813,7 +827,7 @@ int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, in
SSchJob
**
job
=
taosHashGet
(
schMgmt
.
jobs
,
&
pParam
->
queryId
,
sizeof
(
pParam
->
queryId
));
if
(
NULL
==
job
||
NULL
==
(
*
job
))
{
qError
(
"QID:%"
PRIx64
" taosHashGet queryId not exist"
,
pParam
->
queryId
);
qError
(
"QID:%"
PRIx64
" taosHashGet queryId not exist
, may be dropped
"
,
pParam
->
queryId
);
SCH_ERR_JRET
(
TSDB_CODE_SCH_INTERNAL_ERROR
);
}
...
...
@@ -1147,7 +1161,7 @@ void schDropTaskOnExecutedNode(SSchJob *pJob, SSchTask *pTask) {
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
pTask
->
execAddrs
);
if
(
size
<=
0
)
{
SCH_TASK_DLOG
(
"
empty exec address
, status:%d"
,
SCH_GET_TASK_STATUS
(
pTask
));
SCH_TASK_DLOG
(
"
task has no exec address, no need to drop it
, status:%d"
,
SCH_GET_TASK_STATUS
(
pTask
));
return
;
}
...
...
@@ -1157,6 +1171,8 @@ void schDropTaskOnExecutedNode(SSchJob *pJob, SSchTask *pTask) {
schBuildAndSendMsg
(
pJob
,
pTask
,
addr
,
TDMT_VND_DROP_TASK
);
}
SCH_TASK_DLOG
(
"task has %d exec address"
,
size
);
}
void
schDropTaskInHashList
(
SSchJob
*
pJob
,
SHashObj
*
list
)
{
...
...
@@ -1331,6 +1347,12 @@ int32_t scheduleFetchRows(void *job, void **data) {
SSchJob
*
pJob
=
job
;
int32_t
code
=
0
;
int8_t
status
=
SCH_GET_JOB_STATUS
(
pJob
);
if
(
status
==
JOB_TASK_STATUS_DROPPING
)
{
SCH_JOB_ELOG
(
"job is dropping, status:%d"
,
status
);
return
TSDB_CODE_SCH_STATUS_ERROR
;
}
atomic_add_fetch_32
(
&
pJob
->
ref
,
1
);
if
(
!
SCH_JOB_NEED_FETCH
(
&
pJob
->
attr
))
{
...
...
@@ -1345,8 +1367,6 @@ int32_t scheduleFetchRows(void *job, void **data) {
SCH_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
int8_t
status
=
SCH_GET_JOB_STATUS
(
pJob
);
if
(
status
==
JOB_TASK_STATUS_FAILED
)
{
*
data
=
atomic_load_ptr
(
&
pJob
->
res
);
atomic_store_ptr
(
&
pJob
->
res
,
NULL
);
...
...
@@ -1414,6 +1434,10 @@ void scheduleFreeJob(void *job) {
return
;
}
schCheckAndUpdateJobStatus
(
pJob
,
JOB_TASK_STATUS_DROPPING
);
SCH_JOB_DLOG
(
"job removed from list, no further ref, ref:%d"
,
atomic_load_32
(
&
pJob
->
ref
));
while
(
true
)
{
int32_t
ref
=
atomic_load_32
(
&
pJob
->
ref
);
if
(
0
==
ref
)
{
...
...
@@ -1425,6 +1449,8 @@ void scheduleFreeJob(void *job) {
}
}
SCH_JOB_DLOG
(
"job no ref now, status:%d"
,
SCH_GET_JOB_STATUS
(
pJob
));
if
(
pJob
->
status
==
JOB_TASK_STATUS_EXECUTING
)
{
schCancelJob
(
pJob
);
}
...
...
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
89dcffce
...
...
@@ -38,52 +38,73 @@ namespace {
extern
"C"
int32_t
schHandleResponseMsg
(
SSchJob
*
job
,
SSchTask
*
task
,
int32_t
msgType
,
char
*
msg
,
int32_t
msgSize
,
int32_t
rspCode
);
void
schtInitLogFile
()
{
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
int32_t
maxLogFileNum
=
10
;
tsAsyncLog
=
0
;
qDebugFlag
=
159
;
char
temp
[
128
]
=
{
0
};
sprintf
(
temp
,
"%s/%s"
,
tsLogDir
,
defaultLogFileNamePrefix
);
if
(
taosInitLog
(
temp
,
tsNumOfLogLines
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
void
schtBuildQueryDag
(
SQueryDag
*
dag
)
{
uint64_t
qId
=
0x0000000000000001
;
dag
->
queryId
=
qId
;
dag
->
numOfSubplans
=
2
;
dag
->
pSubplans
=
taosArrayInit
(
dag
->
numOfSubplans
,
POINTER_BYTES
);
SArray
*
scan
=
taosArrayInit
(
1
,
sizeof
(
SSubplan
)
);
SArray
*
merge
=
taosArrayInit
(
1
,
sizeof
(
SSubplan
)
);
SArray
*
scan
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
merge
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SSubplan
scanPlan
=
{
0
}
;
SSubplan
mergePlan
=
{
0
}
;
scanPlan
.
id
.
queryId
=
qId
;
scanPlan
.
id
.
templateId
=
0x0000000000000002
;
scanPlan
.
id
.
subplanId
=
0x0000000000000003
;
scanPlan
.
type
=
QUERY_TYPE_SCAN
;
scanPlan
.
execNode
.
numOfEps
=
1
;
scanPlan
.
execNode
.
nodeId
=
1
;
scanPlan
.
execNode
.
inUse
=
0
;
scanPlan
.
execNode
.
epAddr
[
0
].
port
=
6030
;
strcpy
(
scanPlan
.
execNode
.
epAddr
[
0
].
fqdn
,
"ep0"
);
scanPlan
.
pChildren
=
NULL
;
scanPlan
.
level
=
1
;
scanPlan
.
pParents
=
taosArrayInit
(
1
,
POINTER_BYTES
);
scanPlan
.
pNode
=
(
SPhyNode
*
)
calloc
(
1
,
sizeof
(
SPhyNode
));
mergePlan
.
id
.
queryId
=
qId
;
mergePlan
.
id
.
templateId
=
0x4444444444
;
mergePlan
.
id
.
subplanId
=
0x5555555555
;
mergePlan
.
type
=
QUERY_TYPE_MERGE
;
mergePlan
.
level
=
0
;
mergePlan
.
execNode
.
numOfEps
=
0
;
mergePlan
.
pChildren
=
taosArrayInit
(
1
,
POINTER_BYTES
);
mergePlan
.
pParents
=
NULL
;
mergePlan
.
pNode
=
(
SPhyNode
*
)
calloc
(
1
,
sizeof
(
SPhyNode
));
SSubplan
*
scanPlan
=
(
SSubplan
*
)
calloc
(
1
,
sizeof
(
SSubplan
))
;
SSubplan
*
mergePlan
=
(
SSubplan
*
)
calloc
(
1
,
sizeof
(
SSubplan
))
;
scanPlan
->
id
.
queryId
=
qId
;
scanPlan
->
id
.
templateId
=
0x0000000000000002
;
scanPlan
->
id
.
subplanId
=
0x0000000000000003
;
scanPlan
->
type
=
QUERY_TYPE_SCAN
;
scanPlan
->
execNode
.
numOfEps
=
1
;
scanPlan
->
execNode
.
nodeId
=
1
;
scanPlan
->
execNode
.
inUse
=
0
;
scanPlan
->
execNode
.
epAddr
[
0
].
port
=
6030
;
strcpy
(
scanPlan
->
execNode
.
epAddr
[
0
].
fqdn
,
"ep0"
);
scanPlan
->
pChildren
=
NULL
;
scanPlan
->
level
=
1
;
scanPlan
->
pParents
=
taosArrayInit
(
1
,
POINTER_BYTES
);
scanPlan
->
pNode
=
(
SPhyNode
*
)
calloc
(
1
,
sizeof
(
SPhyNode
));
mergePlan
->
id
.
queryId
=
qId
;
mergePlan
->
id
.
templateId
=
0x4444444444
;
mergePlan
->
id
.
subplanId
=
0x5555555555
;
mergePlan
->
type
=
QUERY_TYPE_MERGE
;
mergePlan
->
level
=
0
;
mergePlan
->
execNode
.
numOfEps
=
0
;
mergePlan
->
pChildren
=
taosArrayInit
(
1
,
POINTER_BYTES
);
mergePlan
->
pParents
=
NULL
;
mergePlan
->
pNode
=
(
SPhyNode
*
)
calloc
(
1
,
sizeof
(
SPhyNode
));
SSubplan
*
mergePointer
=
(
SSubplan
*
)
taosArrayPush
(
merge
,
&
mergePlan
);
SSubplan
*
scanPointer
=
(
SSubplan
*
)
taosArrayPush
(
scan
,
&
scanPlan
);
taosArrayPush
(
mergeP
ointer
->
pChildren
,
&
scanPointer
);
taosArrayPush
(
scanP
ointer
->
pParents
,
&
mergePointer
);
taosArrayPush
(
mergeP
lan
->
pChildren
,
&
scanPlan
);
taosArrayPush
(
scanP
lan
->
pParents
,
&
mergePlan
);
taosArrayPush
(
dag
->
pSubplans
,
&
merge
);
taosArrayPush
(
dag
->
pSubplans
,
&
scan
);
}
void
schtFreeQueryDag
(
SQueryDag
*
dag
)
{
}
void
schtBuildInsertDag
(
SQueryDag
*
dag
)
{
uint64_t
qId
=
0x0000000000000002
;
...
...
@@ -138,8 +159,8 @@ int32_t schtPlanToString(const SSubplan *subplan, char** str, int32_t* len) {
return
0
;
}
int32_t
schtExecNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
)
{
return
0
;
void
schtExecNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
)
{
}
...
...
@@ -209,6 +230,9 @@ TEST(queryTest, normalCase) {
SVgroupInfo
vgInfo
=
{
0
};
void
*
pJob
=
NULL
;
SQueryDag
dag
=
{
0
};
schtInitLogFile
();
SArray
*
qnodeList
=
taosArrayInit
(
1
,
sizeof
(
SEpAddr
));
SEpAddr
qnodeAddr
=
{
0
};
...
...
@@ -295,6 +319,8 @@ TEST(queryTest, normalCase) {
ASSERT_EQ
(
data
,
(
void
*
)
NULL
);
scheduleFreeJob
(
pJob
);
schtFreeQueryDag
(
&
dag
);
}
...
...
@@ -308,6 +334,9 @@ TEST(insertTest, normalCase) {
SVgroupInfo
vgInfo
=
{
0
};
SQueryDag
dag
=
{
0
};
uint64_t
numOfRows
=
0
;
schtInitLogFile
();
SArray
*
qnodeList
=
taosArrayInit
(
1
,
sizeof
(
SEpAddr
));
SEpAddr
qnodeAddr
=
{
0
};
...
...
@@ -336,7 +365,11 @@ TEST(insertTest, normalCase) {
scheduleFreeJob
(
pInsertJob
);
}
TEST
(
multiThread
,
forceFree
)
{
schtInitLogFile
();
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
source/os/src/osSysinfo.c
浏览文件 @
89dcffce
...
...
@@ -1087,7 +1087,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
return
0
;
}
return
-
1
;
return
0
;
}
char
*
taosGetCmdlineByPID
(
int
pid
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录