Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba23ed23
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
ba23ed23
编写于
11月 20, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add simple retry
上级
7e010dce
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
8 deletion
+62
-8
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+5
-0
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+9
-0
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+5
-0
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+5
-0
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+38
-8
未找到文件。
include/libs/transport/trpc.h
浏览文件 @
ba23ed23
...
...
@@ -85,6 +85,11 @@ typedef struct SRpcInit {
int32_t
retryLimit
;
// retry limit
int32_t
retryInterval
;
// retry interval ms
int32_t
retryMinInterval
;
// retry init interval
int32_t
retryStepFactor
;
// retry interval factor
int32_t
retryMaxInterval
;
// retry max interval
int32_t
retryMaxTimouet
;
int32_t
compressSize
;
// -1: no compress, 0 : all data compressed, size: compress data if larger than size
int8_t
encryption
;
// encrypt or not
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
ba23ed23
...
...
@@ -146,6 +146,15 @@ typedef struct {
SCvtAddr
cvtAddr
;
bool
setMaxRetry
;
int32_t
retryMinInterval
;
int32_t
retryMaxInterval
;
int32_t
retryStepFactor
;
int32_t
retryMaxTimeout
;
int64_t
retryInitTimestamp
;
int64_t
retryNextInterval
;
bool
retryInit
;
int32_t
retryStep
;
int
hThrdIdx
;
}
STransConnCtx
;
...
...
source/libs/transport/inc/transportInt.h
浏览文件 @
ba23ed23
...
...
@@ -52,6 +52,11 @@ typedef struct {
int32_t
retryLimit
;
// retry limit
int32_t
retryInterval
;
// retry interval ms
int32_t
retryMinInterval
;
// retry init interval
int32_t
retryStepFactor
;
// retry interval factor
int32_t
retryMaxInterval
;
// retry max interval
int32_t
retryMaxTimouet
;
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
bool
(
*
retry
)(
int32_t
code
,
tmsg_t
msgType
);
bool
(
*
startTimer
)(
int32_t
code
,
tmsg_t
msgType
);
...
...
source/libs/transport/src/trans.c
浏览文件 @
ba23ed23
...
...
@@ -51,6 +51,11 @@ void* rpcOpen(const SRpcInit* pInit) {
pRpc
->
retryLimit
=
pInit
->
retryLimit
;
pRpc
->
retryInterval
=
pInit
->
retryInterval
;
pRpc
->
retryMinInterval
=
pInit
->
retryMinInterval
;
// retry init interval
pRpc
->
retryStepFactor
=
pInit
->
retryStepFactor
;
pRpc
->
retryMaxInterval
=
pInit
->
retryMaxInterval
;
pRpc
->
retryMaxTimouet
=
pInit
->
retryMaxTimouet
;
// register callback handle
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
retry
=
pInit
->
rfp
;
...
...
source/libs/transport/src/transCli.c
浏览文件 @
ba23ed23
...
...
@@ -1371,7 +1371,8 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
STaskArg
*
arg
=
taosMemoryMalloc
(
sizeof
(
STaskArg
));
arg
->
param1
=
pMsg
;
arg
->
param2
=
pThrd
;
transDQSched
(
pThrd
->
delayQueue
,
doDelayTask
,
arg
,
pTransInst
->
retryInterval
);
transDQSched
(
pThrd
->
delayQueue
,
doDelayTask
,
arg
,
pCtx
->
retryNextInterval
);
}
FORCE_INLINE
void
cliCompareAndSwap
(
int8_t
*
val
,
int8_t
exp
,
int8_t
newVal
)
{
...
...
@@ -1419,18 +1420,47 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
int32_t
code
=
pResp
->
code
;
bool
retry
=
(
pTransInst
->
retry
!=
NULL
&&
pTransInst
->
retry
(
code
,
pResp
->
msgType
-
1
))
?
true
:
false
;
if
(
retry
==
true
)
{
if
(
!
pCtx
->
retryInit
)
{
pCtx
->
retryMinInterval
=
pTransInst
->
retryMinInterval
;
pCtx
->
retryMaxInterval
=
pTransInst
->
retryMaxInterval
;
pCtx
->
retryStepFactor
=
pTransInst
->
retryStepFactor
;
pCtx
->
retryMaxTimeout
=
pTransInst
->
retryMaxTimouet
;
pCtx
->
retryInit
=
true
;
pCtx
->
retryStep
=
1
;
pCtx
->
retryInitTimestamp
=
taosGetTimestampMs
();
pCtx
->
retryNextInterval
=
pCtx
->
retryMinInterval
;
}
else
{
pCtx
->
retryStep
++
;
int64_t
factor
=
1
;
for
(
int
i
=
0
;
i
<
pCtx
->
retryStep
-
1
;
i
++
)
{
factor
*=
pCtx
->
retryStepFactor
;
}
pCtx
->
retryNextInterval
=
factor
*
pCtx
->
retryMinInterval
;
if
(
pCtx
->
retryNextInterval
>=
pCtx
->
retryMaxInterval
)
{
pCtx
->
retryNextInterval
=
pCtx
->
retryMaxInterval
;
}
}
if
(
taosGetTimestampMs
()
-
pCtx
->
retryInitTimestamp
>=
pCtx
->
retryMaxTimeout
)
{
retry
=
false
;
}
}
if
(
retry
)
{
pMsg
->
sent
=
0
;
pCtx
->
retryCnt
+=
1
;
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
)
{
cliCompareAndSwap
(
&
pCtx
->
retryLimit
,
pTransInst
->
retryLimit
,
EPSET_GET_SIZE
(
&
pCtx
->
epSet
)
*
3
);
if
(
pCtx
->
retryCnt
<
pCtx
->
retryLimit
)
{
transUnrefCliHandle
(
pConn
);
EPSET_FORWARD_INUSE
(
&
pCtx
->
epSet
);
transFreeMsg
(
pResp
->
pCont
);
cliSchedMsgToNextNode
(
pMsg
,
pThrd
);
return
-
1
;
}
//
if (pCtx->retryCnt < pCtx->retryLimit) {
transUnrefCliHandle
(
pConn
);
EPSET_FORWARD_INUSE
(
&
pCtx
->
epSet
);
transFreeMsg
(
pResp
->
pCont
);
cliSchedMsgToNextNode
(
pMsg
,
pThrd
);
return
-
1
;
//
}
}
else
{
cliCompareAndSwap
(
&
pCtx
->
retryLimit
,
pTransInst
->
retryLimit
,
pTransInst
->
retryLimit
);
if
(
pCtx
->
retryCnt
<
pCtx
->
retryLimit
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录