Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
96f9274f
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看板
提交
96f9274f
编写于
7月 12, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): add timer routines
上级
37ebcdea
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
26 deletion
+21
-26
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-0
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-1
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+8
-22
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+10
-2
未找到文件。
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
96f9274f
...
...
@@ -199,6 +199,7 @@ int32_t mndInitSync(SMnode *pMnode) {
}
// decrease election timer
setPingTimerMS
(
pMgmt
->
sync
,
5000
);
setElectTimerMS
(
pMgmt
->
sync
,
600
);
setHeartbeatTimerMS
(
pMgmt
->
sync
,
300
);
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
96f9274f
...
...
@@ -569,7 +569,7 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
return
-
1
;
}
setPingTimerMS
(
pVnode
->
sync
,
3
000
);
setPingTimerMS
(
pVnode
->
sync
,
5
000
);
setElectTimerMS
(
pVnode
->
sync
,
500
);
setHeartbeatTimerMS
(
pVnode
->
sync
,
100
);
return
0
;
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
96f9274f
...
...
@@ -30,7 +30,7 @@ extern "C" {
#define TIMER_MAX_MS 0x7FFFFFFF
#define ENV_TICK_TIMER_MS 1000
#define PING_TIMER_MS
1
000
#define PING_TIMER_MS
5
000
#define ELECT_TIMER_MS_MIN 1300
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
96f9274f
...
...
@@ -1099,19 +1099,13 @@ void syncNodeStart(SSyncNode* pSyncNode) {
// Raft 3.6.2 Committing entries from previous terms
syncNodeAppendNoop
(
pSyncNode
);
syncMaybeAdvanceCommitIndex
(
pSyncNode
);
return
;
}
else
{
syncNodeBecomeFollower
(
pSyncNode
,
"first start"
)
;
}
syncNodeBecomeFollower
(
pSyncNode
,
"first start"
);
// int32_t ret = 0;
// ret = syncNodeStartPingTimer(pSyncNode);
// ASSERT(ret == 0);
if
(
gRaftDetailLog
)
{
syncNodeLog2
(
"==state change become leader immediately=="
,
pSyncNode
);
}
int32_t
ret
=
0
;
ret
=
syncNodeStartPingTimer
(
pSyncNode
);
ASSERT
(
ret
==
0
);
}
void
syncNodeStartStandBy
(
SSyncNode
*
pSyncNode
)
{
...
...
@@ -1162,14 +1156,6 @@ void syncNodeClose(SSyncNode* pSyncNode) {
pSyncNode
->
pNewNodeReceiver
=
NULL
;
}
/*
if (pSyncNode->pSnapshot != NULL) {
taosMemoryFree(pSyncNode->pSnapshot);
}
*/
// tsem_destroy(&pSyncNode->restoreSem);
// free memory in syncFreeNode
// taosMemoryFree(pSyncNode);
}
...
...
@@ -1234,7 +1220,7 @@ int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) {
&
pSyncNode
->
pPingTimer
);
atomic_store_64
(
&
pSyncNode
->
pingTimerLogicClock
,
pSyncNode
->
pingTimerLogicClockUser
);
}
else
{
sError
(
"
sync env is stop, syncNodeStartPingTimer"
);
sError
(
"
vgId:%d, start ping timer error, sync env is stop"
,
pSyncNode
->
vgId
);
}
return
ret
;
}
...
...
@@ -1255,7 +1241,7 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
&
pSyncNode
->
pElectTimer
);
atomic_store_64
(
&
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
);
}
else
{
sError
(
"
sync env is stop, syncNodeStartElectTimer"
);
sError
(
"
vgId:%d, start elect timer error, sync env is stop"
,
pSyncNode
->
vgId
);
}
return
ret
;
}
...
...
@@ -1295,7 +1281,7 @@ int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) {
&
pSyncNode
->
pHeartbeatTimer
);
atomic_store_64
(
&
pSyncNode
->
heartbeatTimerLogicClock
,
pSyncNode
->
heartbeatTimerLogicClockUser
);
}
else
{
sError
(
"
sync env is stop, syncNodeStartHeartbeatTimer"
);
sError
(
"
vgId:%d, start heartbeat timer error, sync env is stop"
,
pSyncNode
->
vgId
);
}
return
ret
;
}
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
96f9274f
...
...
@@ -17,6 +17,11 @@
#include "syncElection.h"
#include "syncReplication.h"
int32_t
syncNodeTimerRoutine
(
SSyncNode
*
ths
)
{
syncNodeEventLog
(
ths
,
"timer routines ... "
);
return
0
;
}
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
)
{
int32_t
ret
=
0
;
syncTimeoutLog2
(
"==syncNodeOnTimeoutCb=="
,
pMsg
);
...
...
@@ -24,8 +29,11 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_PING
)
{
if
(
atomic_load_64
(
&
ths
->
pingTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
pingTimerCounter
);
// syncNodePingAll(ths);
syncNodePingPeers
(
ths
);
// syncNodePingPeers(ths);
syncNodeTimerRoutine
(
ths
);
}
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_ELECTION
)
{
...
...
@@ -40,7 +48,7 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
syncNodeReplicate
(
ths
);
}
}
else
{
s
Trace
(
"unknown timeoutType:%d"
,
pMsg
->
timeoutType
);
s
Error
(
"vgId:%d, unknown timeout-type:%d"
,
ths
->
vgId
,
pMsg
->
timeoutType
);
}
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录