Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7502039d
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看板
提交
7502039d
编写于
3月 12, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
6722b336
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
22 deletion
+33
-22
src/inc/query.h
src/inc/query.h
+3
-2
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+12
-3
src/query/src/queryMain.c
src/query/src/queryMain.c
+4
-5
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+12
-11
未找到文件。
src/inc/query.h
浏览文件 @
7502039d
...
...
@@ -28,7 +28,7 @@ typedef void* qinfo_t;
* @param qinfo
* @return
*/
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryTableMsg
,
qinfo_t
*
qinfo
);
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryTableMsg
,
qinfo_t
*
qinfo
,
uint64_t
*
qId
);
/**
...
...
@@ -88,9 +88,10 @@ void* qOpenQueryMgmt(int32_t vgId);
void
qQueryMgmtNotifyClosed
(
void
*
pExecutor
);
void
qQueryMgmtReOpen
(
void
*
pExecutor
);
void
qCleanupQueryMgmt
(
void
*
pExecutor
);
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qInfo
);
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qI
d
,
uint64_t
qI
nfo
);
void
**
qAcquireQInfo
(
void
*
pMgmt
,
uint64_t
key
);
void
**
qReleaseQInfo
(
void
*
pMgmt
,
void
*
pQInfo
,
bool
freeHandle
);
bool
checkQIdEqual
(
void
*
qHandle
,
uint64_t
qId
);
#ifdef __cplusplus
}
...
...
src/query/inc/qExecutor.h
浏览文件 @
7502039d
...
...
@@ -262,6 +262,7 @@ enum {
typedef
struct
SQInfo
{
void
*
signature
;
uint64_t
qId
;
int32_t
code
;
// error code to returned to client
int64_t
owner
;
// if it is in execution
void
*
tsdb
;
...
...
@@ -311,7 +312,7 @@ int32_t createQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t numOfOutpu
SColumnInfo
*
pTagCols
);
SSqlGroupbyExpr
*
createGroupbyExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
SColIndex
*
pColIndex
,
int32_t
*
code
);
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SSqlGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
bool
stableQuery
,
char
*
sql
);
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
bool
stableQuery
,
char
*
sql
,
uint64_t
*
qId
);
int32_t
initQInfo
(
SQueryTableMsg
*
pQueryMsg
,
void
*
tsdb
,
int32_t
vgId
,
SQInfo
*
pQInfo
,
SQueryParam
*
param
,
bool
isSTable
);
void
freeColumnFilterInfo
(
SColumnFilterInfo
*
pFilter
,
int32_t
numOfFilters
);
...
...
src/query/src/qExecutor.c
浏览文件 @
7502039d
...
...
@@ -112,6 +112,9 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
static
void
finalizeQueryResult
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
uint64_t
queryHandleId
=
0
;
int32_t
getMaximumIdleDurationSec
()
{
return
tsShellActivityTimer
*
2
;
}
...
...
@@ -6570,8 +6573,12 @@ static void calResultBufSize(SQuery* pQuery) {
}
}
FORCE_INLINE
bool
checkQIdEqual
(
void
*
qHandle
,
uint64_t
qId
)
{
return
((
SQInfo
*
)
qHandle
)
->
qId
==
qId
;
}
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SSqlGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
bool
stableQuery
,
char
*
sql
)
{
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
bool
stableQuery
,
char
*
sql
,
uint64_t
*
qId
)
{
int16_t
numOfCols
=
pQueryMsg
->
numOfCols
;
int16_t
numOfOutput
=
pQueryMsg
->
numOfOutput
;
...
...
@@ -6749,8 +6756,10 @@ SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGroupbyExpr
// todo refactor
pQInfo
->
runtimeEnv
.
queryBlockDist
=
(
numOfOutput
==
1
&&
pExprs
[
0
].
base
.
colInfo
.
colId
==
TSDB_BLOCK_DIST_COLUMN_INDEX
);
qDebug
(
"qmsg:%p QInfo:%p created"
,
pQueryMsg
,
pQInfo
);
pQInfo
->
qId
=
atomic_add_fetch_64
(
&
queryHandleId
,
1
);
*
qId
=
pQInfo
->
qId
;
qDebug
(
"qmsg:%p QInfo:%"
PRIu64
"-%p created"
,
pQueryMsg
,
pQInfo
->
qId
,
pQInfo
);
return
pQInfo
;
_cleanup_qinfo:
...
...
src/query/src/queryMain.c
浏览文件 @
7502039d
...
...
@@ -68,7 +68,7 @@ void freeParam(SQueryParam *param) {
tfree
(
param
->
prevResult
);
}
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryMsg
,
qinfo_t
*
pQInfo
)
{
int32_t
qCreateQueryInfo
(
void
*
tsdb
,
int32_t
vgId
,
SQueryTableMsg
*
pQueryMsg
,
qinfo_t
*
pQInfo
,
uint64_t
*
qId
)
{
assert
(
pQueryMsg
!=
NULL
&&
tsdb
!=
NULL
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -158,7 +158,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
goto
_over
;
}
(
*
pQInfo
)
=
createQInfoImpl
(
pQueryMsg
,
param
.
pGroupbyExpr
,
param
.
pExprs
,
param
.
pSecExprs
,
&
tableGroupInfo
,
param
.
pTagColumnInfo
,
isSTableQuery
,
param
.
sql
);
(
*
pQInfo
)
=
createQInfoImpl
(
pQueryMsg
,
param
.
pGroupbyExpr
,
param
.
pExprs
,
param
.
pSecExprs
,
&
tableGroupInfo
,
param
.
pTagColumnInfo
,
isSTableQuery
,
param
.
sql
,
qId
);
param
.
sql
=
NULL
;
param
.
pExprs
=
NULL
;
...
...
@@ -479,7 +479,7 @@ void qCleanupQueryMgmt(void* pQMgmt) {
qDebug
(
"vgId:%d, queryMgmt cleanup completed"
,
vgId
);
}
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qInfo
)
{
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qI
d
,
uint64_t
qI
nfo
)
{
if
(
pMgmt
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
return
NULL
;
...
...
@@ -499,8 +499,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) {
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
return
NULL
;
}
else
{
TSDB_CACHE_PTR_TYPE
handleVal
=
(
TSDB_CACHE_PTR_TYPE
)
qInfo
;
void
**
handle
=
taosCachePut
(
pQueryMgmt
->
qinfoPool
,
&
handleVal
,
sizeof
(
TSDB_CACHE_PTR_TYPE
),
&
qInfo
,
sizeof
(
TSDB_CACHE_PTR_TYPE
),
void
**
handle
=
taosCachePut
(
pQueryMgmt
->
qinfoPool
,
&
qId
,
sizeof
(
qId
),
&
qInfo
,
sizeof
(
TSDB_CACHE_PTR_TYPE
),
(
getMaximumIdleDurationSec
()
*
1000
));
pthread_mutex_unlock
(
&
pQueryMgmt
->
lock
);
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
7502039d
...
...
@@ -247,7 +247,8 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
if
(
contLen
!=
0
)
{
qinfo_t
pQInfo
=
NULL
;
code
=
qCreateQueryInfo
(
pVnode
->
tsdb
,
pVnode
->
vgId
,
pQueryTableMsg
,
&
pQInfo
);
uint64_t
qId
=
0
;
code
=
qCreateQueryInfo
(
pVnode
->
tsdb
,
pVnode
->
vgId
,
pQueryTableMsg
,
&
pQInfo
,
&
qId
);
SQueryTableRsp
*
pRsp
=
(
SQueryTableRsp
*
)
rpcMallocCont
(
sizeof
(
SQueryTableRsp
));
pRsp
->
code
=
code
;
...
...
@@ -259,22 +260,22 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// current connect is broken
if
(
code
==
TSDB_CODE_SUCCESS
)
{
handle
=
qRegisterQInfo
(
pVnode
->
qMgmt
,
(
uint64_t
)
pQInfo
);
handle
=
qRegisterQInfo
(
pVnode
->
qMgmt
,
qId
,
(
uint64_t
)
pQInfo
);
if
(
handle
==
NULL
)
{
// failed to register qhandle
pRsp
->
code
=
terrno
;
terrno
=
0
;
vError
(
"vgId:%d, QInfo:%
p register qhandle failed, return to app, code:%s"
,
pVnode
->
vg
Id
,
(
void
*
)
pQInfo
,
vError
(
"vgId:%d, QInfo:%
"
PRIu64
"-%p register qhandle failed, return to app, code:%s"
,
pVnode
->
vgId
,
q
Id
,
(
void
*
)
pQInfo
,
tstrerror
(
pRsp
->
code
));
qDestroyQueryInfo
(
pQInfo
);
// destroy it directly
return
pRsp
->
code
;
}
else
{
assert
(
*
handle
==
pQInfo
);
pRsp
->
qhandle
=
htobe64
(
(
uint64_t
)
pQInfo
);
pRsp
->
qhandle
=
htobe64
(
qId
);
}
if
(
handle
!=
NULL
&&
vnodeNotifyCurrentQhandle
(
pRead
->
rpcHandle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%
p, query discarded since link is broken, %p"
,
pVnode
->
vg
Id
,
*
handle
,
vError
(
"vgId:%d, QInfo:%
"
PRIu64
"-%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
q
Id
,
*
handle
,
pRead
->
rpcHandle
);
pRsp
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
...
@@ -285,7 +286,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
}
if
(
handle
!=
NULL
)
{
vTrace
(
"vgId:%d, QInfo:%
p, dnode query msg disposed, create qhandle and returns to app"
,
vg
Id
,
*
handle
);
vTrace
(
"vgId:%d, QInfo:%
"
PRIu64
"-%p, dnode query msg disposed, create qhandle and returns to app"
,
vgId
,
q
Id
,
*
handle
);
code
=
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
pRead
->
rpcHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRsp
->
code
=
code
;
...
...
@@ -349,7 +350,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
pRetrieve
->
free
=
htons
(
pRetrieve
->
free
);
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
vTrace
(
"vgId:%d, QInfo:%
p, retrieve msg is disposed, free:%d, conn:%p"
,
pVnode
->
vgId
,
(
void
*
)
pRetrieve
->
qhandle
,
vTrace
(
"vgId:%d, QInfo:%
"
PRIu64
", retrieve msg is disposed, free:%d, conn:%p"
,
pVnode
->
vgId
,
pRetrieve
->
qhandle
,
pRetrieve
->
free
,
pRead
->
rpcHandle
);
memset
(
pRet
,
0
,
sizeof
(
SRspRet
));
...
...
@@ -360,19 +361,19 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
if
(
handle
==
NULL
)
{
code
=
terrno
;
terrno
=
TSDB_CODE_SUCCESS
;
}
else
if
(
(
*
handle
)
!=
(
void
*
)
pRetrieve
->
qhandle
)
{
}
else
if
(
!
checkQIdEqual
(
*
handle
,
pRetrieve
->
qhandle
)
)
{
code
=
TSDB_CODE_QRY_INVALID_QHANDLE
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, invalid handle in retrieving result, code:%s, QInfo:%
p"
,
pVnode
->
vgId
,
tstrerror
(
code
),
(
void
*
)
pRetrieve
->
qhandle
);
vError
(
"vgId:%d, invalid handle in retrieving result, code:%s, QInfo:%
"
PRIu64
,
pVnode
->
vgId
,
tstrerror
(
code
),
pRetrieve
->
qhandle
);
vnodeBuildNoResultQueryRsp
(
pRet
);
return
code
;
}
// kill current query and free corresponding resources.
if
(
pRetrieve
->
free
==
1
)
{
vWarn
(
"vgId:%d, QInfo:%
p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
*
handle
);
vWarn
(
"vgId:%d, QInfo:%
"
PRIu64
"-%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
pRetrieve
->
qhandle
,
*
handle
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
...
@@ -383,7 +384,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// register the qhandle to connect to quit query immediate if connection is broken
if
(
vnodeNotifyCurrentQhandle
(
pRead
->
rpcHandle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%
p, retrieve discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pRead
->
rpcHandle
);
vError
(
"vgId:%d, QInfo:%
"
PRIu64
"-%p, retrieve discarded since link is broken, %p"
,
pVnode
->
vgId
,
pRetrieve
->
qhandle
,
*
handle
,
pRead
->
rpcHandle
);
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录