Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
29456c06
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
29456c06
编写于
10月 26, 2022
作者:
H
Hui Li
提交者:
GitHub
10月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17649 from taosdata/feature/sync2-merge
refactor(sync): adjust elect timer
上级
61797504
7723a9ac
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
64 deletion
+67
-64
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+6
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+49
-58
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+1
-3
source/libs/sync/src/syncVoteMgr.c
source/libs/sync/src/syncVoteMgr.c
+11
-2
未找到文件。
source/libs/sync/inc/syncInt.h
浏览文件 @
29456c06
...
@@ -79,6 +79,12 @@ typedef struct SSyncTimer {
...
@@ -79,6 +79,12 @@ typedef struct SSyncTimer {
void
*
pData
;
void
*
pData
;
}
SSyncTimer
;
}
SSyncTimer
;
typedef
struct
SElectTimer
{
uint64_t
logicClock
;
SSyncNode
*
pSyncNode
;
void
*
pData
;
}
SElectTimer
;
int32_t
syncHbTimerInit
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
,
SRaftId
destId
);
int32_t
syncHbTimerInit
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
,
SRaftId
destId
);
int32_t
syncHbTimerStart
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
);
int32_t
syncHbTimerStart
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
);
int32_t
syncHbTimerStop
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
);
int32_t
syncHbTimerStop
(
SSyncNode
*
pSyncNode
,
SSyncTimer
*
pSyncTimer
);
...
@@ -155,7 +161,6 @@ typedef struct SSyncNode {
...
@@ -155,7 +161,6 @@ typedef struct SSyncNode {
tmr_h
pElectTimer
;
tmr_h
pElectTimer
;
int32_t
electTimerMS
;
int32_t
electTimerMS
;
uint64_t
electTimerLogicClock
;
uint64_t
electTimerLogicClock
;
uint64_t
electTimerLogicClockUser
;
TAOS_TMR_CALLBACK
FpElectTimerCB
;
// Timer Fp
TAOS_TMR_CALLBACK
FpElectTimerCB
;
// Timer Fp
uint64_t
electTimerCounter
;
uint64_t
electTimerCounter
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
29456c06
...
@@ -1310,7 +1310,6 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
...
@@ -1310,7 +1310,6 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
pSyncNode
->
pElectTimer
=
NULL
;
pSyncNode
->
pElectTimer
=
NULL
;
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClock
,
0
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClock
,
0
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClockUser
,
0
);
pSyncNode
->
FpElectTimerCB
=
syncNodeEqElectTimer
;
pSyncNode
->
FpElectTimerCB
=
syncNodeEqElectTimer
;
pSyncNode
->
electTimerCounter
=
0
;
pSyncNode
->
electTimerCounter
=
0
;
...
@@ -1565,17 +1564,14 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
...
@@ -1565,17 +1564,14 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
int32_t
ret
=
0
;
int32_t
ret
=
0
;
if
(
syncEnvIsStart
())
{
if
(
syncEnvIsStart
())
{
pSyncNode
->
electTimerMS
=
ms
;
pSyncNode
->
electTimerMS
=
ms
;
taosTmrReset
(
pSyncNode
->
FpElectTimerCB
,
pSyncNode
->
electTimerMS
,
pSyncNode
,
gSyncEnv
->
pTimerManager
,
&
pSyncNode
->
pElectTimer
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
);
/*
SElectTimer
*
pElectTimer
=
taosMemoryMalloc
(
sizeof
(
SElectTimer
));
do {
pElectTimer
->
logicClock
=
pSyncNode
->
electTimerLogicClock
;
char logBuf[128]
;
pElectTimer
->
pSyncNode
=
pSyncNode
;
snprintf(logBuf, sizeof(logBuf), "elect timer reset, ms:%d", ms)
;
pElectTimer
->
pData
=
NULL
;
syncNodeEventLog(pSyncNode, logBuf);
} while (0);
taosTmrReset
(
pSyncNode
->
FpElectTimerCB
,
pSyncNode
->
electTimerMS
,
pElectTimer
,
gSyncEnv
->
pTimerManager
,
*/
&
pSyncNode
->
pElectTimer
);
}
else
{
}
else
{
sError
(
"vgId:%d, start elect timer error, sync env is stop"
,
pSyncNode
->
vgId
);
sError
(
"vgId:%d, start elect timer error, sync env is stop"
,
pSyncNode
->
vgId
);
...
@@ -1585,11 +1581,10 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
...
@@ -1585,11 +1581,10 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
int32_t
syncNodeStopElectTimer
(
SSyncNode
*
pSyncNode
)
{
int32_t
syncNodeStopElectTimer
(
SSyncNode
*
pSyncNode
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
atomic_add_fetch_64
(
&
pSyncNode
->
electTimerLogicClock
User
,
1
);
atomic_add_fetch_64
(
&
pSyncNode
->
electTimerLogicClock
,
1
);
taosTmrStop
(
pSyncNode
->
pElectTimer
);
taosTmrStop
(
pSyncNode
->
pElectTimer
);
pSyncNode
->
pElectTimer
=
NULL
;
pSyncNode
->
pElectTimer
=
NULL
;
// sTrace("vgId:%d, sync %s stop elect timer", pSyncNode->vgId, syncUtilState2String(pSyncNode->state));
return
ret
;
return
ret
;
}
}
...
@@ -1815,8 +1810,6 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
...
@@ -1815,8 +1810,6 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
cJSON_AddNumberToObject
(
pRoot
,
"electTimerMS"
,
pSyncNode
->
electTimerMS
);
cJSON_AddNumberToObject
(
pRoot
,
"electTimerMS"
,
pSyncNode
->
electTimerMS
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pSyncNode
->
electTimerLogicClock
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pSyncNode
->
electTimerLogicClock
);
cJSON_AddStringToObject
(
pRoot
,
"electTimerLogicClock"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"electTimerLogicClock"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pSyncNode
->
electTimerLogicClockUser
);
cJSON_AddStringToObject
(
pRoot
,
"electTimerLogicClockUser"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
FpElectTimerCB
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
FpElectTimerCB
);
cJSON_AddStringToObject
(
pRoot
,
"FpElectTimerCB"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"FpElectTimerCB"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pSyncNode
->
electTimerCounter
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pSyncNode
->
electTimerCounter
);
...
@@ -1922,7 +1915,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1922,7 +1915,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
electTimerLogicClock
User
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
peerStateStr
,
printStr
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
peerStateStr
,
printStr
);
}
else
{
}
else
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
}
}
...
@@ -1946,7 +1939,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1946,7 +1939,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
electTimerLogicClock
User
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
peerStateStr
,
printStr
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
peerStateStr
,
printStr
);
}
else
{
}
else
{
snprintf
(
s
,
len
,
"%s"
,
str
);
snprintf
(
s
,
len
,
"%s"
,
str
);
}
}
...
@@ -2000,7 +1993,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -2000,7 +1993,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
electTimerLogicClock
User
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
printStr
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
printStr
);
}
else
{
}
else
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
}
}
...
@@ -2022,7 +2015,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -2022,7 +2015,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
syncNodeDynamicQuorum
(
pSyncNode
),
pSyncNode
->
electTimerLogicClock
User
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
printStr
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
heartbeatTimerLogicClockUser
,
printStr
);
}
else
{
}
else
{
snprintf
(
s
,
len
,
"%s"
,
str
);
snprintf
(
s
,
len
,
"%s"
,
str
);
}
}
...
@@ -2789,38 +2782,46 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
...
@@ -2789,38 +2782,46 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
}
}
static
void
syncNodeEqElectTimer
(
void
*
param
,
void
*
tmrId
)
{
static
void
syncNodeEqElectTimer
(
void
*
param
,
void
*
tmrId
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
param
;
SElectTimer
*
pElectTimer
=
(
SElectTimer
*
)
param
;
if
(
atomic_load_64
(
&
pSyncNode
->
electTimerLogicClockUser
)
<=
atomic_load_64
(
&
pSyncNode
->
electTimerLogicClock
))
{
SSyncNode
*
pSyncNode
=
pElectTimer
->
pSyncNode
;
SyncTimeout
*
pSyncMsg
=
syncTimeoutBuild2
(
SYNC_TIMEOUT_ELECTION
,
atomic_load_64
(
&
pSyncNode
->
electTimerLogicClock
),
pSyncNode
->
electTimerMS
,
pSyncNode
->
vgId
,
pSyncNode
);
SyncTimeout
*
pSyncMsg
=
syncTimeoutBuild2
(
SYNC_TIMEOUT_ELECTION
,
pElectTimer
->
logicClock
,
pSyncNode
->
electTimerMS
,
SRpcMsg
rpcMsg
;
pSyncNode
->
vgId
,
pSyncNode
);
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
SRpcMsg
rpcMsg
;
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqElectTimer=="
,
&
rpcMsg
);
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
if
(
pSyncNode
->
FpEqMsg
!=
NULL
)
{
if
(
pSyncNode
->
FpEqMsg
!=
NULL
)
{
int32_t
code
=
pSyncNode
->
FpEqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
int32_t
code
=
pSyncNode
->
FpEqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, sync enqueue elect msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
sError
(
"vgId:%d, sync enqueue elect msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
syncTimeoutDestroy
(
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
return
;
taosMemoryFree
(
pElectTimer
);
}
return
;
}
else
{
sTrace
(
"syncNodeEqElectTimer FpEqMsg is NULL"
);
}
}
syncTimeoutDestroy
(
pSyncMsg
);
// reset timer ms
do
{
if
(
syncEnvIsStart
()
&&
pSyncNode
->
electBaseLine
>
0
)
{
char
logBuf
[
128
];
pSyncNode
->
electTimerMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"eq elect timer lc:%"
PRIu64
,
pSyncMsg
->
logicClock
);
taosTmrReset
(
syncNodeEqElectTimer
,
pSyncNode
->
electTimerMS
,
pSyncNode
,
gSyncEnv
->
pTimerManager
,
syncNodeEventLog
(
pSyncNode
,
logBuf
);
&
pSyncNode
->
pElectTimer
);
}
while
(
0
);
}
else
{
sError
(
"sync env is stop, syncNodeEqElectTimer"
);
}
else
{
}
sTrace
(
"syncNodeEqElectTimer FpEqMsg is NULL"
);
}
syncTimeoutDestroy
(
pSyncMsg
);
taosMemoryFree
(
pElectTimer
);
#if 0
// reset timer ms
if (syncEnvIsStart() && pSyncNode->electBaseLine > 0) {
pSyncNode->electTimerMS = syncUtilElectRandomMS(pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine);
taosTmrReset(syncNodeEqElectTimer, pSyncNode->electTimerMS, pSyncNode, gSyncEnv->pTimerManager,
&pSyncNode->pElectTimer);
} else {
} else {
sTrace
(
"==syncNodeEqElectTimer== electTimerLogicClock:%"
PRIu64
", electTimerLogicClockUser:%"
PRIu64
,
sError("sync env is stop, syncNodeEqElectTimer");
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
);
}
}
#endif
}
}
static
void
syncNodeEqHeartbeatTimer
(
void
*
param
,
void
*
tmrId
)
{
static
void
syncNodeEqHeartbeatTimer
(
void
*
param
,
void
*
tmrId
)
{
...
@@ -3000,16 +3001,6 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
...
@@ -3000,16 +3001,6 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
// on message ----
// on message ----
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
)
{
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
)
{
// log state
// log state
char
logBuf
[
1024
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%"
PRIu64
" electTimerLogicClock:%"
PRIu64
", "
"electTimerLogicClockUser:%"
PRIu64
", electTimerMS:%d"
,
ths
->
vgId
,
ths
->
state
,
syncUtilState2String
(
ths
->
state
),
ths
->
pRaftStore
->
currentTerm
,
ths
->
electTimerLogicClock
,
ths
->
electTimerLogicClockUser
,
ths
->
electTimerMS
);
int32_t
ret
=
0
;
syncPingLog2
(
logBuf
,
pMsg
);
SyncPingReply
*
pMsgReply
=
syncPingReplyBuild3
(
&
ths
->
myRaftId
,
&
pMsg
->
srcId
,
ths
->
vgId
);
SyncPingReply
*
pMsgReply
=
syncPingReplyBuild3
(
&
ths
->
myRaftId
,
&
pMsg
->
srcId
,
ths
->
vgId
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncPingReply2RpcMsg
(
pMsgReply
,
&
rpcMsg
);
syncPingReply2RpcMsg
(
pMsgReply
,
&
rpcMsg
);
...
@@ -3024,7 +3015,7 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
...
@@ -3024,7 +3015,7 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
syncNodeSendMsgById
(
&
pMsgReply
->
destId
,
ths
,
&
rpcMsg
);
syncNodeSendMsgById
(
&
pMsgReply
->
destId
,
ths
,
&
rpcMsg
);
syncPingReplyDestroy
(
pMsgReply
);
syncPingReplyDestroy
(
pMsgReply
);
return
ret
;
return
0
;
}
}
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
)
{
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
)
{
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
29456c06
...
@@ -113,10 +113,8 @@ int32_t syncNodeOnTimer(SSyncNode* ths, SyncTimeout* pMsg) {
...
@@ -113,10 +113,8 @@ int32_t syncNodeOnTimer(SSyncNode* ths, SyncTimeout* pMsg) {
}
}
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_ELECTION
)
{
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_ELECTION
)
{
if
(
atomic_load_64
(
&
ths
->
electTimerLogicClock
User
)
<=
pMsg
->
logicClock
)
{
if
(
atomic_load_64
(
&
ths
->
electTimerLogicClock
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
electTimerCounter
);
++
(
ths
->
electTimerCounter
);
sTrace
(
"vgId:%d, sync timer, type:election count:%"
PRIu64
", lc-user:%"
PRIu64
,
ths
->
vgId
,
ths
->
electTimerCounter
,
ths
->
electTimerLogicClockUser
);
syncNodeElect
(
ths
);
syncNodeElect
(
ths
);
}
}
...
...
source/libs/sync/src/syncVoteMgr.c
浏览文件 @
29456c06
...
@@ -66,7 +66,12 @@ bool voteGrantedMajority(SVotesGranted *pVotesGranted) {
...
@@ -66,7 +66,12 @@ bool voteGrantedMajority(SVotesGranted *pVotesGranted) {
void
voteGrantedVote
(
SVotesGranted
*
pVotesGranted
,
SyncRequestVoteReply
*
pMsg
)
{
void
voteGrantedVote
(
SVotesGranted
*
pVotesGranted
,
SyncRequestVoteReply
*
pMsg
)
{
ASSERT
(
pMsg
->
voteGranted
==
true
);
ASSERT
(
pMsg
->
voteGranted
==
true
);
ASSERT
(
pMsg
->
term
==
pVotesGranted
->
term
);
if
(
pMsg
->
term
!=
pVotesGranted
->
term
)
{
syncNodeEventLog
(
pVotesGranted
->
pSyncNode
,
"vote grant vnode error"
);
return
;
}
ASSERT
(
syncUtilSameId
(
&
pVotesGranted
->
pSyncNode
->
myRaftId
,
&
pMsg
->
destId
));
ASSERT
(
syncUtilSameId
(
&
pVotesGranted
->
pSyncNode
->
myRaftId
,
&
pMsg
->
destId
));
int
j
=
-
1
;
int
j
=
-
1
;
...
@@ -201,7 +206,11 @@ bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId) {
...
@@ -201,7 +206,11 @@ bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId) {
}
}
void
votesRespondAdd
(
SVotesRespond
*
pVotesRespond
,
const
SyncRequestVoteReply
*
pMsg
)
{
void
votesRespondAdd
(
SVotesRespond
*
pVotesRespond
,
const
SyncRequestVoteReply
*
pMsg
)
{
ASSERT
(
pVotesRespond
->
term
==
pMsg
->
term
);
if
(
pVotesRespond
->
term
!=
pMsg
->
term
)
{
syncNodeEventLog
(
pVotesRespond
->
pSyncNode
,
"vote respond add error"
);
return
;
}
for
(
int
i
=
0
;
i
<
pVotesRespond
->
replicaNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pVotesRespond
->
replicaNum
;
++
i
)
{
if
(
syncUtilSameId
(
&
((
*
(
pVotesRespond
->
replicas
))[
i
]),
&
pMsg
->
srcId
))
{
if
(
syncUtilSameId
(
&
((
*
(
pVotesRespond
->
replicas
))[
i
]),
&
pMsg
->
srcId
))
{
// ASSERT(pVotesRespond->isRespond[i] == false);
// ASSERT(pVotesRespond->isRespond[i] == false);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录