Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ef58297a
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看板
提交
ef58297a
编写于
7月 07, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor qhandle mgmt
上级
aaaf7c21
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
57 addition
and
48 deletion
+57
-48
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+57
-48
未找到文件。
src/vnode/src/vnodeRead.c
浏览文件 @
ef58297a
...
...
@@ -94,10 +94,10 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
qinfo_t
pQInfo
=
NULL
;
void
**
handle
=
NULL
;
if
(
contLen
!=
0
)
{
qinfo_t
pQInfo
=
NULL
;
code
=
qCreateQueryInfo
(
pVnode
->
tsdb
,
pVnode
->
vgId
,
pQueryTableMsg
,
pVnode
,
NULL
,
&
pQInfo
);
SQueryTableRsp
*
pRsp
=
(
SQueryTableRsp
*
)
rpcMallocCont
(
sizeof
(
SQueryTableRsp
));
...
...
@@ -116,19 +116,19 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
qKillQuery
(
pQInfo
);
qKillQuery
(
pQInfo
);
pQInfo
=
NULL
;
}
else
{
assert
(
*
handle
==
pQInfo
);
pRsp
->
qhandle
=
htobe64
((
uint64_t
)
(
handle
));
}
pQInfo
=
NULL
;
if
(
handle
!=
NULL
&&
vnodeNotifyCurrentQhandle
(
pReadMsg
->
rpcMsg
.
handle
,
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
pQInfo
,
pReadMsg
->
rpcMsg
.
handle
);
vError
(
"vgId:%d, QInfo:%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pReadMsg
->
rpcMsg
.
handle
);
pRsp
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
// NOTE: there two refcount, needs to kill twice
// query has not been put into qhandle pool, kill it directly.
qKillQuery
(
pQInfo
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
return
pRsp
->
code
;
}
...
...
@@ -139,16 +139,18 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg disposed"
,
vgId
,
pQInfo
);
}
else
{
assert
(
pCont
!=
NULL
);
pQInfo
=
*
(
void
**
)(
pCont
);
handle
=
pCont
;
handle
=
qAcquireQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
pCont
);
if
(
handle
==
NULL
)
{
vWarn
(
"QInfo:%p invalid qhandle in continuing exec query, conn:%p"
,
*
(
void
**
)
pCont
,
pReadMsg
->
rpcMsg
.
handle
);
code
=
TSDB_CODE_QRY_INVALID_QHANDLE
;
}
else
{
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg in progress"
,
pVnode
->
vgId
,
*
(
void
**
)
pCont
);
code
=
TSDB_CODE_VND_ACTION_IN_PROGRESS
;
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg in progress"
,
pVnode
->
vgId
,
pQInfo
);
}
}
if
(
pQInfo
!=
NULL
)
{
qTableQuery
(
pQInfo
);
// do execute query
assert
(
handle
!=
NULL
);
if
(
handle
!=
NULL
)
{
qTableQuery
(
*
handle
);
// do execute query
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
}
...
...
@@ -160,22 +162,33 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
SRspRet
*
pRet
=
&
pReadMsg
->
rspRet
;
SRetrieveTableMsg
*
pRetrieve
=
pCont
;
void
**
pQInfo
=
(
void
*
)
htobe64
(
pRetrieve
->
qhandle
);
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
pRetrieve
->
free
=
htons
(
pRetrieve
->
free
);
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg is disposed"
,
pVnode
->
vgId
,
*
pQInfo
);
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg is disposed"
,
pVnode
->
vgId
,
*
(
void
**
)
pRetrieve
->
qhandle
);
memset
(
pRet
,
0
,
sizeof
(
SRspRet
));
int32_t
ret
=
0
;
void
**
handle
=
qAcquireQInfo
(
pVnode
->
qMgmt
,
pQInfo
);
if
(
handle
==
NULL
||
handle
!=
pQInfo
)
{
ret
=
TSDB_CODE_QRY_INVALID_QHANDLE
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
void
**
handle
=
qAcquireQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
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
);
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
pRet
->
len
=
sizeof
(
SRetrieveTableRsp
);
memset
(
pRet
->
rsp
,
0
,
sizeof
(
SRetrieveTableRsp
));
SRetrieveTableRsp
*
pRsp
=
pRet
->
rsp
;
pRsp
->
numOfRows
=
0
;
pRsp
->
completed
=
true
;
pRsp
->
useconds
=
0
;
return
code
;
}
if
(
pRetrieve
->
free
==
1
)
{
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
pQInfo
);
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
...
...
@@ -186,31 +199,27 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
pRsp
->
numOfRows
=
0
;
pRsp
->
completed
=
true
;
pRsp
->
useconds
=
0
;
}
else
{
// todo handle error
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
}
return
ret
;
return
code
;
}
int32_t
code
=
qRetrieveQueryResultInfo
(
*
pQInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
ret
!=
TSDB_CODE_SUCCESS
)
{
//TODO
bool
freeHandle
=
true
;
code
=
qRetrieveQueryResultInfo
(
*
handle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
//TODO handle malloc failure
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
memset
(
pRet
->
rsp
,
0
,
sizeof
(
SRetrieveTableRsp
));
}
else
{
// todo check code and handle error in build result set
code
=
qDumpRetrieveResult
(
*
pQInfo
,
(
SRetrieveTableRsp
**
)
&
pRet
->
rsp
,
&
pRet
->
len
);
}
else
{
// if failed to dump result, free qhandle immediately
if
((
code
=
qDumpRetrieveResult
(
*
handle
,
(
SRetrieveTableRsp
**
)
&
pRet
->
rsp
,
&
pRet
->
len
))
==
TSDB_CODE_SUCCESS
)
{
if
(
qHasMoreResultsToRetrieve
(
*
handle
))
{
dnodePutItemIntoReadQueue
(
pVnode
,
handle
);
pRet
->
qhandle
=
handle
;
code
=
TSDB_CODE_SUCCESS
;
}
else
{
// no further execution invoked, release the ref to vnode
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
freeHandle
=
false
;
}
}
}
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
freeHandle
);
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录