Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c29401ed
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看板
提交
c29401ed
编写于
12月 07, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): re send snapshot in timer-routine
上级
b9447601
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
46 addition
and
23 deletion
+46
-23
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-0
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+1
-0
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+27
-21
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+15
-0
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+2
-2
未找到文件。
include/libs/sync/sync.h
浏览文件 @
c29401ed
...
...
@@ -47,6 +47,7 @@ extern "C" {
#define SYNC_HEARTBEAT_SLOW_MS 1500
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
#define SYNC_SNAP_RESEND_MS 1000 * 60
#define SYNC_MAX_BATCH_SIZE 1
#define SYNC_INDEX_BEGIN 0
...
...
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
c29401ed
...
...
@@ -44,6 +44,7 @@ typedef struct SSyncSnapshotSender {
SyncTerm
term
;
int64_t
startTime
;
int64_t
endTime
;
int64_t
lastSendTime
;
bool
finish
;
// init when create
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
c29401ed
...
...
@@ -103,6 +103,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) {
pSender
->
sendingMS
=
0
;
pSender
->
term
=
pSender
->
pSyncNode
->
pRaftStore
->
currentTerm
;
pSender
->
startTime
=
taosGetTimestampMs
();
pSender
->
lastSendTime
=
pSender
->
startTime
;
pSender
->
finish
=
false
;
// build begin msg
...
...
@@ -201,6 +202,8 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) {
syncNodeSendMsgById
(
&
pMsg
->
destId
,
pSender
->
pSyncNode
,
&
rpcMsg
);
syncLogSendSyncSnapshotSend
(
pSender
->
pSyncNode
,
pMsg
,
""
);
pSender
->
lastSendTime
=
taosGetTimestampMs
();
// event log
if
(
pSender
->
seq
==
SYNC_SNAPSHOT_SEQ_END
)
{
sSTrace
(
pSender
,
"snapshot sender finish"
);
...
...
@@ -213,7 +216,7 @@ int32_t snapshotSend(SSyncSnapshotSender *pSender) {
// send snapshot data from cache
int32_t
snapshotReSend
(
SSyncSnapshotSender
*
pSender
)
{
// send current block data
if
(
pSender
->
pCurrentBlock
!=
NULL
&&
pSender
->
blockLen
>
0
)
{
// build msg
SRpcMsg
rpcMsg
=
{
0
};
(
void
)
syncBuildSnapshotSend
(
&
rpcMsg
,
pSender
->
blockLen
,
pSender
->
pSyncNode
->
vgId
);
...
...
@@ -229,16 +232,19 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) {
pMsg
->
lastConfig
=
pSender
->
lastConfig
;
pMsg
->
seq
=
pSender
->
seq
;
if
(
pSender
->
pCurrentBlock
!=
NULL
&&
pSender
->
blockLen
>
0
)
{
// pMsg->privateTerm = pSender->privateTerm;
memcpy
(
pMsg
->
data
,
pSender
->
pCurrentBlock
,
pSender
->
blockLen
);
}
// send msg
syncNodeSendMsgById
(
&
pMsg
->
destId
,
pSender
->
pSyncNode
,
&
rpcMsg
);
syncLogSendSyncSnapshotSend
(
pSender
->
pSyncNode
,
pMsg
,
""
);
pSender
->
lastSendTime
=
taosGetTimestampMs
();
// event log
sSTrace
(
pSender
,
"snapshot sender resend"
);
}
return
0
;
}
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
c29401ed
...
...
@@ -20,6 +20,7 @@
#include "syncRaftLog.h"
#include "syncReplication.h"
#include "syncRespMgr.h"
#include "syncSnapshot.h"
#include "syncUtil.h"
static
void
syncNodeCleanConfigIndex
(
SSyncNode
*
ths
)
{
...
...
@@ -70,6 +71,20 @@ static int32_t syncNodeTimerRoutine(SSyncNode* ths) {
}
int64_t
timeNow
=
taosGetTimestampMs
();
for
(
int
i
=
0
;
i
<
ths
->
peersNum
;
++
i
)
{
SSyncSnapshotSender
*
pSender
=
syncNodeGetSnapshotSender
(
ths
,
&
(
ths
->
peersId
[
i
]));
if
(
pSender
!=
NULL
)
{
if
(
ths
->
isStart
&&
ths
->
state
==
TAOS_SYNC_STATE_LEADER
&&
pSender
->
start
&&
timeNow
-
pSender
->
lastSendTime
>
SYNC_SNAP_RESEND_MS
)
{
snapshotReSend
(
pSender
);
}
else
{
sTrace
(
"vgId:%d, do not resend: nstart%d, now:%"
PRId64
", lstsend:%"
PRId64
", diff:%"
PRId64
,
ths
->
vgId
,
ths
->
isStart
,
timeNow
,
pSender
->
lastSendTime
,
timeNow
-
pSender
->
lastSendTime
);
}
}
}
if
(
atomic_load_64
(
&
ths
->
snapshottingIndex
)
!=
SYNC_INDEX_INVALID
)
{
// end timeout wal snapshot
if
(
timeNow
-
ths
->
snapshottingTime
>
SYNC_DEL_WAL_MS
&&
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
c29401ed
...
...
@@ -568,7 +568,7 @@ void syncLogSendSyncSnapshotSend(SSyncNode* pSyncNode, const SyncSnapshotSend* p
syncUtilU642Addr
(
pMsg
->
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
sNTrace
(
pSyncNode
,
"send sync-snapshot-send
from
%s:%d {term:%"
PRId64
", begin:%"
PRId64
", end:%"
PRId64
", lterm:%"
PRId64
"send sync-snapshot-send
to
%s:%d {term:%"
PRId64
", begin:%"
PRId64
", end:%"
PRId64
", lterm:%"
PRId64
", stime:%"
PRId64
", seq:%d}, %s"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
beginIndex
,
pMsg
->
lastIndex
,
pMsg
->
lastTerm
,
pMsg
->
startTime
,
pMsg
->
seq
,
s
);
}
...
...
@@ -595,7 +595,7 @@ void syncLogSendSyncSnapshotRsp(SSyncNode* pSyncNode, const SyncSnapshotRsp* pMs
syncUtilU642Addr
(
pMsg
->
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
sNTrace
(
pSyncNode
,
"send sync-snapshot-rsp
from
%s:%d {term:%"
PRId64
", begin:%"
PRId64
", lst:%"
PRId64
", lterm:%"
PRId64
"send sync-snapshot-rsp
to
%s:%d {term:%"
PRId64
", begin:%"
PRId64
", lst:%"
PRId64
", lterm:%"
PRId64
", stime:%"
PRId64
", ack:%d}, %s"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
snapBeginIndex
,
pMsg
->
lastIndex
,
pMsg
->
lastTerm
,
pMsg
->
startTime
,
pMsg
->
ack
,
s
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录