Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a657413f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
a657413f
编写于
7月 01, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: kill query
上级
f421ab09
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
112 addition
and
4 deletion
+112
-4
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+17
-2
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+4
-2
tests/script/api/stopquery.c
tests/script/api/stopquery.c
+91
-0
未找到文件。
source/client/src/clientEnv.c
浏览文件 @
a657413f
...
@@ -153,7 +153,13 @@ void destroyAppInst(SAppInstInfo *pAppInfo) {
...
@@ -153,7 +153,13 @@ void destroyAppInst(SAppInstInfo *pAppInfo) {
}
}
void
destroyTscObj
(
void
*
pObj
)
{
void
destroyTscObj
(
void
*
pObj
)
{
if
(
NULL
==
pObj
)
{
return
;
}
STscObj
*
pTscObj
=
pObj
;
STscObj
*
pTscObj
=
pObj
;
int64_t
tscId
=
pTscObj
->
id
;
tscDebug
(
"begin to destroy tscObj %"
PRIx64
" p:%p"
,
tscId
,
pTscObj
);
SClientHbKey
connKey
=
{.
tscRid
=
pTscObj
->
id
,
.
connType
=
pTscObj
->
connType
};
SClientHbKey
connKey
=
{.
tscRid
=
pTscObj
->
id
,
.
connType
=
pTscObj
->
connType
};
hbDeregisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
connKey
);
hbDeregisterConn
(
pTscObj
->
pAppInfo
->
pAppHbMgr
,
connKey
);
...
@@ -168,6 +174,8 @@ void destroyTscObj(void *pObj) {
...
@@ -168,6 +174,8 @@ void destroyTscObj(void *pObj) {
}
}
taosThreadMutexDestroy
(
&
pTscObj
->
mutex
);
taosThreadMutexDestroy
(
&
pTscObj
->
mutex
);
taosMemoryFreeClear
(
pTscObj
);
taosMemoryFreeClear
(
pTscObj
);
tscDebug
(
"end to destroy tscObj %"
PRIx64
" p:%p"
,
tscId
,
pTscObj
);
}
}
void
*
createTscObj
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
int32_t
connType
,
SAppInstInfo
*
pAppInfo
)
{
void
*
createTscObj
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
int32_t
connType
,
SAppInstInfo
*
pAppInfo
)
{
...
@@ -261,9 +269,14 @@ int32_t releaseRequest(int64_t rid) { return taosReleaseRef(clientReqRefPool, ri
...
@@ -261,9 +269,14 @@ int32_t releaseRequest(int64_t rid) { return taosReleaseRef(clientReqRefPool, ri
int32_t
removeRequest
(
int64_t
rid
)
{
return
taosRemoveRef
(
clientReqRefPool
,
rid
);
}
int32_t
removeRequest
(
int64_t
rid
)
{
return
taosRemoveRef
(
clientReqRefPool
,
rid
);
}
void
doDestroyRequest
(
void
*
p
)
{
void
doDestroyRequest
(
void
*
p
)
{
assert
(
p
!=
NULL
);
if
(
NULL
==
p
)
{
return
;
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
p
;
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
p
;
int64_t
reqId
=
pRequest
->
self
;
tscDebug
(
"begin to destroy request %"
PRIx64
" p:%p"
,
reqId
,
pRequest
);
taosHashRemove
(
pRequest
->
pTscObj
->
pRequests
,
&
pRequest
->
self
,
sizeof
(
pRequest
->
self
));
taosHashRemove
(
pRequest
->
pTscObj
->
pRequests
,
&
pRequest
->
self
,
sizeof
(
pRequest
->
self
));
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
...
@@ -285,6 +298,8 @@ void doDestroyRequest(void *p) {
...
@@ -285,6 +298,8 @@ void doDestroyRequest(void *p) {
deregisterRequest
(
pRequest
);
deregisterRequest
(
pRequest
);
}
}
taosMemoryFreeClear
(
pRequest
);
taosMemoryFreeClear
(
pRequest
);
tscDebug
(
"end to destroy request %"
PRIx64
" p:%p"
,
reqId
,
pRequest
);
}
}
void
destroyRequest
(
SRequestObj
*
pRequest
)
{
void
destroyRequest
(
SRequestObj
*
pRequest
)
{
...
...
source/libs/scheduler/src/schJob.c
浏览文件 @
a657413f
...
@@ -1495,6 +1495,8 @@ void schFreeJobImpl(void *job) {
...
@@ -1495,6 +1495,8 @@ void schFreeJobImpl(void *job) {
uint64_t
queryId
=
pJob
->
queryId
;
uint64_t
queryId
=
pJob
->
queryId
;
int64_t
refId
=
pJob
->
refId
;
int64_t
refId
=
pJob
->
refId
;
qDebug
(
"QID:0x%"
PRIx64
" begin to free sch job, refId:0x%"
PRIx64
", pointer:%p"
,
queryId
,
refId
,
pJob
);
if
(
pJob
->
status
==
JOB_TASK_STATUS_EXECUTING
)
{
if
(
pJob
->
status
==
JOB_TASK_STATUS_EXECUTING
)
{
schCancelJob
(
pJob
);
schCancelJob
(
pJob
);
}
}
...
@@ -1535,12 +1537,12 @@ void schFreeJobImpl(void *job) {
...
@@ -1535,12 +1537,12 @@ void schFreeJobImpl(void *job) {
taosMemoryFreeClear
(
pJob
->
resData
);
taosMemoryFreeClear
(
pJob
->
resData
);
taosMemoryFree
(
pJob
);
taosMemoryFree
(
pJob
);
qDebug
(
"QID:0x%"
PRIx64
" sch job freed, refId:0x%"
PRIx64
", pointer:%p"
,
queryId
,
refId
,
pJob
);
int32_t
jobNum
=
atomic_sub_fetch_32
(
&
schMgmt
.
jobNum
,
1
);
int32_t
jobNum
=
atomic_sub_fetch_32
(
&
schMgmt
.
jobNum
,
1
);
if
(
jobNum
==
0
)
{
if
(
jobNum
==
0
)
{
schCloseJobRef
();
schCloseJobRef
();
}
}
qDebug
(
"QID:0x%"
PRIx64
" sch job freed, refId:0x%"
PRIx64
", pointer:%p"
,
queryId
,
refId
,
pJob
);
}
}
int32_t
schLaunchStaticExplainJob
(
SSchedulerReq
*
pReq
,
SSchJob
*
pJob
,
bool
sync
)
{
int32_t
schLaunchStaticExplainJob
(
SSchedulerReq
*
pReq
,
SSchJob
*
pJob
,
bool
sync
)
{
...
...
tests/script/api/stopquery.c
浏览文件 @
a657413f
...
@@ -156,6 +156,28 @@ void sqCloseQueryCb(void *param, TAOS_RES *pRes, int code) {
...
@@ -156,6 +156,28 @@ void sqCloseQueryCb(void *param, TAOS_RES *pRes, int code) {
}
}
}
}
void
sqKillFetchCb
(
void
*
param
,
TAOS_RES
*
pRes
,
int
numOfRows
)
{
SSP_CB_PARAM
*
qParam
=
(
SSP_CB_PARAM
*
)
param
;
taos_kill_query
(
qParam
->
taos
);
*
qParam
->
end
=
1
;
}
void
sqKillQueryCb
(
void
*
param
,
TAOS_RES
*
pRes
,
int
code
)
{
SSP_CB_PARAM
*
qParam
=
(
SSP_CB_PARAM
*
)
param
;
if
(
code
==
0
&&
pRes
)
{
if
(
qParam
->
fetch
)
{
taos_fetch_rows_a
(
pRes
,
sqKillFetchCb
,
param
);
}
else
{
taos_kill_query
(
qParam
->
taos
);
*
qParam
->
end
=
1
;
}
}
else
{
sqExit
(
"select"
,
taos_errstr
(
pRes
));
}
}
int
sqSyncStopQuery
(
bool
fetch
)
{
int
sqSyncStopQuery
(
bool
fetch
)
{
CASE_ENTER
();
CASE_ENTER
();
for
(
int32_t
i
=
0
;
i
<
runTimes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
runTimes
;
++
i
)
{
...
@@ -391,6 +413,69 @@ int sqConSyncCloseQuery(bool fetch) {
...
@@ -391,6 +413,69 @@ int sqConSyncCloseQuery(bool fetch) {
CASE_LEAVE
();
CASE_LEAVE
();
}
}
int
sqSyncKillQuery
(
bool
fetch
)
{
CASE_ENTER
();
for
(
int32_t
i
=
0
;
i
<
runTimes
;
++
i
)
{
char
sql
[
1024
]
=
{
0
};
int32_t
code
=
0
;
TAOS
*
taos
=
taos_connect
(
hostName
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
sqExit
(
"taos_connect"
,
taos_errstr
(
NULL
));
sprintf
(
sql
,
"reset query cache"
);
sqExecSQL
(
taos
,
sql
);
sprintf
(
sql
,
"use %s"
,
dbName
);
sqExecSQL
(
taos
,
sql
);
sprintf
(
sql
,
"select * from %s"
,
tbName
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
pRes
);
if
(
code
)
{
sqExit
(
"taos_query"
,
taos_errstr
(
pRes
));
}
if
(
fetch
)
{
taos_fetch_row
(
pRes
);
}
taos_kill_query
(
taos
);
taos_close
(
taos
);
}
CASE_LEAVE
();
}
int
sqAsyncKillQuery
(
bool
fetch
)
{
CASE_ENTER
();
for
(
int32_t
i
=
0
;
i
<
runTimes
;
++
i
)
{
char
sql
[
1024
]
=
{
0
};
int32_t
code
=
0
;
TAOS
*
taos
=
taos_connect
(
hostName
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
sqExit
(
"taos_connect"
,
taos_errstr
(
NULL
));
sprintf
(
sql
,
"reset query cache"
);
sqExecSQL
(
taos
,
sql
);
sprintf
(
sql
,
"use %s"
,
dbName
);
sqExecSQL
(
taos
,
sql
);
sprintf
(
sql
,
"select * from %s"
,
tbName
);
int32_t
qEnd
=
0
;
SSP_CB_PARAM
param
=
{
0
};
param
.
fetch
=
fetch
;
param
.
end
=
&
qEnd
;
taos_query_a
(
taos
,
sql
,
sqKillQueryCb
,
&
param
);
while
(
0
==
qEnd
)
{
usleep
(
5000
);
}
taos_close
(
taos
);
}
CASE_LEAVE
();
}
void
sqRunAllCase
(
void
)
{
void
sqRunAllCase
(
void
)
{
/*
/*
sqSyncStopQuery(false);
sqSyncStopQuery(false);
...
@@ -409,8 +494,14 @@ void sqRunAllCase(void) {
...
@@ -409,8 +494,14 @@ void sqRunAllCase(void) {
sqAsyncCloseQuery(true);
sqAsyncCloseQuery(true);
*/
*/
sqConSyncCloseQuery
(
false
);
sqConSyncCloseQuery
(
false
);
/*
sqConSyncCloseQuery(true);
sqConSyncCloseQuery(true);
sqSyncKillQuery(false);
sqSyncKillQuery(true);
sqAsyncKillQuery(false);
sqAsyncKillQuery(true);
*/
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录