Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ad7509b1
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看板
未验证
提交
ad7509b1
编写于
5月 16, 2023
作者:
D
dapan1121
提交者:
GitHub
5月 16, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21315 from taosdata/enh/TD-23421-M
fix: client hb logic fix and optimization
上级
4415fcd0
b125d214
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
34 deletion
+53
-34
source/client/src/clientHb.c
source/client/src/clientHb.c
+53
-34
未找到文件。
source/client/src/clientHb.c
浏览文件 @
ad7509b1
...
@@ -24,6 +24,8 @@ typedef struct {
...
@@ -24,6 +24,8 @@ typedef struct {
struct
{
struct
{
int64_t
clusterId
;
int64_t
clusterId
;
int32_t
passKeyCnt
;
int32_t
passKeyCnt
;
int32_t
passVer
;
int32_t
reqCnt
;
};
};
};
};
}
SHbParam
;
}
SHbParam
;
...
@@ -536,14 +538,20 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
...
@@ -536,14 +538,20 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
hbGetUserBasicInfo
(
SClientHbKey
*
connKey
,
SClientHbReq
*
req
)
{
static
int32_t
hbGetUserBasicInfo
(
SClientHbKey
*
connKey
,
S
HbParam
*
param
,
S
ClientHbReq
*
req
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
acquireTscObj
(
connKey
->
tscRid
);
STscObj
*
pTscObj
=
(
STscObj
*
)
acquireTscObj
(
connKey
->
tscRid
);
if
(
!
pTscObj
)
{
if
(
!
pTscObj
)
{
tscWarn
(
"tscObj rid %"
PRIx64
" not exist"
,
connKey
->
tscRid
);
tscWarn
(
"tscObj rid %"
PRIx64
" not exist"
,
connKey
->
tscRid
);
return
TSDB_CODE_APP_ERROR
;
return
TSDB_CODE_APP_ERROR
;
}
}
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
param
&&
(
param
->
passVer
!=
INT32_MIN
)
&&
(
param
->
passVer
<=
pTscObj
->
passInfo
.
ver
))
{
tscDebug
(
"hb got user basic info, no need since passVer %d <= %d"
,
param
->
passVer
,
pTscObj
->
passInfo
.
ver
);
goto
_return
;
}
SUserPassVersion
*
user
=
taosMemoryMalloc
(
sizeof
(
SUserPassVersion
));
SUserPassVersion
*
user
=
taosMemoryMalloc
(
sizeof
(
SUserPassVersion
));
if
(
!
user
)
{
if
(
!
user
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -570,6 +578,11 @@ static int32_t hbGetUserBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
...
@@ -570,6 +578,11 @@ static int32_t hbGetUserBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
goto
_return
;
goto
_return
;
}
}
// assign the passVer
if
(
param
)
{
param
->
passVer
=
pTscObj
->
passInfo
.
ver
;
}
_return:
_return:
releaseTscObj
(
connKey
->
tscRid
);
releaseTscObj
(
connKey
->
tscRid
);
if
(
code
)
{
if
(
code
)
{
...
@@ -714,13 +727,16 @@ int32_t hbGetAppInfo(int64_t clusterId, SClientHbReq *req) {
...
@@ -714,13 +727,16 @@ int32_t hbGetAppInfo(int64_t clusterId, SClientHbReq *req) {
}
}
int32_t
hbQueryHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
int32_t
hbQueryHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
SHbParam
*
hbParam
=
(
SHbParam
*
)
param
;
int32_t
code
=
0
;
struct
SCatalog
*
pCatalog
=
NULL
;
SHbParam
*
hbParam
=
(
SHbParam
*
)
param
;
SCatalog
*
pCatalog
=
NULL
;
int32_t
code
=
catalogGetHandle
(
hbParam
->
clusterId
,
&
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
hbParam
->
reqCnt
==
0
)
{
tscWarn
(
"catalogGetHandle failed, clusterId:%"
PRIx64
", error:%s"
,
hbParam
->
clusterId
,
tstrerror
(
code
));
code
=
catalogGetHandle
(
hbParam
->
clusterId
,
&
pCatalog
);
return
code
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscWarn
(
"catalogGetHandle failed, clusterId:%"
PRIx64
", error:%s"
,
hbParam
->
clusterId
,
tstrerror
(
code
));
return
code
;
}
}
}
hbGetAppInfo
(
hbParam
->
clusterId
,
req
);
hbGetAppInfo
(
hbParam
->
clusterId
,
req
);
...
@@ -728,24 +744,28 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
...
@@ -728,24 +744,28 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
hbGetQueryBasicInfo
(
connKey
,
req
);
hbGetQueryBasicInfo
(
connKey
,
req
);
if
(
hbParam
->
passKeyCnt
>
0
)
{
if
(
hbParam
->
passKeyCnt
>
0
)
{
hbGetUserBasicInfo
(
connKey
,
req
);
hbGetUserBasicInfo
(
connKey
,
hbParam
,
req
);
}
}
code
=
hbGetExpiredUserInfo
(
connKey
,
pCatalog
,
req
);
if
(
hbParam
->
reqCnt
==
0
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
code
=
hbGetExpiredUserInfo
(
connKey
,
pCatalog
,
req
);
return
code
;
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
}
return
code
;
}
code
=
hbGetExpiredDBInfo
(
connKey
,
pCatalog
,
req
);
code
=
hbGetExpiredDBInfo
(
connKey
,
pCatalog
,
req
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
code
=
hbGetExpiredStbInfo
(
connKey
,
pCatalog
,
req
);
code
=
hbGetExpiredStbInfo
(
connKey
,
pCatalog
,
req
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
}
++
hbParam
->
reqCnt
;
// success to get catalog info
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -766,6 +786,10 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
...
@@ -766,6 +786,10 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
}
}
int32_t
connKeyCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
int32_t
connKeyCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
pBatchReq
->
reqs
=
taosArrayInit
(
connKeyCnt
,
sizeof
(
SClientHbReq
));
pBatchReq
->
reqs
=
taosArrayInit
(
connKeyCnt
,
sizeof
(
SClientHbReq
));
if
(
!
pBatchReq
->
reqs
)
{
tFreeClientHbBatchReq
(
pBatchReq
);
return
NULL
;
}
int64_t
rid
=
-
1
;
int64_t
rid
=
-
1
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -782,12 +806,18 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
...
@@ -782,12 +806,18 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
return
NULL
;
return
NULL
;
}
}
SHbParam
param
=
{
0
};
while
(
pIter
!=
NULL
)
{
while
(
pIter
!=
NULL
)
{
pOneReq
=
taosArrayPush
(
pBatchReq
->
reqs
,
pOneReq
);
pOneReq
=
taosArrayPush
(
pBatchReq
->
reqs
,
pOneReq
);
SHbParam
param
;
switch
(
pOneReq
->
connKey
.
connType
)
{
switch
(
pOneReq
->
connKey
.
connType
)
{
case
CONN_TYPE__QUERY
:
{
case
CONN_TYPE__QUERY
:
{
param
.
clusterId
=
pOneReq
->
clusterId
;
if
(
param
.
clusterId
==
0
)
{
// init
param
.
clusterId
=
pOneReq
->
clusterId
;
param
.
passVer
=
INT32_MIN
;
}
param
.
passKeyCnt
=
atomic_load_32
(
&
pAppHbMgr
->
passKeyCnt
);
param
.
passKeyCnt
=
atomic_load_32
(
&
pAppHbMgr
->
passKeyCnt
);
break
;
break
;
}
}
...
@@ -801,9 +831,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
...
@@ -801,9 +831,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
pOneReq
->
connKey
.
tscRid
,
pOneReq
->
connKey
.
connType
);
pOneReq
->
connKey
.
tscRid
,
pOneReq
->
connKey
.
connType
);
}
}
}
}
break
;
#if 0
if
(
code
)
{
if
(
code
)
{
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pOneReq
=
pIter
;
pOneReq
=
pIter
;
...
@@ -812,7 +840,6 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
...
@@ -812,7 +840,6 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
pOneReq
=
pIter
;
pOneReq
=
pIter
;
#endif
}
}
releaseTscObj
(
rid
);
releaseTscObj
(
rid
);
...
@@ -885,7 +912,6 @@ static void *hbThreadFunc(void *param) {
...
@@ -885,7 +912,6 @@ static void *hbThreadFunc(void *param) {
hbGatherAppInfo
();
hbGatherAppInfo
();
}
}
SArray
*
mgr
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SAppHbMgr
*
pAppHbMgr
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
i
);
SAppHbMgr
*
pAppHbMgr
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
i
);
if
(
pAppHbMgr
==
NULL
)
{
if
(
pAppHbMgr
==
NULL
)
{
...
@@ -894,7 +920,6 @@ static void *hbThreadFunc(void *param) {
...
@@ -894,7 +920,6 @@ static void *hbThreadFunc(void *param) {
int32_t
connCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
int32_t
connCnt
=
atomic_load_32
(
&
pAppHbMgr
->
connKeyCnt
);
if
(
connCnt
==
0
)
{
if
(
connCnt
==
0
)
{
taosArrayPush
(
mgr
,
&
pAppHbMgr
);
continue
;
continue
;
}
}
SClientHbBatchReq
*
pReq
=
hbGatherAllInfo
(
pAppHbMgr
);
SClientHbBatchReq
*
pReq
=
hbGatherAllInfo
(
pAppHbMgr
);
...
@@ -908,7 +933,6 @@ static void *hbThreadFunc(void *param) {
...
@@ -908,7 +933,6 @@ static void *hbThreadFunc(void *param) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tFreeClientHbBatchReq
(
pReq
);
tFreeClientHbBatchReq
(
pReq
);
// hbClearReqInfo(pAppHbMgr);
// hbClearReqInfo(pAppHbMgr);
taosArrayPush
(
mgr
,
&
pAppHbMgr
);
break
;
break
;
}
}
...
@@ -920,7 +944,6 @@ static void *hbThreadFunc(void *param) {
...
@@ -920,7 +944,6 @@ static void *hbThreadFunc(void *param) {
tFreeClientHbBatchReq
(
pReq
);
tFreeClientHbBatchReq
(
pReq
);
// hbClearReqInfo(pAppHbMgr);
// hbClearReqInfo(pAppHbMgr);
taosMemoryFree
(
buf
);
taosMemoryFree
(
buf
);
taosArrayPush
(
mgr
,
&
pAppHbMgr
);
break
;
break
;
}
}
pInfo
->
fp
=
hbAsyncCallBack
;
pInfo
->
fp
=
hbAsyncCallBack
;
...
@@ -941,12 +964,8 @@ static void *hbThreadFunc(void *param) {
...
@@ -941,12 +964,8 @@ static void *hbThreadFunc(void *param) {
// hbClearReqInfo(pAppHbMgr);
// hbClearReqInfo(pAppHbMgr);
atomic_add_fetch_32
(
&
pAppHbMgr
->
reportCnt
,
1
);
atomic_add_fetch_32
(
&
pAppHbMgr
->
reportCnt
,
1
);
taosArrayPush
(
mgr
,
&
pAppHbMgr
);
}
}
taosArrayDestroy
(
clientHbMgr
.
appHbMgrs
);
clientHbMgr
.
appHbMgrs
=
mgr
;
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
taosThreadMutexUnlock
(
&
clientHbMgr
.
lock
);
taosMsleep
(
HEARTBEAT_INTERVAL
);
taosMsleep
(
HEARTBEAT_INTERVAL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录