Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d81f5e9f
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看板
提交
d81f5e9f
编写于
6月 09, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(sync): add detail log flag
上级
89e2c2d4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
95 addition
and
56 deletion
+95
-56
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+18
-9
source/libs/sync/src/syncIndexMgr.c
source/libs/sync/src/syncIndexMgr.c
+6
-4
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+6
-4
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+60
-36
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+5
-3
未找到文件。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
d81f5e9f
...
...
@@ -497,30 +497,39 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
// prevLogIndex == -1
static
bool
syncNodeOnAppendEntriesLogOK
(
SSyncNode
*
pSyncNode
,
SyncAppendEntries
*
pMsg
)
{
if
(
pMsg
->
prevLogIndex
==
SYNC_INDEX_INVALID
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld"
,
pMsg
->
prevLogIndex
);
if
(
gRaftDetailLog
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld"
,
pMsg
->
prevLogIndex
);
}
return
true
;
}
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
if
(
pMsg
->
prevLogIndex
>
myLastIndex
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld"
,
pMsg
->
prevLogIndex
,
myLastIndex
);
if
(
gRaftDetailLog
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld"
,
pMsg
->
prevLogIndex
,
myLastIndex
);
}
return
false
;
}
SyncTerm
myPreLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
pMsg
->
prevLogIndex
+
1
);
if
(
pMsg
->
prevLogIndex
<=
myLastIndex
&&
pMsg
->
prevLogTerm
==
myPreLogTerm
)
{
if
(
gRaftDetailLog
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK true, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
"myPreLogTerm:%lu"
,
pMsg
->
prevLogIndex
,
myLastIndex
,
pMsg
->
prevLogTerm
,
myPreLogTerm
);
}
return
true
;
}
if
(
gRaftDetailLog
)
{
sTrace
(
"syncNodeOnAppendEntriesLogOK
tru
e, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
"syncNodeOnAppendEntriesLogOK
fals
e, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
"myPreLogTerm:%lu"
,
pMsg
->
prevLogIndex
,
myLastIndex
,
pMsg
->
prevLogTerm
,
myPreLogTerm
);
return
true
;
}
sTrace
(
"syncNodeOnAppendEntriesLogOK false, pMsg->prevLogIndex:%ld, myLastIndex:%ld, pMsg->prevLogTerm:%lu, "
"myPreLogTerm:%lu"
,
pMsg
->
prevLogIndex
,
myLastIndex
,
pMsg
->
prevLogTerm
,
myPreLogTerm
);
return
false
;
}
...
...
source/libs/sync/src/syncIndexMgr.c
浏览文件 @
d81f5e9f
...
...
@@ -119,7 +119,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) {
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
cJSON
*
pJson
=
syncIndexMgr2Json
(
pSyncIndexMgr
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
...
...
@@ -146,9 +146,11 @@ void syncIndexMgrLog(SSyncIndexMgr *pObj) {
}
void
syncIndexMgrLog2
(
char
*
s
,
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
sTrace
(
"syncIndexMgrLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
sTrace
(
"syncIndexMgrLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
void
syncIndexMgrSetTerm
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
SyncTerm
term
)
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
d81f5e9f
...
...
@@ -852,10 +852,12 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp
SEpSet
epSet
;
syncUtilraftId2EpSet
(
destRaftId
,
&
epSet
);
if
(
pSyncNode
->
FpSendMsg
!=
NULL
)
{
char
*
JsonStr
=
syncRpcMsg2Str
(
pMsg
);
syncUtilJson2Line
(
JsonStr
);
sTrace
(
"sync send msg, vgId:%d, type:%d, msg:%s"
,
pSyncNode
->
vgId
,
pMsg
->
msgType
,
JsonStr
);
taosMemoryFree
(
JsonStr
);
if
(
gRaftDetailLog
)
{
char
*
JsonStr
=
syncRpcMsg2Str
(
pMsg
);
syncUtilJson2Line
(
JsonStr
);
sTrace
(
"sync send msg, vgId:%d, type:%d, msg:%s"
,
pSyncNode
->
vgId
,
pMsg
->
msgType
,
JsonStr
);
taosMemoryFree
(
JsonStr
);
}
// htonl
syncUtilMsgHtoN
(
pMsg
->
pCont
);
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
d81f5e9f
...
...
@@ -145,9 +145,11 @@ void syncRpcMsgLog(SRpcMsg* pMsg) {
}
void
syncRpcMsgLog2
(
char
*
s
,
SRpcMsg
*
pMsg
)
{
char
*
serialized
=
syncRpcMsg2Str
(
pMsg
);
sTrace
(
"syncRpcMsgLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncRpcMsg2Str
(
pMsg
);
sTrace
(
"syncRpcMsgLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncTimeout----
...
...
@@ -274,9 +276,11 @@ void syncTimeoutLog(const SyncTimeout* pMsg) {
}
void
syncTimeoutLog2
(
char
*
s
,
const
SyncTimeout
*
pMsg
)
{
char
*
serialized
=
syncTimeout2Str
(
pMsg
);
sTrace
(
"syncTimeoutLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncTimeout2Str
(
pMsg
);
sTrace
(
"syncTimeoutLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncPing----
...
...
@@ -534,9 +538,11 @@ void syncPingLog(const SyncPing* pMsg) {
}
void
syncPingLog2
(
char
*
s
,
const
SyncPing
*
pMsg
)
{
char
*
serialized
=
syncPing2Str
(
pMsg
);
sTrace
(
"syncPingLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncPing2Str
(
pMsg
);
sTrace
(
"syncPingLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncPingReply----
...
...
@@ -794,9 +800,11 @@ void syncPingReplyLog(const SyncPingReply* pMsg) {
}
void
syncPingReplyLog2
(
char
*
s
,
const
SyncPingReply
*
pMsg
)
{
char
*
serialized
=
syncPingReply2Str
(
pMsg
);
sTrace
(
"syncPingReplyLog2 | len:%zu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncPingReply2Str
(
pMsg
);
sTrace
(
"syncPingReplyLog2 | len:%zu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncClientRequest----
...
...
@@ -935,9 +943,11 @@ void syncClientRequestLog(const SyncClientRequest* pMsg) {
}
void
syncClientRequestLog2
(
char
*
s
,
const
SyncClientRequest
*
pMsg
)
{
char
*
serialized
=
syncClientRequest2Str
(
pMsg
);
sTrace
(
"syncClientRequestLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncClientRequest2Str
(
pMsg
);
sTrace
(
"syncClientRequestLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncRequestVote----
...
...
@@ -1084,9 +1094,11 @@ void syncRequestVoteLog(const SyncRequestVote* pMsg) {
}
void
syncRequestVoteLog2
(
char
*
s
,
const
SyncRequestVote
*
pMsg
)
{
char
*
serialized
=
syncRequestVote2Str
(
pMsg
);
sTrace
(
"syncRequestVoteLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncRequestVote2Str
(
pMsg
);
sTrace
(
"syncRequestVoteLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncRequestVoteReply----
...
...
@@ -1230,9 +1242,11 @@ void syncRequestVoteReplyLog(const SyncRequestVoteReply* pMsg) {
}
void
syncRequestVoteReplyLog2
(
char
*
s
,
const
SyncRequestVoteReply
*
pMsg
)
{
char
*
serialized
=
syncRequestVoteReply2Str
(
pMsg
);
sTrace
(
"syncRequestVoteReplyLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncRequestVoteReply2Str
(
pMsg
);
sTrace
(
"syncRequestVoteReplyLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncAppendEntries----
...
...
@@ -1399,9 +1413,11 @@ void syncAppendEntriesLog(const SyncAppendEntries* pMsg) {
}
void
syncAppendEntriesLog2
(
char
*
s
,
const
SyncAppendEntries
*
pMsg
)
{
char
*
serialized
=
syncAppendEntries2Str
(
pMsg
);
sTrace
(
"syncAppendEntriesLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncAppendEntries2Str
(
pMsg
);
sTrace
(
"syncAppendEntriesLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncAppendEntriesReply----
...
...
@@ -1551,9 +1567,11 @@ void syncAppendEntriesReplyLog(const SyncAppendEntriesReply* pMsg) {
}
void
syncAppendEntriesReplyLog2
(
char
*
s
,
const
SyncAppendEntriesReply
*
pMsg
)
{
char
*
serialized
=
syncAppendEntriesReply2Str
(
pMsg
);
sTrace
(
"syncAppendEntriesReplyLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncAppendEntriesReply2Str
(
pMsg
);
sTrace
(
"syncAppendEntriesReplyLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---- message process SyncApplyMsg----
...
...
@@ -1702,9 +1720,11 @@ void syncApplyMsgLog(const SyncApplyMsg* pMsg) {
}
void
syncApplyMsgLog2
(
char
*
s
,
const
SyncApplyMsg
*
pMsg
)
{
char
*
serialized
=
syncApplyMsg2Str
(
pMsg
);
sTrace
(
"syncApplyMsgLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncApplyMsg2Str
(
pMsg
);
sTrace
(
"syncApplyMsgLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---------------------------------------------
...
...
@@ -1870,9 +1890,11 @@ void syncSnapshotSendLog(const SyncSnapshotSend* pMsg) {
}
void
syncSnapshotSendLog2
(
char
*
s
,
const
SyncSnapshotSend
*
pMsg
)
{
char
*
serialized
=
syncSnapshotSend2Str
(
pMsg
);
sTrace
(
"syncSnapshotSendLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncSnapshotSend2Str
(
pMsg
);
sTrace
(
"syncSnapshotSendLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
// ---------------------------------------------
...
...
@@ -2028,7 +2050,9 @@ void syncSnapshotRspLog(const SyncSnapshotRsp* pMsg) {
}
void
syncSnapshotRspLog2
(
char
*
s
,
const
SyncSnapshotRsp
*
pMsg
)
{
char
*
serialized
=
syncSnapshotRsp2Str
(
pMsg
);
sTrace
(
"syncSnapshotRspLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncSnapshotRsp2Str
(
pMsg
);
sTrace
(
"syncSnapshotRspLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
\ No newline at end of file
source/libs/sync/src/syncRaftLog.c
浏览文件 @
d81f5e9f
...
...
@@ -583,7 +583,9 @@ void logStoreSimpleLog(SSyncLogStore* pLogStore) {
}
void
logStoreSimpleLog2
(
char
*
s
,
SSyncLogStore
*
pLogStore
)
{
char
*
serialized
=
logStoreSimple2Str
(
pLogStore
);
sTrace
(
"logStoreSimpleLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
if
(
gRaftDetailLog
)
{
char
*
serialized
=
logStoreSimple2Str
(
pLogStore
);
sTrace
(
"logStoreSimpleLog2 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录