Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
053785bb
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
053785bb
编写于
4月 12, 2021
作者:
H
haojun Liao
提交者:
GitHub
4月 12, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5772 from taosdata/fix/query
Fix/query
上级
71539043
67fd99e7
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
74 addition
and
25 deletion
+74
-25
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+2
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+69
-21
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+3
-3
未找到文件。
src/client/src/tscSchemaUtil.c
浏览文件 @
053785bb
...
@@ -144,8 +144,9 @@ SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) {
...
@@ -144,8 +144,9 @@ SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) {
SNewVgroupInfo
info
=
{
0
};
SNewVgroupInfo
info
=
{
0
};
info
.
numOfEps
=
pVgroupMsg
->
numOfEps
;
info
.
numOfEps
=
pVgroupMsg
->
numOfEps
;
info
.
vgId
=
pVgroupMsg
->
vgId
;
info
.
vgId
=
pVgroupMsg
->
vgId
;
info
.
inUse
=
0
;
info
.
inUse
=
0
;
// 0 is the default value of inUse in case of multiple replica
assert
(
info
.
numOfEps
>=
1
&&
info
.
vgId
>=
1
);
for
(
int32_t
i
=
0
;
i
<
pVgroupMsg
->
numOfEps
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroupMsg
->
numOfEps
;
++
i
)
{
tstrncpy
(
info
.
ep
[
i
].
fqdn
,
pVgroupMsg
->
epAddr
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
tstrncpy
(
info
.
ep
[
i
].
fqdn
,
pVgroupMsg
->
epAddr
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
info
.
ep
[
i
].
port
=
pVgroupMsg
->
epAddr
[
i
].
port
;
info
.
ep
[
i
].
port
=
pVgroupMsg
->
epAddr
[
i
].
port
;
...
...
src/client/src/tscServer.c
浏览文件 @
053785bb
...
@@ -34,6 +34,7 @@ int tscKeepConn[TSDB_SQL_MAX] = {0};
...
@@ -34,6 +34,7 @@ int tscKeepConn[TSDB_SQL_MAX] = {0};
TSKEY
tscGetSubscriptionProgress
(
void
*
sub
,
int64_t
uid
,
TSKEY
dflt
);
TSKEY
tscGetSubscriptionProgress
(
void
*
sub
,
int64_t
uid
,
TSKEY
dflt
);
void
tscUpdateSubscriptionProgress
(
void
*
sub
,
int64_t
uid
,
TSKEY
ts
);
void
tscUpdateSubscriptionProgress
(
void
*
sub
,
int64_t
uid
,
TSKEY
ts
);
void
tscSaveSubscriptionProgress
(
void
*
sub
);
void
tscSaveSubscriptionProgress
(
void
*
sub
);
static
int32_t
extractSTableQueryVgroupId
(
STableMetaInfo
*
pTableMetaInfo
);
static
int32_t
minMsgSize
()
{
return
tsRpcHeadSize
+
100
;
}
static
int32_t
minMsgSize
()
{
return
tsRpcHeadSize
+
100
;
}
static
int32_t
getWaitingTimeInterval
(
int32_t
count
)
{
static
int32_t
getWaitingTimeInterval
(
int32_t
count
)
{
...
@@ -79,6 +80,7 @@ static void tscEpSetHtons(SRpcEpSet *s) {
...
@@ -79,6 +80,7 @@ static void tscEpSetHtons(SRpcEpSet *s) {
s
->
port
[
i
]
=
htons
(
s
->
port
[
i
]);
s
->
port
[
i
]
=
htons
(
s
->
port
[
i
]);
}
}
}
}
bool
tscEpSetIsEqual
(
SRpcEpSet
*
s1
,
SRpcEpSet
*
s2
)
{
bool
tscEpSetIsEqual
(
SRpcEpSet
*
s1
,
SRpcEpSet
*
s2
)
{
if
(
s1
->
numOfEps
!=
s2
->
numOfEps
||
s1
->
inUse
!=
s2
->
inUse
)
{
if
(
s1
->
numOfEps
!=
s2
->
numOfEps
||
s1
->
inUse
!=
s2
->
inUse
)
{
return
false
;
return
false
;
...
@@ -111,19 +113,22 @@ static void tscDumpEpSetFromVgroupInfo(SRpcEpSet *pEpSet, SNewVgroupInfo *pVgrou
...
@@ -111,19 +113,22 @@ static void tscDumpEpSetFromVgroupInfo(SRpcEpSet *pEpSet, SNewVgroupInfo *pVgrou
}
}
}
}
static
void
tscUpdateVgroupInfo
(
SSqlObj
*
p
Obj
,
SRpcEpSet
*
pEpSet
)
{
static
void
tscUpdateVgroupInfo
(
SSqlObj
*
p
Sql
,
SRpcEpSet
*
pEpSet
)
{
SSqlCmd
*
pCmd
=
&
p
Obj
->
cmd
;
SSqlCmd
*
pCmd
=
&
p
Sql
->
cmd
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
if
(
pTableMetaInfo
==
NULL
||
pTableMetaInfo
->
pTableMeta
==
NULL
)
{
if
(
pTableMetaInfo
==
NULL
||
pTableMetaInfo
->
pTableMeta
==
NULL
)
{
return
;
return
;
}
}
int32_t
vgId
=
pTableMetaInfo
->
pTableMeta
->
vgId
;
int32_t
vgId
=
-
1
;
if
(
pTableMetaInfo
->
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
if
(
pTableMetaInfo
->
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
assert
(
vgId
==
0
);
vgId
=
extractSTableQueryVgroupId
(
pTableMetaInfo
);
return
;
}
else
{
vgId
=
pTableMetaInfo
->
pTableMeta
->
vgId
;
}
}
assert
(
vgId
>
0
);
SNewVgroupInfo
vgroupInfo
=
{.
vgId
=
-
1
};
SNewVgroupInfo
vgroupInfo
=
{.
vgId
=
-
1
};
taosHashGetClone
(
tscVgroupMap
,
&
vgId
,
sizeof
(
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashGetClone
(
tscVgroupMap
,
&
vgId
,
sizeof
(
vgId
),
NULL
,
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
assert
(
vgroupInfo
.
numOfEps
>
0
&&
vgroupInfo
.
vgId
>
0
);
assert
(
vgroupInfo
.
numOfEps
>
0
&&
vgroupInfo
.
vgId
>
0
);
...
@@ -138,6 +143,33 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
...
@@ -138,6 +143,33 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
tscDebug
(
"after: EndPoint in use:%d, numOfEps:%d"
,
vgroupInfo
.
inUse
,
vgroupInfo
.
numOfEps
);
tscDebug
(
"after: EndPoint in use:%d, numOfEps:%d"
,
vgroupInfo
.
inUse
,
vgroupInfo
.
numOfEps
);
taosHashPut
(
tscVgroupMap
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
taosHashPut
(
tscVgroupMap
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
SNewVgroupInfo
));
// Update the local cached epSet info cached by SqlObj
int32_t
inUse
=
pSql
->
epSet
.
inUse
;
tscDumpEpSetFromVgroupInfo
(
&
pSql
->
epSet
,
&
vgroupInfo
);
tscDebug
(
"%p update the epSet in SqlObj, in use before:%d, after:%d"
,
pSql
,
inUse
,
pSql
->
epSet
.
inUse
);
}
int32_t
extractSTableQueryVgroupId
(
STableMetaInfo
*
pTableMetaInfo
)
{
assert
(
pTableMetaInfo
!=
NULL
);
int32_t
vgIndex
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
vgId
=
-
1
;
if
(
pTableMetaInfo
->
pVgroupTables
==
NULL
)
{
SVgroupsInfo
*
pVgroupInfo
=
pTableMetaInfo
->
vgroupList
;
assert
(
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
>
0
&&
vgIndex
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
vgId
=
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
;
}
else
{
int32_t
numOfVgroups
=
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
assert
(
vgIndex
>=
0
&&
vgIndex
<
numOfVgroups
);
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
vgIndex
);
vgId
=
pTableIdList
->
vgInfo
.
vgId
;
}
return
vgId
;
}
}
void
tscProcessHeartBeatRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
void
tscProcessHeartBeatRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
...
@@ -515,21 +547,22 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -515,21 +547,22 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
int32_t
vgIndex
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
vgIndex
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
vgId
=
-
1
;
if
(
pTableMetaInfo
->
pVgroupTables
==
NULL
)
{
if
(
pTableMetaInfo
->
pVgroupTables
==
NULL
)
{
SVgroupsInfo
*
pVgroupInfo
=
pTableMetaInfo
->
vgroupList
;
SVgroupsInfo
*
pVgroupInfo
=
pTableMetaInfo
->
vgroupList
;
assert
(
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
>
0
&&
vgIndex
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
assert
(
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
>
0
&&
vgIndex
<
pTableMetaInfo
->
vgroupList
->
numOfVgroups
);
vgId
=
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
;
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
);
tscDebug
(
"%p build fetch msg from vgId:%d, vgIndex:%d, qId:%"
PRIu64
,
pSql
,
pVgroupInfo
->
vgroups
[
vgIndex
].
vgId
,
vgIndex
,
pSql
->
res
.
qId
);
}
else
{
}
else
{
int32_t
numOfVgroups
=
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
int32_t
numOfVgroups
=
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
assert
(
vgIndex
>=
0
&&
vgIndex
<
numOfVgroups
);
assert
(
vgIndex
>=
0
&&
vgIndex
<
numOfVgroups
);
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
vgIndex
);
SVgroupTableInfo
*
pTableIdList
=
taosArrayGet
(
pTableMetaInfo
->
pVgroupTables
,
vgIndex
);
vgId
=
pTableIdList
->
vgInfo
.
vgId
;
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableIdList
->
vgInfo
.
vgId
);
tscDebug
(
"%p build fetch msg from vgId:%d, vgIndex:%d, qId:%"
PRIu64
,
pSql
,
pTableIdList
->
vgInfo
.
vgId
,
vgIndex
,
pSql
->
res
.
qId
);
}
}
pRetrieveMsg
->
header
.
vgId
=
htonl
(
vgId
);
tscDebug
(
"%p build fetch msg from vgId:%d, vgIndex:%d, qId:%"
PRIu64
,
pSql
,
vgId
,
vgIndex
,
pSql
->
res
.
qId
);
}
else
{
}
else
{
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
pRetrieveMsg
->
header
.
vgId
=
htonl
(
pTableMeta
->
vgId
);
...
@@ -1980,7 +2013,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
...
@@ -1980,7 +2013,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
(
vgroupInfo
.
inUse
<
0
))
{
// vgroup info exists, compare with it
(
vgroupInfo
.
inUse
<
0
))
{
// vgroup info exists, compare with it
vgroupInfo
=
createNewVgroupInfo
(
&
pMetaMsg
->
vgroup
);
vgroupInfo
=
createNewVgroupInfo
(
&
pMetaMsg
->
vgroup
);
taosHashPut
(
tscVgroupMap
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
vgroupInfo
));
taosHashPut
(
tscVgroupMap
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
,
sizeof
(
vgroupInfo
));
tscDebug
(
"add new VgroupInfo, vgId:%d, total:%d"
,
vgId
,
(
int32_t
)
taosHashGetSize
(
tscVgroupMap
));
tscDebug
(
"add new VgroupInfo, vgId:%d, total
cached
:%d"
,
vgId
,
(
int32_t
)
taosHashGetSize
(
tscVgroupMap
));
}
}
}
}
...
@@ -2132,18 +2165,33 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
...
@@ -2132,18 +2165,33 @@ int tscProcessSTableVgroupRsp(SSqlObj *pSql) {
tscError
(
"%p empty vgroup info"
,
pSql
);
tscError
(
"%p empty vgroup info"
,
pSql
);
}
else
{
}
else
{
for
(
int32_t
j
=
0
;
j
<
pInfo
->
vgroupList
->
numOfVgroups
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pInfo
->
vgroupList
->
numOfVgroups
;
++
j
)
{
//just init, no need to lock
//
just init, no need to lock
SVgroupInfo
*
pVgroup
s
=
&
pInfo
->
vgroupList
->
vgroups
[
j
];
SVgroupInfo
*
pVgroup
=
&
pInfo
->
vgroupList
->
vgroups
[
j
];
SVgroupMsg
*
vmsg
=
&
pVgroupMsg
->
vgroups
[
j
];
SVgroupMsg
*
vmsg
=
&
pVgroupMsg
->
vgroups
[
j
];
pVgroups
->
vgId
=
htonl
(
vmsg
->
vgId
);
vmsg
->
vgId
=
htonl
(
vmsg
->
vgId
);
pVgroups
->
numOfEps
=
vmsg
->
numOfEps
;
vmsg
->
numOfEps
=
vmsg
->
numOfEps
;
for
(
int32_t
k
=
0
;
k
<
vmsg
->
numOfEps
;
++
k
)
{
vmsg
->
epAddr
[
k
].
port
=
htons
(
vmsg
->
epAddr
[
k
].
port
);
}
SNewVgroupInfo
newVi
=
createNewVgroupInfo
(
vmsg
);
pVgroup
->
numOfEps
=
newVi
.
numOfEps
;
pVgroup
->
vgId
=
newVi
.
vgId
;
for
(
int32_t
k
=
0
;
k
<
vmsg
->
numOfEps
;
++
k
)
{
pVgroup
->
epAddr
[
k
].
port
=
newVi
.
ep
[
k
].
port
;
pVgroup
->
epAddr
[
k
].
fqdn
=
strndup
(
newVi
.
ep
[
k
].
fqdn
,
TSDB_FQDN_LEN
);
}
assert
(
pVgroups
->
numOfEps
>=
1
&&
pVgroups
->
vgId
>=
1
);
// check if current buffer contains the vgroup info.
// If not, add it
SNewVgroupInfo
existVgroupInfo
=
{.
inUse
=
-
1
};
taosHashGetClone
(
tscVgroupMap
,
&
newVi
.
vgId
,
sizeof
(
newVi
.
vgId
),
NULL
,
&
existVgroupInfo
,
sizeof
(
SNewVgroupInfo
));
for
(
int32_t
k
=
0
;
k
<
pVgroups
->
numOfEps
;
++
k
)
{
if
(((
existVgroupInfo
.
inUse
>=
0
)
&&
!
vgroupInfoIdentical
(
&
existVgroupInfo
,
vmsg
))
||
pVgroups
->
epAddr
[
k
].
port
=
htons
(
vmsg
->
epAddr
[
k
].
port
);
(
existVgroupInfo
.
inUse
<
0
))
{
// vgroup info exists, compare with it
pVgroups
->
epAddr
[
k
].
fqdn
=
strndup
(
vmsg
->
epAddr
[
k
].
fqdn
,
tListLen
(
vmsg
->
epAddr
[
k
].
fqdn
));
taosHashPut
(
tscVgroupMap
,
&
newVi
.
vgId
,
sizeof
(
newVi
.
vgId
),
&
newVi
,
sizeof
(
newVi
));
tscDebug
(
"add new VgroupInfo, vgId:%d, total cached:%d"
,
newVi
.
vgId
,
(
int32_t
)
taosHashGetSize
(
tscVgroupMap
));
}
}
}
}
}
}
...
...
src/rpc/src/rpcMain.c
浏览文件 @
053785bb
...
@@ -295,7 +295,7 @@ void *rpcOpen(const SRpcInit *pInit) {
...
@@ -295,7 +295,7 @@ void *rpcOpen(const SRpcInit *pInit) {
return
NULL
;
return
NULL
;
}
}
}
else
{
}
else
{
pRpc
->
pCache
=
rpcOpenConnCache
(
pRpc
->
sessions
,
rpcCloseConn
,
pRpc
->
tmrCtrl
,
pRpc
->
idleTime
);
pRpc
->
pCache
=
rpcOpenConnCache
(
pRpc
->
sessions
,
rpcCloseConn
,
pRpc
->
tmrCtrl
,
pRpc
->
idleTime
*
30
);
if
(
pRpc
->
pCache
==
NULL
)
{
if
(
pRpc
->
pCache
==
NULL
)
{
tError
(
"%s failed to init connection cache"
,
pRpc
->
label
);
tError
(
"%s failed to init connection cache"
,
pRpc
->
label
);
rpcClose
(
pRpc
);
rpcClose
(
pRpc
);
...
@@ -470,7 +470,7 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
...
@@ -470,7 +470,7 @@ void rpcSendResponse(const SRpcMsg *pRsp) {
taosTmrStopA
(
&
pConn
->
pTimer
);
taosTmrStopA
(
&
pConn
->
pTimer
);
// set the idle timer to monitor the activity
// set the idle timer to monitor the activity
taosTmrReset
(
rpcProcessIdleTimer
,
pRpc
->
idleTime
,
pConn
,
pRpc
->
tmrCtrl
,
&
pConn
->
pIdleTimer
);
taosTmrReset
(
rpcProcessIdleTimer
,
pRpc
->
idleTime
*
30
,
pConn
,
pRpc
->
tmrCtrl
,
&
pConn
->
pIdleTimer
);
rpcSendMsgToPeer
(
pConn
,
msg
,
msgLen
);
rpcSendMsgToPeer
(
pConn
,
msg
,
msgLen
);
// if not set to secured, set it expcet NOT_READY case, since client wont treat it as secured
// if not set to secured, set it expcet NOT_READY case, since client wont treat it as secured
...
@@ -1367,7 +1367,7 @@ static void rpcProcessConnError(void *param, void *id) {
...
@@ -1367,7 +1367,7 @@ static void rpcProcessConnError(void *param, void *id) {
tDebug
(
"%s %p, connection error happens"
,
pRpc
->
label
,
pContext
->
ahandle
);
tDebug
(
"%s %p, connection error happens"
,
pRpc
->
label
,
pContext
->
ahandle
);
if
(
pContext
->
numOfTry
>=
pContext
->
epSet
.
numOfEps
)
{
if
(
pContext
->
numOfTry
>=
pContext
->
epSet
.
numOfEps
||
pContext
->
msgType
==
TSDB_MSG_TYPE_FETCH
)
{
rpcMsg
.
msgType
=
pContext
->
msgType
+
1
;
rpcMsg
.
msgType
=
pContext
->
msgType
+
1
;
rpcMsg
.
ahandle
=
pContext
->
ahandle
;
rpcMsg
.
ahandle
=
pContext
->
ahandle
;
rpcMsg
.
code
=
pContext
->
code
;
rpcMsg
.
code
=
pContext
->
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录