Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b2c16621
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b2c16621
编写于
8月 07, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] add check after killing query.
上级
0ee12789
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
16 deletion
+28
-16
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+16
-9
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+12
-7
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
b2c16621
...
...
@@ -6361,8 +6361,8 @@ static bool doBuildResCheck(SQInfo* pQInfo) {
pthread_mutex_unlock
(
&
pQInfo
->
lock
);
// clear qhandle owner
//
assert(pQInfo->owner == pthread_self());
//
pQInfo->owner = 0;
assert
(
pQInfo
->
owner
==
pthread_self
());
pQInfo
->
owner
=
0
;
return
buildRes
;
}
...
...
@@ -6370,14 +6370,14 @@ static bool doBuildResCheck(SQInfo* pQInfo) {
bool
qTableQuery
(
qinfo_t
qinfo
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
assert
(
pQInfo
&&
pQInfo
->
signature
==
pQInfo
);
//
int64_t threadId = pthread_self();
int64_t
threadId
=
pthread_self
();
//
int64_t curOwner = 0;
//
if ((curOwner = atomic_val_compare_exchange_64(&pQInfo->owner, 0, threadId)) != 0) {
//
qError("QInfo:%p qhandle is now executed by thread:%p", pQInfo, (void*) curOwner);
//
pQInfo->code = TSDB_CODE_QRY_IN_EXEC;
//
return false;
//
}
int64_t
curOwner
=
0
;
if
((
curOwner
=
atomic_val_compare_exchange_64
(
&
pQInfo
->
owner
,
0
,
threadId
))
!=
0
)
{
qError
(
"QInfo:%p qhandle is now executed by thread:%p"
,
pQInfo
,
(
void
*
)
curOwner
);
pQInfo
->
code
=
TSDB_CODE_QRY_IN_EXEC
;
return
false
;
}
if
(
IS_QUERY_KILLED
(
pQInfo
))
{
qDebug
(
"QInfo:%p it is already killed, abort"
,
pQInfo
);
...
...
@@ -6529,6 +6529,13 @@ int32_t qKillQuery(qinfo_t qinfo) {
}
setQueryKilled
(
pQInfo
);
// Wait for the query executing thread being stopped/
// Once the query is stopped, the owner of qHandle will be cleared immediately.
while
(
pQInfo
->
owner
!=
0
)
{
taosMsleep
(
100
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
b2c16621
...
...
@@ -225,8 +225,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
SRspRet
*
pRet
=
&
pReadMsg
->
rspRet
;
SRetrieveTableMsg
*
pRetrieve
=
pCont
;
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
pRetrieve
->
free
=
htons
(
pRetrieve
->
free
);
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p"
,
pVnode
->
vgId
,
(
void
*
)
pRetrieve
->
qhandle
,
pRetrieve
->
free
,
pReadMsg
->
rpcMsg
.
handle
);
...
...
@@ -236,24 +236,29 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
void
**
handle
=
qAcquireQInfo
(
pVnode
->
qMgmt
,
pRetrieve
->
qhandle
);
if
(
handle
==
NULL
||
(
*
handle
)
!=
(
void
*
)
pRetrieve
->
qhandle
)
{
code
=
TSDB_CODE_QRY_INVALID_QHANDLE
;
vDebug
(
"vgId:%d, invalid qhandle in
fetch
result, QInfo:%p"
,
pVnode
->
vgId
,
(
void
*
)
pRetrieve
->
qhandle
);
vDebug
(
"vgId:%d, invalid qhandle in
retrieving
result, QInfo:%p"
,
pVnode
->
vgId
,
(
void
*
)
pRetrieve
->
qhandle
);
vnodeBuildNoResultQueryRsp
(
pRet
);
return
code
;
}
if
(
pRetrieve
->
free
==
1
)
{
v
Debug
(
"vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
*
handle
);
v
Warn
(
"vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
*
handle
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
vnodeBuildNoResultQueryRsp
(
pRet
);
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
return
code
;
}
// todo add more error check here
// register the qhandle to connect to quit query immediate if connection is broken
vnodeNotifyCurrentQhandle
(
pReadMsg
->
rpcMsg
.
handle
,
*
handle
,
pVnode
->
vgId
);
if
(
vnodeNotifyCurrentQhandle
(
pReadMsg
->
rpcMsg
.
handle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pReadMsg
->
rpcMsg
.
handle
);
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
return
code
;
}
bool
freeHandle
=
true
;
bool
buildRes
=
false
;
...
...
@@ -273,8 +278,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
code
=
vnodeDumpQueryResult
(
pRet
,
pVnode
,
handle
,
&
freeHandle
);
}
//
if qhandle is not added into task queue, the query must be completed already or paused with error ,
// free qhandle immediately
//
If qhandle is not added into vread queue, the query should be completed already or paused with error.
//
Here
free qhandle immediately
if
(
freeHandle
)
{
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录