Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
47ace000
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47ace000
编写于
1月 05, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: refactor some sync func names for pipelining
上级
3e215fc6
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
28 addition
and
31 deletion
+28
-31
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+2
-2
source/libs/sync/inc/syncPipeline.h
source/libs/sync/inc/syncPipeline.h
+6
-6
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+2
-2
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+2
-2
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+16
-19
未找到文件。
source/libs/sync/inc/syncMessage.h
浏览文件 @
47ace000
...
...
@@ -258,7 +258,7 @@ int32_t syncBuildRequestVote(SRpcMsg* pMsg, int32_t vgId);
int32_t
syncBuildRequestVoteReply
(
SRpcMsg
*
pMsg
,
int32_t
vgId
);
int32_t
syncBuildAppendEntries
(
SRpcMsg
*
pMsg
,
int32_t
dataLen
,
int32_t
vgId
);
int32_t
syncBuildAppendEntriesReply
(
SRpcMsg
*
pMsg
,
int32_t
vgId
);
int32_t
syncBuildAppendEntriesFromRaft
Log
(
SSyncNode
*
pNode
,
SSyncRaftEntry
*
pEntry
,
SyncTerm
prevLogTerm
,
int32_t
syncBuildAppendEntriesFromRaft
Entry
(
SSyncNode
*
pNode
,
SSyncRaftEntry
*
pEntry
,
SyncTerm
prevLogTerm
,
SRpcMsg
*
pRpcMsg
);
int32_t
syncBuildHeartbeat
(
SRpcMsg
*
pMsg
,
int32_t
vgId
);
int32_t
syncBuildHeartbeatReply
(
SRpcMsg
*
pMsg
,
int32_t
vgId
);
...
...
source/libs/sync/inc/syncPipeline.h
浏览文件 @
47ace000
...
...
@@ -78,14 +78,14 @@ static FORCE_INLINE int32_t syncLogGetNextRetryBackoff(SSyncLogReplMgr* pMgr) {
SyncTerm
syncLogReplMgrGetPrevLogTerm
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
);
int32_t
syncLogReplMgrReplicateOnce
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
);
int32_t
syncLog
Buffe
rReplicateOneTo
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
,
SyncTerm
*
pTerm
,
int32_t
syncLog
ReplMg
rReplicateOneTo
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
,
SyncTerm
*
pTerm
,
SRaftId
*
pDestId
,
bool
*
pBarrier
);
int32_t
syncLogReplMgrReplicateAttempt
edOnce
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
);
int32_t
syncLogReplMgrReplicateProbe
Once
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
);
int32_t
syncLogReplMgrReplicateAttempt
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
);
int32_t
syncLogReplMgrReplicateProbe
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
);
int32_t
syncLogReplMgrProcessReply
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncLogReplMgrProcessReplyInRecoveryMode
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncLogReplMgrProcessReply
InNormalMode
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncLogReplMgrProcessReplyAsRecovery
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncLogReplMgrProcessReply
AsNormal
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
syncLogReplMgrProcessHeartbeatReply
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncHeartbeatReply
*
pMsg
);
int32_t
syncLogReplMgrRetryOnNeed
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
47ace000
...
...
@@ -127,7 +127,7 @@ int32_t syncNodeFollowerCommit(SSyncNode* ths, SyncIndex newCommitIndex) {
return
0
;
}
SSyncRaftEntry
*
sync
LogAppendEntriesToRaftEntry
(
const
SyncAppendEntries
*
pMsg
)
{
SSyncRaftEntry
*
sync
BuildRaftEntryFromAppendEntries
(
const
SyncAppendEntries
*
pMsg
)
{
SSyncRaftEntry
*
pEntry
=
taosMemoryMalloc
(
pMsg
->
dataLen
);
if
(
pEntry
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -181,7 +181,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
goto
_IGNORE
;
}
SSyncRaftEntry
*
pEntry
=
sync
LogAppendEntriesToRaftEntry
(
pMsg
);
SSyncRaftEntry
*
pEntry
=
sync
BuildRaftEntryFromAppendEntries
(
pMsg
);
if
(
pEntry
==
NULL
)
{
sError
(
"vgId:%d, failed to get raft entry from append entries since %s"
,
ths
->
vgId
,
terrstr
());
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
47ace000
...
...
@@ -154,7 +154,7 @@ int32_t syncBuildAppendEntriesReply(SRpcMsg* pMsg, int32_t vgId) {
return
0
;
}
int32_t
syncBuildAppendEntriesFromRaft
Log
(
SSyncNode
*
pNode
,
SSyncRaftEntry
*
pEntry
,
SyncTerm
prevLogTerm
,
int32_t
syncBuildAppendEntriesFromRaft
Entry
(
SSyncNode
*
pNode
,
SSyncRaftEntry
*
pEntry
,
SyncTerm
prevLogTerm
,
SRpcMsg
*
pRpcMsg
)
{
uint32_t
dataLen
=
pEntry
->
bytes
;
uint32_t
bytes
=
sizeof
(
SyncAppendEntries
)
+
dataLen
;
...
...
source/libs/sync/src/syncPipeline.c
浏览文件 @
47ace000
...
...
@@ -617,7 +617,7 @@ int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) {
}
bool
barrier
=
false
;
if
(
syncLog
Buffe
rReplicateOneTo
(
pMgr
,
pNode
,
index
,
&
term
,
pDestId
,
&
barrier
)
<
0
)
{
if
(
syncLog
ReplMg
rReplicateOneTo
(
pMgr
,
pNode
,
index
,
&
term
,
pDestId
,
&
barrier
)
<
0
)
{
sError
(
"vgId:%d, failed to replicate sync log entry since %s. index: %"
PRId64
", dest: %"
PRIx64
""
,
pNode
->
vgId
,
terrstr
(),
index
,
pDestId
->
addr
);
goto
_out
;
...
...
@@ -647,8 +647,7 @@ _out:
return
ret
;
}
int32_t
syncLogReplMgrProcessReplyInRecoveryMode
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
)
{
int32_t
syncLogReplMgrProcessReplyAsRecovery
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
)
{
SSyncLogBuffer
*
pBuf
=
pNode
->
pLogBuf
;
SRaftId
destId
=
pMsg
->
srcId
;
ASSERT
(
pMgr
->
restored
==
false
);
...
...
@@ -723,7 +722,7 @@ int32_t syncLogReplMgrProcessReplyInRecoveryMode(SSyncLogReplMgr* pMgr, SSyncNod
// attempt to replicate the raft log at index
(
void
)
syncLogReplMgrReset
(
pMgr
);
return
syncLogReplMgrReplicateProbe
Once
(
pMgr
,
pNode
,
index
);
return
syncLogReplMgrReplicateProbe
(
pMgr
,
pNode
,
index
);
}
int32_t
syncLogReplMgrProcessHeartbeatReply
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncHeartbeatReply
*
pMsg
)
{
...
...
@@ -751,9 +750,9 @@ int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sync
}
if
(
pMgr
->
restored
)
{
(
void
)
syncLogReplMgrProcessReply
InNormalMode
(
pMgr
,
pNode
,
pMsg
);
(
void
)
syncLogReplMgrProcessReply
AsNormal
(
pMgr
,
pNode
,
pMsg
);
}
else
{
(
void
)
syncLogReplMgrProcessReply
InRecoveryMode
(
pMgr
,
pNode
,
pMsg
);
(
void
)
syncLogReplMgrProcessReply
AsRecovery
(
pMgr
,
pNode
,
pMsg
);
}
taosThreadMutexUnlock
(
&
pBuf
->
mutex
);
return
0
;
...
...
@@ -761,14 +760,14 @@ int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Sync
int32_t
syncLogReplMgrReplicateOnce
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
)
{
if
(
pMgr
->
restored
)
{
(
void
)
syncLogReplMgrReplicateAttempt
edOnce
(
pMgr
,
pNode
);
(
void
)
syncLogReplMgrReplicateAttempt
(
pMgr
,
pNode
);
}
else
{
(
void
)
syncLogReplMgrReplicateProbe
Once
(
pMgr
,
pNode
,
pNode
->
pLogBuf
->
matchIndex
);
(
void
)
syncLogReplMgrReplicateProbe
(
pMgr
,
pNode
,
pNode
->
pLogBuf
->
matchIndex
);
}
return
0
;
}
int32_t
syncLogReplMgrReplicateProbe
Once
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
)
{
int32_t
syncLogReplMgrReplicateProbe
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
)
{
ASSERT
(
!
pMgr
->
restored
);
ASSERT
(
pMgr
->
startIndex
>=
0
);
int64_t
retryMaxWaitMs
=
SYNC_LOG_REPL_RETRY_WAIT_MS
*
(
1
<<
SYNC_MAX_RETRY_BACKOFF
);
...
...
@@ -783,7 +782,7 @@ int32_t syncLogReplMgrReplicateProbeOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode
SRaftId
*
pDestId
=
&
pNode
->
replicasId
[
pMgr
->
peerId
];
bool
barrier
=
false
;
SyncTerm
term
=
-
1
;
if
(
syncLog
Buffe
rReplicateOneTo
(
pMgr
,
pNode
,
index
,
&
term
,
pDestId
,
&
barrier
)
<
0
)
{
if
(
syncLog
ReplMg
rReplicateOneTo
(
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
,
terrstr
(),
index
,
pDestId
->
addr
);
return
-
1
;
...
...
@@ -807,7 +806,7 @@ int32_t syncLogReplMgrReplicateProbeOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode
return
0
;
}
int32_t
syncLogReplMgrReplicateAttempt
edOnce
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
)
{
int32_t
syncLogReplMgrReplicateAttempt
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
)
{
ASSERT
(
pMgr
->
restored
);
SRaftId
*
pDestId
=
&
pNode
->
replicasId
[
pMgr
->
peerId
];
...
...
@@ -827,7 +826,7 @@ int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* p
SRaftId
*
pDestId
=
&
pNode
->
replicasId
[
pMgr
->
peerId
];
bool
barrier
=
false
;
SyncTerm
term
=
-
1
;
if
(
syncLog
Buffe
rReplicateOneTo
(
pMgr
,
pNode
,
index
,
&
term
,
pDestId
,
&
barrier
)
<
0
)
{
if
(
syncLog
ReplMg
rReplicateOneTo
(
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
,
terrstr
(),
index
,
pDestId
->
addr
);
return
-
1
;
...
...
@@ -857,7 +856,7 @@ int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* p
return
0
;
}
int32_t
syncLogReplMgrProcessReply
InNormalMode
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
)
{
int32_t
syncLogReplMgrProcessReply
AsNormal
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncAppendEntriesReply
*
pMsg
)
{
ASSERT
(
pMgr
->
restored
==
true
);
if
(
pMgr
->
startIndex
<=
pMsg
->
lastSendIndex
&&
pMsg
->
lastSendIndex
<
pMgr
->
endIndex
)
{
if
(
pMgr
->
startIndex
<
pMgr
->
matchIndex
&&
pMgr
->
retryBackoff
>
0
)
{
...
...
@@ -876,7 +875,7 @@ int32_t syncLogReplMgrProcessReplyInNormalMode(SSyncLogReplMgr* pMgr, SSyncNode*
pMgr
->
startIndex
=
pMgr
->
matchIndex
;
}
return
syncLogReplMgrReplicateAttempt
edOnce
(
pMgr
,
pNode
);
return
syncLogReplMgrReplicateAttempt
(
pMgr
,
pNode
);
}
SSyncLogReplMgr
*
syncLogReplMgrCreate
()
{
...
...
@@ -1066,12 +1065,11 @@ SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode,
return
pEntry
;
}
int32_t
syncLog
Buffe
rReplicateOneTo
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
,
SyncTerm
*
pTerm
,
int32_t
syncLog
ReplMg
rReplicateOneTo
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
,
SyncIndex
index
,
SyncTerm
*
pTerm
,
SRaftId
*
pDestId
,
bool
*
pBarrier
)
{
SSyncRaftEntry
*
pEntry
=
NULL
;
SRpcMsg
msgOut
=
{
0
};
bool
inBuf
=
false
;
int32_t
ret
=
-
1
;
SyncTerm
prevLogTerm
=
-
1
;
SSyncLogBuffer
*
pBuf
=
pNode
->
pLogBuf
;
...
...
@@ -1097,14 +1095,13 @@ int32_t syncLogBufferReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, Syn
}
if
(
pTerm
)
*
pTerm
=
pEntry
->
term
;
int32_t
code
=
syncBuildAppendEntriesFromRaft
Log
(
pNode
,
pEntry
,
prevLogTerm
,
&
msgOut
);
int32_t
code
=
syncBuildAppendEntriesFromRaft
Entry
(
pNode
,
pEntry
,
prevLogTerm
,
&
msgOut
);
if
(
code
<
0
)
{
sError
(
"vgId:%d, failed to get append entries for index:%"
PRId64
""
,
pNode
->
vgId
,
index
);
goto
_err
;
}
(
void
)
syncNodeSendAppendEntries
(
pNode
,
pDestId
,
&
msgOut
);
ret
=
0
;
sTrace
(
"vgId:%d, replicate one msg index: %"
PRId64
" term: %"
PRId64
" prevterm: %"
PRId64
" to dest: 0x%016"
PRIx64
,
pNode
->
vgId
,
pEntry
->
index
,
pEntry
->
term
,
prevLogTerm
,
pDestId
->
addr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录