Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
75338f80
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看板
提交
75338f80
编写于
1月 20, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
64d3ab2e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
30 deletion
+46
-30
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+46
-30
未找到文件。
source/libs/qworker/src/qworker.c
浏览文件 @
75338f80
...
@@ -254,6 +254,19 @@ int32_t qwAcquireTaskCtx(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_
...
@@ -254,6 +254,19 @@ int32_t qwAcquireTaskCtx(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
qwGetTaskCtx
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
SQWTaskCtx
**
ctx
)
{
char
id
[
sizeof
(
qId
)
+
sizeof
(
tId
)]
=
{
0
};
QW_SET_QTID
(
id
,
qId
,
tId
);
*
ctx
=
taosHashGet
(
mgmt
->
ctxHash
,
id
,
sizeof
(
id
));
if
(
NULL
==
(
*
ctx
))
{
QW_TASK_ELOG
(
"ctx not in ctxHash, id:%s"
,
id
);
QW_ERR_RET
(
TSDB_CODE_QRY_RES_CACHE_NOT_EXIST
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
qwAddTaskCtxImpl
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
int32_t
rwType
,
int32_t
status
,
SQWTaskCtx
**
ctx
)
{
int32_t
qwAddTaskCtxImpl
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
int32_t
rwType
,
int32_t
status
,
SQWTaskCtx
**
ctx
)
{
char
id
[
sizeof
(
qId
)
+
sizeof
(
tId
)]
=
{
0
};
char
id
[
sizeof
(
qId
)
+
sizeof
(
tId
)]
=
{
0
};
QW_SET_QTID
(
id
,
qId
,
tId
);
QW_SET_QTID
(
id
,
qId
,
tId
);
...
@@ -294,19 +307,6 @@ int32_t qwAddTaskCtx(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tI
...
@@ -294,19 +307,6 @@ int32_t qwAddTaskCtx(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tI
QW_RET
(
qwAddTaskCtxImpl
(
QW_FPARAMS
(),
0
,
0
,
NULL
));
QW_RET
(
qwAddTaskCtxImpl
(
QW_FPARAMS
(),
0
,
0
,
NULL
));
}
}
int32_t
qwGetTaskCtx
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
SQWTaskCtx
**
ctx
)
{
char
id
[
sizeof
(
qId
)
+
sizeof
(
tId
)]
=
{
0
};
QW_SET_QTID
(
id
,
qId
,
tId
);
*
ctx
=
taosHashGet
(
mgmt
->
ctxHash
,
id
,
sizeof
(
id
));
if
(
NULL
==
(
*
ctx
))
{
QW_TASK_ELOG
(
"ctx not in ctxHash, id:%s"
,
id
);
QW_ERR_RET
(
TSDB_CODE_QRY_RES_CACHE_NOT_EXIST
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
qwAddAcquireTaskCtx
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
int32_t
rwType
,
SQWTaskCtx
**
ctx
)
{
int32_t
qwAddAcquireTaskCtx
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
int32_t
rwType
,
SQWTaskCtx
**
ctx
)
{
...
@@ -322,16 +322,33 @@ void qwReleaseTaskCtx(int32_t rwType, SQWorkerMgmt *mgmt) {
...
@@ -322,16 +322,33 @@ void qwReleaseTaskCtx(int32_t rwType, SQWorkerMgmt *mgmt) {
QW_UNLOCK
(
rwType
,
&
mgmt
->
ctxLock
);
QW_UNLOCK
(
rwType
,
&
mgmt
->
ctxLock
);
}
}
void
qwFreeTaskHandle
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
)
{
// RC WARNING
qTaskInfo_t
taskHandle
=
atomic_load_ptr
(
&
ctx
->
taskHandle
);
if
(
taskHandle
&&
atomic_val_compare_exchange_ptr
(
&
ctx
->
taskHandle
,
taskHandle
,
NULL
))
{
qDestroyTask
(
taskHandle
);
}
}
void
qwFreeTask
(
SQWorkerMgmt
*
mgmt
,
uint64_t
sId
,
uint64_t
qId
,
uint64_t
tId
,
SQWTaskCtx
*
ctx
)
{
int32_t
qwKillTaskHandle
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
)
{
if
(
ctx
->
taskHandle
)
{
int32_t
code
=
0
;
qDestroyTask
(
ctx
->
taskHandle
);
// RC WARNING
ctx
->
taskHandle
=
NULL
;
qTaskInfo_t
taskHandle
=
atomic_load_ptr
(
&
ctx
->
taskHandle
);
if
(
taskHandle
&&
atomic_val_compare_exchange_ptr
(
&
ctx
->
taskHandle
,
taskHandle
,
NULL
))
{
code
=
qKillTask
(
taskHandle
);
atomic_store_ptr
(
&
ctx
->
taskHandle
,
taskHandle
);
}
}
// TODO
QW_RET
(
code
);
if
(
ctx
->
sinkHandle
)
{
}
void
qwFreeTask
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
)
{
qwFreeTaskHandle
(
QW_FPARAMS
(),
ctx
);
if
(
ctx
->
sinkHandle
)
{
dsDestroyDataSinker
(
ctx
->
sinkHandle
);
ctx
->
sinkHandle
=
NULL
;
}
}
}
}
...
@@ -425,7 +442,7 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId,
...
@@ -425,7 +442,7 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId,
SQWTaskCtx
*
ctx
=
NULL
;
SQWTaskCtx
*
ctx
=
NULL
;
bool
locked
=
false
;
bool
locked
=
false
;
QW_ERR_JRET
(
qwAddGetTaskCtx
(
QW_FPARAMS
(),
QW_READ
,
&
ctx
));
QW_ERR_JRET
(
qwAddGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
...
@@ -437,9 +454,7 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId,
...
@@ -437,9 +454,7 @@ int32_t qwDropTask(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t tId,
}
}
if
(
QW_IN_EXECUTOR
(
ctx
))
{
if
(
QW_IN_EXECUTOR
(
ctx
))
{
if
(
ctx
->
taskHandle
)
{
QW_ERR_JRET
(
qwKillTaskHandle
(
QW_FPARAMS
(),
ctx
));
QW_ERR_JRET
(
qKillTask
(
ctx
->
taskHandle
));
}
QW_ERR_JRET
(
qwUpdateTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_DROPPING
));
QW_ERR_JRET
(
qwUpdateTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_DROPPING
));
}
else
if
(
ctx
->
phase
>
0
)
{
}
else
if
(
ctx
->
phase
>
0
)
{
...
@@ -587,7 +602,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
...
@@ -587,7 +602,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
switch
(
phase
)
{
switch
(
phase
)
{
case
QW_PHASE_PRE_QUERY
:
{
case
QW_PHASE_PRE_QUERY
:
{
QW_ERR_JRET
(
qwAddGetTaskCtx
(
QW_FPARAMS
(),
QW_READ
,
&
ctx
));
QW_ERR_JRET
(
qwAddGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
ctx
->
phase
=
phase
;
ctx
->
phase
=
phase
;
...
@@ -607,7 +622,6 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
...
@@ -607,7 +622,6 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
output
->
needStop
=
true
;
output
->
needStop
=
true
;
QW_ERR_JRET
(
qwAddTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_CANCELLED
));
QW_ERR_JRET
(
qwAddTaskStatus
(
QW_FPARAMS
(),
JOB_TASK_STATUS_CANCELLED
));
qwFreeTask
(
QW_FPARAMS
(),
ctx
);
QW_SET_EVENT_PROCESSED
(
ctx
,
QW_EVENT_CANCEL
);
QW_SET_EVENT_PROCESSED
(
ctx
,
QW_EVENT_CANCEL
);
...
@@ -620,7 +634,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
...
@@ -620,7 +634,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
break
;
break
;
}
}
case
QW_PHASE_POST_QUERY
:
{
case
QW_PHASE_POST_QUERY
:
{
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
QW_READ
,
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
...
@@ -702,7 +716,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
...
@@ -702,7 +716,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
break
;
break
;
}
}
case
QW_PHASE_POST_CQUERY
:
{
case
QW_PHASE_POST_CQUERY
:
{
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
QW_READ
,
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
...
@@ -738,7 +752,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
...
@@ -738,7 +752,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
break
;
break
;
}
}
case
QW_PHASE_PRE_FETCH
:
{
case
QW_PHASE_PRE_FETCH
:
{
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
QW_READ
,
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
...
@@ -786,7 +800,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
...
@@ -786,7 +800,7 @@ int32_t qwHandleTaskEvent(QW_FPARAMS_DEF, int32_t phase, SQWPhaseInput *input, S
break
;
break
;
}
}
case
QW_PHASE_POST_FETCH
:
{
case
QW_PHASE_POST_FETCH
:
{
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
QW_READ
,
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
...
@@ -984,6 +998,7 @@ int32_t qwProcessCQuery(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t
...
@@ -984,6 +998,7 @@ int32_t qwProcessCQuery(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t
if
((
!
sOutput
.
queryEnd
)
&&
(
DS_BUF_LOW
==
sOutput
.
bufStatus
||
DS_BUF_EMPTY
==
sOutput
.
bufStatus
))
{
if
((
!
sOutput
.
queryEnd
)
&&
(
DS_BUF_LOW
==
sOutput
.
bufStatus
||
DS_BUF_EMPTY
==
sOutput
.
bufStatus
))
{
QW_TASK_DLOG
(
"task not end, need to continue, bufStatus:%d"
,
sOutput
.
bufStatus
);
QW_TASK_DLOG
(
"task not end, need to continue, bufStatus:%d"
,
sOutput
.
bufStatus
);
// RC WARNING
atomic_store_8
(
&
ctx
->
queryContinue
,
1
);
atomic_store_8
(
&
ctx
->
queryContinue
,
1
);
}
}
...
@@ -1061,6 +1076,7 @@ int32_t qwProcessFetch(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t
...
@@ -1061,6 +1076,7 @@ int32_t qwProcessFetch(SQWorkerMgmt *mgmt, uint64_t sId, uint64_t qId, uint64_t
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
QW_LOCK
(
QW_WRITE
,
&
ctx
->
lock
);
locked
=
true
;
locked
=
true
;
// RC WARNING
if
(
QW_IN_EXECUTOR
(
ctx
))
{
if
(
QW_IN_EXECUTOR
(
ctx
))
{
atomic_store_8
(
&
ctx
->
queryContinue
,
1
);
atomic_store_8
(
&
ctx
->
queryContinue
,
1
);
}
else
if
(
0
==
atomic_load_8
(
&
ctx
->
inQueue
))
{
}
else
if
(
0
==
atomic_load_8
(
&
ctx
->
inQueue
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录