Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b67e27bb
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看板
未验证
提交
b67e27bb
编写于
11月 14, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18119 from taosdata/fix/TD-20372
fix(sync): fix AddressSanitizer error: TD-20372
上级
bb4c2ddc
9b58176c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
44 deletion
+28
-44
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+0
-37
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-1
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+11
-2
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+16
-4
未找到文件。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
b67e27bb
...
...
@@ -37,43 +37,6 @@
// /\ UNCHANGED <<serverVars, candidateVars, logVars, elections>>
//
// only start once
static
void
syncNodeStartSnapshotOnce
(
SSyncNode
*
ths
,
SyncIndex
beginIndex
,
SyncIndex
endIndex
,
SyncTerm
lastApplyTerm
,
SyncAppendEntriesReply
*
pMsg
)
{
if
(
beginIndex
>
endIndex
)
{
sNError
(
ths
,
"snapshot param error, start:%"
PRId64
", end:%"
PRId64
,
beginIndex
,
endIndex
);
return
;
}
// get sender
SSyncSnapshotSender
*
pSender
=
syncNodeGetSnapshotSender
(
ths
,
&
(
pMsg
->
srcId
));
ASSERT
(
pSender
!=
NULL
);
if
(
snapshotSenderIsStart
(
pSender
))
{
sSError
(
pSender
,
"snapshot sender already start"
);
return
;
}
SSnapshot
snapshot
=
{
.
data
=
NULL
,
.
lastApplyIndex
=
endIndex
,
.
lastApplyTerm
=
lastApplyTerm
,
.
lastConfigIndex
=
SYNC_INDEX_INVALID
};
void
*
pReader
=
NULL
;
SSnapshotParam
readerParam
=
{.
start
=
beginIndex
,
.
end
=
endIndex
};
int32_t
code
=
ths
->
pFsm
->
FpSnapshotStartRead
(
ths
->
pFsm
,
&
readerParam
,
&
pReader
);
ASSERT
(
code
==
0
);
#if 0
if (pMsg->privateTerm < pSender->privateTerm) {
ASSERT(pReader != NULL);
snapshotSenderStart(pSender, readerParam, snapshot, pReader);
} else {
if (pReader != NULL) {
ths->pFsm->FpSnapshotStopRead(ths->pFsm, pReader);
}
}
#endif
}
int32_t
syncNodeOnAppendEntriesReply
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
SyncAppendEntriesReply
*
pMsg
=
pRpcMsg
->
pCont
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
b67e27bb
...
...
@@ -385,7 +385,7 @@ bool syncIsReadyForRead(int64_t rid) {
if
(
!
pSyncNode
->
pLogStore
->
syncLogIsEmpty
(
pSyncNode
->
pLogStore
))
{
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
),
&
pEntry
);
pSyncNode
->
pLogStore
,
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
),
&
pEntry
);
if
(
code
==
0
&&
pEntry
!=
NULL
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_NOOP
&&
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
ready
=
true
;
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
b67e27bb
...
...
@@ -197,7 +197,12 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
syncMeta
.
isWeek
=
pEntry
->
isWeak
;
syncMeta
.
seqNum
=
pEntry
->
seqNum
;
syncMeta
.
term
=
pEntry
->
term
;
int64_t
tsWriteBegin
=
taosGetTimestampMs
();
index
=
walAppendLog
(
pWal
,
pEntry
->
originalRpcType
,
syncMeta
,
pEntry
->
data
,
pEntry
->
dataLen
);
int64_t
tsWriteEnd
=
taosGetTimestampMs
();
int64_t
tsElapsed
=
tsWriteEnd
-
tsWriteBegin
;
if
(
index
<
0
)
{
int32_t
err
=
terrno
;
const
char
*
errStr
=
tstrerror
(
err
);
...
...
@@ -210,8 +215,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
}
pEntry
->
index
=
index
;
sNTrace
(
pData
->
pSyncNode
,
"write index:%"
PRId64
", type:%s, origin type:%s
"
,
pEntry
->
index
,
TMSG_INFO
(
pEntry
->
msgType
),
TMSG_INFO
(
pEntry
->
originalRpcType
));
sNTrace
(
pData
->
pSyncNode
,
"write index:%"
PRId64
", type:%s, origin type:%s
, elapsed:%"
PRId64
,
pEntry
->
index
,
TMSG_INFO
(
pEntry
->
msgType
),
TMSG_INFO
(
pEntry
->
originalRpcType
)
,
tsElapsed
);
return
0
;
}
...
...
@@ -236,7 +241,11 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
taosThreadMutexLock
(
&
(
pData
->
mutex
));
int64_t
tsBegin
=
taosGetTimestampMs
();
code
=
walReadVer
(
pWalHandle
,
index
);
int64_t
tsEnd
=
taosGetTimestampMs
();
int64_t
tsElapsed
=
tsEnd
-
tsBegin
;
// code = walReadVerCached(pWalHandle, index);
if
(
code
!=
0
)
{
int32_t
err
=
terrno
;
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
b67e27bb
...
...
@@ -140,9 +140,10 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) {
int32_t
syncNodeSendAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
SyncAppendEntries
*
pMsg
=
pRpcMsg
->
pCont
;
syncLogSendAppendEntries
(
pSyncNode
,
pMsg
,
""
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
pRpcMsg
);
if
(
pMsg
==
NULL
)
{
sError
(
"vgId:%d, sync-append-entries msg is NULL"
,
pSyncNode
->
vgId
);
return
0
;
}
SPeerState
*
pState
=
syncNodeGetPeerState
(
pSyncNode
,
destRaftId
);
if
(
pState
==
NULL
)
{
...
...
@@ -150,8 +151,19 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI
return
0
;
}
// save index, otherwise pMsg will be free by rpc
SyncIndex
saveLastSendIndex
=
pState
->
lastSendIndex
;
bool
update
=
false
;
if
(
pMsg
->
dataLen
>
0
)
{
pState
->
lastSendIndex
=
pMsg
->
prevLogIndex
+
1
;
saveLastSendIndex
=
pMsg
->
prevLogIndex
+
1
;
update
=
true
;
}
syncLogSendAppendEntries
(
pSyncNode
,
pMsg
,
""
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
pRpcMsg
);
if
(
update
)
{
pState
->
lastSendIndex
=
saveLastSendIndex
;
pState
->
lastSendTime
=
taosGetTimestampMs
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录