Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9ab28e0b
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,发现更多精彩内容 >>
提交
9ab28e0b
编写于
6月 17, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): add last config index in fsm cbMeta
上级
455a8da0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
38 addition
and
10 deletion
+38
-10
include/libs/sync/sync.h
include/libs/sync/sync.h
+2
-0
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+2
-1
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+10
-5
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+24
-4
未找到文件。
include/libs/sync/sync.h
浏览文件 @
9ab28e0b
...
...
@@ -62,6 +62,7 @@ typedef struct SSyncCfg {
typedef
struct
SFsmCbMeta
{
SyncIndex
index
;
SyncIndex
lastConfigIndex
;
bool
isWeak
;
int32_t
code
;
ESyncState
state
;
...
...
@@ -75,6 +76,7 @@ typedef struct SReConfigCbMeta {
int32_t
code
;
SyncIndex
index
;
SyncTerm
term
;
SyncIndex
lastConfigIndex
;
SyncTerm
currentTerm
;
SSyncCfg
oldCfg
;
SSyncCfg
newCfg
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
9ab28e0b
...
...
@@ -172,6 +172,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, const SRpcMsg* pMsg, bool isWea
// option
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeGetSnapshotConfigIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
snapshotLastApplyIndex
);
// ping --------------
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
9ab28e0b
...
...
@@ -208,8 +208,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pRollBackEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pRollBackEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -234,8 +235,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pAppendEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pAppendEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pAppendEntry
->
isWeak
;
cbMeta
.
code
=
2
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -266,8 +268,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pAppendEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pAppendEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pAppendEntry
->
isWeak
;
cbMeta
.
code
=
3
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -696,8 +699,9 @@ static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pRollBackEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pRollBackEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -725,8 +729,9 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
2
;
cbMeta
.
state
=
ths
->
state
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
9ab28e0b
...
...
@@ -441,6 +441,21 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
return
0
;
}
SyncIndex
syncNodeGetSnapshotConfigIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
snapshotLastApplyIndex
)
{
ASSERT
(
pSyncNode
->
pRaftCfg
->
configIndexCount
>=
1
);
SyncIndex
lastIndex
=
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
0
];
for
(
int
i
=
0
;
i
<
pSyncNode
->
pRaftCfg
->
configIndexCount
;
++
i
)
{
if
((
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
]
>
lastIndex
&&
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
]
<=
snapshotLastApplyIndex
)
{
lastIndex
=
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
];
}
}
sTrace
(
"sync syncNodeGetSnapshotConfigIndex index:%ld lastConfigIndex:%ld"
,
snapshotLastApplyIndex
,
lastIndex
);
return
lastIndex
;
}
const
char
*
syncGetMyRoleStr
(
int64_t
rid
)
{
const
char
*
s
=
syncUtilState2String
(
syncGetMyRole
(
rid
));
return
s
;
...
...
@@ -2065,8 +2080,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -2087,8 +2103,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
1
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -2152,11 +2169,12 @@ static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
}
*/
if
(
ths
->
pFsm
->
FpLeaderTransferCb
!=
NULL
)
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
code
=
0
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
flag
=
0
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
state
=
ths
->
state
;
...
...
@@ -2258,6 +2276,7 @@ static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
cbMeta
.
code
=
0
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
pEntry
->
index
);
cbMeta
.
term
=
pEntry
->
term
;
cbMeta
.
newCfg
=
newSyncCfg
;
cbMeta
.
oldCfg
=
oldSyncCfg
;
...
...
@@ -2292,8 +2311,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
// user commit
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
&&
syncUtilUserCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录