Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b958030b
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看板
提交
b958030b
编写于
4月 17, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: remove unused functions in sync
上级
0993510d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
7 addition
and
63 deletion
+7
-63
source/libs/sync/inc/syncCommit.h
source/libs/sync/inc/syncCommit.h
+0
-2
source/libs/sync/inc/syncReplication.h
source/libs/sync/inc/syncReplication.h
+0
-1
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+1
-12
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+0
-29
source/libs/sync/src/syncRaftEntry.c
source/libs/sync/src/syncRaftEntry.c
+6
-3
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+0
-16
未找到文件。
source/libs/sync/inc/syncCommit.h
浏览文件 @
b958030b
...
...
@@ -48,8 +48,6 @@ extern "C" {
void
syncOneReplicaAdvance
(
SSyncNode
*
pSyncNode
);
void
syncMaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
);
bool
syncAgreeIndex
(
SSyncNode
*
pSyncNode
,
SRaftId
*
pRaftId
,
SyncIndex
index
);
bool
syncAgree
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
);
bool
syncNodeAgreedUpon
(
SSyncNode
*
pNode
,
SyncIndex
index
);
int64_t
syncNodeUpdateCommitIndex
(
SSyncNode
*
ths
,
SyncIndex
commitIndex
);
...
...
source/libs/sync/inc/syncReplication.h
浏览文件 @
b958030b
...
...
@@ -55,7 +55,6 @@ int32_t syncNodeReplicateReset(SSyncNode* pSyncNode, SRaftId* pDestId);
int32_t
syncNodeReplicateWithoutLock
(
SSyncNode
*
pNode
);
int32_t
syncNodeSendAppendEntries
(
SSyncNode
*
pNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
);
int32_t
syncNodeMaybeSendAppendEntries
(
SSyncNode
*
pNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
);
#ifdef __cplusplus
}
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
b958030b
...
...
@@ -89,17 +89,6 @@
// /\ UNCHANGED <<candidateVars, leaderVars>>
//
SSyncRaftEntry
*
syncBuildRaftEntryFromAppendEntries
(
const
SyncAppendEntries
*
pMsg
)
{
SSyncRaftEntry
*
pEntry
=
taosMemoryMalloc
(
pMsg
->
dataLen
);
if
(
pEntry
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
(
void
)
memcpy
(
pEntry
,
pMsg
->
data
,
pMsg
->
dataLen
);
ASSERT
(
pEntry
->
bytes
==
pMsg
->
dataLen
);
return
pEntry
;
}
int32_t
syncNodeOnAppendEntries
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
SyncAppendEntries
*
pMsg
=
pRpcMsg
->
pCont
;
SRpcMsg
rpcRsp
=
{
0
};
...
...
@@ -146,7 +135,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
goto
_IGNORE
;
}
pEntry
=
sync
BuildRaftEntry
FromAppendEntries
(
pMsg
);
pEntry
=
sync
EntryBuild
FromAppendEntries
(
pMsg
);
if
(
pEntry
==
NULL
)
{
sError
(
"vgId:%d, failed to get raft entry from append entries since %s"
,
ths
->
vgId
,
terrstr
());
goto
_IGNORE
;
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
b958030b
...
...
@@ -44,22 +44,6 @@
// /\ UNCHANGED <<messages, serverVars, candidateVars, leaderVars, log>>
//
bool
syncAgreeIndex
(
SSyncNode
*
pSyncNode
,
SRaftId
*
pRaftId
,
SyncIndex
index
)
{
// I am leader, I agree
if
(
syncUtilSameId
(
pRaftId
,
&
(
pSyncNode
->
myRaftId
))
&&
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
return
true
;
}
// follower agree
SyncIndex
matchIndex
=
syncIndexMgrGetIndex
(
pSyncNode
->
pMatchIndex
,
pRaftId
);
if
(
matchIndex
>=
index
)
{
return
true
;
}
// not agree
return
false
;
}
static
inline
int64_t
syncNodeAbs64
(
int64_t
a
,
int64_t
b
)
{
ASSERT
(
a
>=
0
);
ASSERT
(
b
>=
0
);
...
...
@@ -85,19 +69,6 @@ bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index) {
return
count
>=
pNode
->
quorum
;
}
bool
syncAgree
(
SSyncNode
*
pNode
,
SyncIndex
index
)
{
int
agreeCount
=
0
;
for
(
int
i
=
0
;
i
<
pNode
->
replicaNum
;
++
i
)
{
if
(
syncAgreeIndex
(
pNode
,
&
(
pNode
->
replicasId
[
i
]),
index
))
{
++
agreeCount
;
}
if
(
agreeCount
>=
pNode
->
quorum
)
{
return
true
;
}
}
return
false
;
}
int64_t
syncNodeUpdateCommitIndex
(
SSyncNode
*
ths
,
SyncIndex
commitIndex
)
{
SyncIndex
lastVer
=
ths
->
pLogStore
->
syncLogLastIndex
(
ths
->
pLogStore
);
commitIndex
=
TMAX
(
commitIndex
,
ths
->
commitIndex
);
...
...
source/libs/sync/src/syncRaftEntry.c
浏览文件 @
b958030b
...
...
@@ -64,10 +64,13 @@ SSyncRaftEntry* syncEntryBuildFromRpcMsg(const SRpcMsg* pMsg, SyncTerm term, Syn
}
SSyncRaftEntry
*
syncEntryBuildFromAppendEntries
(
const
SyncAppendEntries
*
pMsg
)
{
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
((
int32_t
)(
pMsg
->
dataLen
));
if
(
pEntry
==
NULL
)
return
NULL
;
SSyncRaftEntry
*
pEntry
=
taosMemoryMalloc
(
pMsg
->
dataLen
);
if
(
pEntry
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
memcpy
(
pEntry
,
pMsg
->
data
,
pMsg
->
dataLen
);
ASSERT
(
pEntry
->
bytes
==
pMsg
->
dataLen
);
return
pEntry
;
}
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
b958030b
...
...
@@ -46,8 +46,6 @@
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
int32_t
syncNodeMaybeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
);
int32_t
syncNodeReplicateReset
(
SSyncNode
*
pNode
,
SRaftId
*
pDestId
)
{
SSyncLogBuffer
*
pBuf
=
pNode
->
pLogBuf
;
taosThreadMutexLock
(
&
pBuf
->
mutex
);
...
...
@@ -86,20 +84,6 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI
return
0
;
}
int32_t
syncNodeMaybeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
SyncAppendEntries
*
pMsg
=
pRpcMsg
->
pCont
;
if
(
syncNodeNeedSendAppendEntries
(
pSyncNode
,
destRaftId
,
pMsg
))
{
ret
=
syncNodeSendAppendEntries
(
pSyncNode
,
destRaftId
,
pRpcMsg
);
}
else
{
sNTrace
(
pSyncNode
,
"do not repcate to dnode:%d for index:%"
PRId64
,
DID
(
destRaftId
),
pMsg
->
prevLogIndex
+
1
);
rpcFreeCont
(
pRpcMsg
->
pCont
);
}
return
ret
;
}
int32_t
syncNodeSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destId
,
SRpcMsg
*
pMsg
)
{
return
syncNodeSendMsgById
(
destId
,
pSyncNode
,
pMsg
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录