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