Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
991d6fd8
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看板
提交
991d6fd8
编写于
7月 19, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): add trace log
上级
329ba3ce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
15 deletion
+56
-15
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+16
-12
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+39
-2
未找到文件。
source/libs/sync/src/syncElection.c
浏览文件 @
991d6fd8
...
@@ -125,7 +125,7 @@ int32_t syncNodeRequestVote(SSyncNode* pSyncNode, const SRaftId* destRaftId, con
...
@@ -125,7 +125,7 @@ int32_t syncNodeRequestVote(SSyncNode* pSyncNode, const SRaftId* destRaftId, con
syncUtilU642Addr
(
destRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
destRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
sDebug
(
"vgId:%d, send sync-request-vote to %s:%d, {term:%"
PRIu64
", last-index:%"
PRId64
", last-term:%"
PRIu64
sDebug
(
"vgId:%d, send sync-request-vote to %s:%d, {term:%"
PRIu64
", last-index:%"
PRId64
", last-term:%"
PRIu64
"}"
,
"}"
,
pSyncNode
->
vgId
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLog
Term
,
pMsg
->
lastLogIndex
);
pSyncNode
->
vgId
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLog
Index
,
pMsg
->
lastLogTerm
);
}
while
(
0
);
}
while
(
0
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
991d6fd8
...
@@ -1539,13 +1539,13 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1539,13 +1539,13 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
", snapshot:%"
PRId64
", snapshot:%"
PRId64
", snapshot-term:%"
PRIu64
", standby:%d, "
", standby:%d, "
"strategy:%d, batch:%d, "
"strategy:%d, batch:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
printStr
);
pSyncNode
->
restoreFinish
,
printStr
);
...
@@ -1561,13 +1561,13 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1561,13 +1561,13 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
", snapshot:%"
PRId64
", snapshot:%"
PRId64
", snapshot-term:%"
PRIu64
", standby:%d, "
", standby:%d, "
"strategy:%d, batch:%d, "
"strategy:%d, batch:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
printStr
);
pSyncNode
->
restoreFinish
,
printStr
);
...
@@ -1608,14 +1608,16 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1608,14 +1608,16 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
", snapshot:%"
PRId64
", snapshot:%"
PRId64
", snapshot-term:%"
PRIu64
", standby:%d, "
", standby:%d, "
"strategy:%d, batch:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
printStr
);
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
printStr
);
}
else
{
}
else
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"%s"
,
str
);
}
}
...
@@ -1627,14 +1629,16 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1627,14 +1629,16 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", first:%"
PRId64
", last:%"
PRId64
", snapshot:%"
PRId64
", snapshot:%"
PRId64
", snapshot-term:%"
PRIu64
", standby:%d, "
", standby:%d, "
"strategy:%d, batch:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
printStr
);
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
,
printStr
);
}
else
{
}
else
{
snprintf
(
s
,
len
,
"%s"
,
str
);
snprintf
(
s
,
len
,
"%s"
,
str
);
}
}
...
...
source/libs/sync/src/syncRequestVote.c
浏览文件 @
991d6fd8
...
@@ -159,16 +159,53 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* pSyncNode, SyncRequestVote* pM
...
@@ -159,16 +159,53 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* pSyncNode, SyncRequestVote* pM
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
if
(
myLastTerm
==
SYNC_TERM_INVALID
)
{
if
(
myLastTerm
==
SYNC_TERM_INVALID
)
{
do
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"logok:0, {my-lterm:%"
PRIu64
", my-lindex:%"
PRId64
", recv-lterm:%"
PRIu64
", recv-lindex:%"
PRId64
", recv-term:%"
PRIu64
"}"
,
myLastTerm
,
myLastIndex
,
pMsg
->
lastLogTerm
,
pMsg
->
lastLogIndex
,
pMsg
->
term
);
syncNodeEventLog
(
pSyncNode
,
logBuf
);
}
while
(
0
);
return
false
;
return
false
;
}
}
if
(
pMsg
->
lastLogTerm
>
myLastTerm
)
{
if
(
pMsg
->
lastLogTerm
>
myLastTerm
)
{
do
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"logok:1, {my-lterm:%"
PRIu64
", my-lindex:%"
PRId64
", recv-lterm:%"
PRIu64
", recv-lindex:%"
PRId64
", recv-term:%"
PRIu64
"}"
,
myLastTerm
,
myLastIndex
,
pMsg
->
lastLogTerm
,
pMsg
->
lastLogIndex
,
pMsg
->
term
);
syncNodeEventLog
(
pSyncNode
,
logBuf
);
}
while
(
0
);
return
true
;
return
true
;
}
}
if
(
pMsg
->
lastLogTerm
==
myLastTerm
&&
pMsg
->
lastLogIndex
>=
myLastIndex
)
{
if
(
pMsg
->
lastLogTerm
==
myLastTerm
&&
pMsg
->
lastLogIndex
>=
myLastIndex
)
{
do
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"logok:1, {my-lterm:%"
PRIu64
", my-lindex:%"
PRId64
", recv-lterm:%"
PRIu64
", recv-lindex:%"
PRId64
", recv-term:%"
PRIu64
"}"
,
myLastTerm
,
myLastIndex
,
pMsg
->
lastLogTerm
,
pMsg
->
lastLogIndex
,
pMsg
->
term
);
syncNodeEventLog
(
pSyncNode
,
logBuf
);
}
while
(
0
);
return
true
;
return
true
;
}
}
do
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"logok:0, {my-lterm:%"
PRIu64
", my-lindex:%"
PRId64
", recv-lterm:%"
PRIu64
", recv-lindex:%"
PRId64
", recv-term:%"
PRIu64
"}"
,
myLastTerm
,
myLastIndex
,
pMsg
->
lastLogTerm
,
pMsg
->
lastLogIndex
,
pMsg
->
term
);
syncNodeEventLog
(
pSyncNode
,
logBuf
);
}
while
(
0
);
return
false
;
return
false
;
}
}
...
@@ -224,8 +261,8 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
...
@@ -224,8 +261,8 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
"recv sync-request-vote from %s:%d,
{
term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", reply-grant:%d"
,
", reply-grant:%d
}
"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
,
pReply
->
voteGranted
);
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
,
pReply
->
voteGranted
);
syncNodeEventLog
(
ths
,
logBuf
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
while
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录