Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d5ae1ca1
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看板
提交
d5ae1ca1
编写于
11月 25, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: make the range span of unconfirmed logs sent less than half of the size of log ring buffer
上级
ff286e1f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
14 deletion
+31
-14
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-1
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+30
-13
未找到文件。
include/libs/sync/sync.h
浏览文件 @
d5ae1ca1
...
...
@@ -41,7 +41,7 @@ extern "C" {
#define SNAPSHOT_WAIT_MS 1000 * 30
#define SYNC_MAX_RETRY_BACKOFF 5
#define SYNC_LOG_REPL_RETRY_WAIT_MS
5
0
#define SYNC_LOG_REPL_RETRY_WAIT_MS
10
0
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
#define SYNC_MAX_BATCH_SIZE 1
...
...
source/libs/sync/src/syncPipeline.c
浏览文件 @
d5ae1ca1
...
...
@@ -566,33 +566,42 @@ int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr) {
return
0
;
}
_Atomic
int64_t
tsRetryCnt
=
0
;
int32_t
syncLogReplMgrRetryOnNeed
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
)
{
if
(
pMgr
->
endIndex
<=
pMgr
->
startIndex
)
{
return
0
;
}
SRaftId
*
pDestId
=
&
pNode
->
replicasId
[
pMgr
->
peerId
];
if
(
pMgr
->
retryBackoff
==
SYNC_MAX_RETRY_BACKOFF
)
{
syncLogReplMgrReset
(
pMgr
);
sWarn
(
"vgId:%d, reset sync log repl mgr since retry backoff exceeding limit. peer: %"
PRIx64
,
pNode
->
vgId
,
pDestId
->
addr
);
return
-
1
;
}
int32_t
ret
=
-
1
;
bool
retried
=
false
;
int64_t
retryWaitMs
=
syncLogGetRetryBackoffTimeMs
(
pMgr
);
int64_t
nowMs
=
taosGetMonoTimestampMs
();
int
count
=
0
;
int64_t
firstIndex
=
-
1
;
SyncTerm
term
=
-
1
;
for
(
SyncIndex
index
=
pMgr
->
startIndex
;
index
<
pMgr
->
endIndex
;
index
++
)
{
int64_t
pos
=
index
%
pMgr
->
size
;
ASSERT
(
!
pMgr
->
states
[
pos
].
barrier
||
(
index
==
pMgr
->
startIndex
||
index
+
1
==
pMgr
->
endIndex
));
if
(
pMgr
->
states
[
pos
].
acked
)
{
continue
;
}
int64_t
nowMs
=
taosGetMonoTimestampMs
();
if
(
nowMs
<
pMgr
->
states
[
pos
].
timeMs
+
retryWaitMs
)
{
break
;
}
SRaftId
*
pDestId
=
&
pNode
->
replicasId
[
pMgr
->
peerId
];
bool
barrier
=
false
;
SyncTerm
term
=
-
1
;
if
(
pMgr
->
states
[
pos
].
acked
)
{
continue
;
}
bool
barrier
=
false
;
if
(
syncLogBufferReplicateOneTo
(
pMgr
,
pNode
,
index
,
&
term
,
pDestId
,
&
barrier
)
<
0
)
{
sError
(
"vgId:%d, failed to replicate log entry since %s. index: %"
PRId64
", dest:
0x%016
"
PRIx64
""
,
pNode
->
vgId
,
sError
(
"vgId:%d, failed to replicate log entry since %s. index: %"
PRId64
", dest:
%
"
PRIx64
""
,
pNode
->
vgId
,
terrstr
(),
index
,
pDestId
->
addr
);
goto
_out
;
}
...
...
@@ -601,13 +610,19 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
pMgr
->
states
[
pos
].
term
=
term
;
pMgr
->
states
[
pos
].
acked
=
false
;
retried
=
true
;
tsRetryCnt
++
;
if
(
firstIndex
==
-
1
)
firstIndex
=
index
;
count
++
;
}
ret
=
0
;
_out:
if
(
retried
)
{
pMgr
->
retryBackoff
=
syncLogGetNextRetryBackoff
(
pMgr
);
sInfo
(
"vgId:%d, resend %d raft log entries. dest: %"
PRIx64
", for indexes: %"
PRId64
" etc., maybe of term: %"
PRId64
", retryWaitMs: %"
PRId64
", repl mgr: [%"
PRId64
" %"
PRId64
", %"
PRId64
")"
,
pNode
->
vgId
,
count
,
pDestId
->
addr
,
firstIndex
,
term
,
retryWaitMs
,
pMgr
->
startIndex
,
pMgr
->
matchIndex
,
pMgr
->
endIndex
);
}
return
ret
;
}
...
...
@@ -771,9 +786,10 @@ int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* p
int32_t
batchSize
=
TMAX
(
1
,
pMgr
->
size
/
20
);
int32_t
count
=
0
;
int64_t
nowMs
=
taosGetMonoTimestampMs
();
int64_t
limit
=
pMgr
->
size
>>
1
;
for
(
SyncIndex
index
=
pMgr
->
endIndex
;
index
<=
pNode
->
pLogBuf
->
matchIndex
;
index
++
)
{
if
(
batchSize
<
count
++
||
pMgr
->
startIndex
+
pMgr
->
size
<=
i
ndex
)
{
if
(
batchSize
<
count
++
||
limit
<=
index
-
pMgr
->
startI
ndex
)
{
break
;
}
if
(
pMgr
->
startIndex
+
1
<
index
&&
pMgr
->
states
[(
index
-
1
)
%
pMgr
->
size
].
barrier
)
{
...
...
@@ -800,12 +816,13 @@ int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* p
}
}
syncLogReplMgrRetryOnNeed
(
pMgr
,
pNode
);
SSyncLogBuffer
*
pBuf
=
pNode
->
pLogBuf
;
sTrace
(
"vgId:%d, attempted to replicate %d msgs to the %d'th peer. pMgr(rs:%d): [%"
PRId64
" %"
PRId64
", %"
PRId64
"), pBuf: [%"
PRId64
" %"
PRId64
" %"
PRId64
", %"
PRId64
")"
,
pNode
->
vgId
,
count
,
pMgr
->
peerId
,
pMgr
->
restored
,
pMgr
->
startIndex
,
pMgr
->
matchIndex
,
pMgr
->
endIndex
,
pBuf
->
startIndex
,
pBuf
->
commitIndex
,
pBuf
->
matchIndex
,
pBuf
->
endIndex
);
syncLogReplMgrRetryOnNeed
(
pMgr
,
pNode
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录