Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ce538a0a
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看板
未验证
提交
ce538a0a
编写于
3月 07, 2022
作者:
L
Li Minghao
提交者:
GitHub
3月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10592 from taosdata/feature/3.0_mhli
sync refactor
上级
128b6138
cf0857e1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
4 deletion
+57
-4
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+3
-3
source/libs/sync/inc/syncTimeout.h
source/libs/sync/inc/syncTimeout.h
+12
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+18
-0
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+24
-1
未找到文件。
source/libs/sync/inc/syncIO.h
浏览文件 @
ce538a0a
...
@@ -31,11 +31,11 @@ extern "C" {
...
@@ -31,11 +31,11 @@ extern "C" {
typedef
struct
SSyncIO
{
typedef
struct
SSyncIO
{
STaosQueue
*
pMsgQ
;
STaosQueue
*
pMsgQ
;
STaosQset
*
pQset
;
STaosQset
*
pQset
;
pthread_t
consumerTid
;
pthread_t
consumerTid
;
void
*
serverRpc
;
void
*
serverRpc
;
void
*
clientRpc
;
void
*
clientRpc
;
SEpSet
myAddr
;
SEpSet
myAddr
;
void
*
ioTimerTickQ
;
void
*
ioTimerTickQ
;
...
...
source/libs/sync/inc/syncTimeout.h
浏览文件 @
ce538a0a
...
@@ -28,6 +28,18 @@ extern "C" {
...
@@ -28,6 +28,18 @@ extern "C" {
#include "syncRaft.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "taosdef.h"
// TLA+ Spec
// Timeout(i) == /\ state[i] \in {Follower, Candidate}
// /\ state' = [state EXCEPT ![i] = Candidate]
// /\ currentTerm' = [currentTerm EXCEPT ![i] = currentTerm[i] + 1]
// \* Most implementations would probably just set the local vote
// \* atomically, but messaging localhost for it is weaker.
// /\ votedFor' = [votedFor EXCEPT ![i] = Nil]
// /\ votesResponded' = [votesResponded EXCEPT ![i] = {}]
// /\ votesGranted' = [votesGranted EXCEPT ![i] = {}]
// /\ voterLog' = [voterLog EXCEPT ![i] = [j \in {} |-> <<>>]]
// /\ UNCHANGED <<messages, leaderVars, logVars>>
//
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
ce538a0a
...
@@ -363,6 +363,24 @@ static void syncNodeBecomeFollower(SSyncNode* pSyncNode) {
...
@@ -363,6 +363,24 @@ static void syncNodeBecomeFollower(SSyncNode* pSyncNode) {
syncNodeStartElectTimer
(
pSyncNode
,
electMS
);
syncNodeStartElectTimer
(
pSyncNode
,
electMS
);
}
}
// TLA+ Spec
// \* Candidate i transitions to leader.
// BecomeLeader(i) ==
// /\ state[i] = Candidate
// /\ votesGranted[i] \in Quorum
// /\ state' = [state EXCEPT ![i] = Leader]
// /\ nextIndex' = [nextIndex EXCEPT ![i] =
// [j \in Server |-> Len(log[i]) + 1]]
// /\ matchIndex' = [matchIndex EXCEPT ![i] =
// [j \in Server |-> 0]]
// /\ elections' = elections \cup
// {[eterm |-> currentTerm[i],
// eleader |-> i,
// elog |-> log[i],
// evotes |-> votesGranted[i],
// evoterLog |-> voterLog[i]]}
// /\ UNCHANGED <<messages, currentTerm, votedFor, candidateVars, logVars>>
//
static
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
)
{
static
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
)
{
pSyncNode
->
state
=
TAOS_SYNC_STATE_LEADER
;
pSyncNode
->
state
=
TAOS_SYNC_STATE_LEADER
;
pSyncNode
->
leaderCache
=
pSyncNode
->
raftId
;
pSyncNode
->
leaderCache
=
pSyncNode
->
raftId
;
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
ce538a0a
...
@@ -20,7 +20,30 @@ int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncBuffer* pBuf) {
...
@@ -20,7 +20,30 @@ int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncBuffer* pBuf) {
// get one log entry, user need to free pBuf->data
// get one log entry, user need to free pBuf->data
int32_t
raftLogGetEntry
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
,
SSyncBuffer
*
pBuf
)
{
return
0
;
}
int32_t
raftLogGetEntry
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
,
SSyncBuffer
*
pBuf
)
{
return
0
;
}
// update log store commit index with "index"
// TLA+ Spec
// \* Leader i advances its commitIndex.
// \* This is done as a separate step from handling AppendEntries responses,
// \* in part to minimize atomic regions, and in part so that leaders of
// \* single-server clusters are able to mark entries committed.
// AdvanceCommitIndex(i) ==
// /\ state[i] = Leader
// /\ LET \* The set of servers that agree up through index.
// Agree(index) == {i} \cup {k \in Server :
// matchIndex[i][k] >= index}
// \* The maximum indexes for which a quorum agrees
// agreeIndexes == {index \in 1..Len(log[i]) :
// Agree(index) \in Quorum}
// \* New value for commitIndex'[i]
// newCommitIndex ==
// IF /\ agreeIndexes /= {}
// /\ log[i][Max(agreeIndexes)].term = currentTerm[i]
// THEN
// Max(agreeIndexes)
// ELSE
// commitIndex[i]
// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex]
// /\ UNCHANGED <<messages, serverVars, candidateVars, leaderVars, log>>
//
int32_t
raftLogupdateCommitIndex
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
return
0
;
}
int32_t
raftLogupdateCommitIndex
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
return
0
;
}
// truncate log with index, entries after the given index (>index) will be deleted
// truncate log with index, entries after the given index (>index) will be deleted
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录