Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5035e5e9
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看板
未验证
提交
5035e5e9
编写于
11月 25, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18463 from taosdata/feature/3.0_mhli
refactor(sync): add trace log
上级
97ba6087
93efefcb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
27 addition
and
10 deletion
+27
-10
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+1
-0
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+1
-0
source/libs/sync/inc/syncReplication.h
source/libs/sync/inc/syncReplication.h
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+15
-4
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+1
-0
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+3
-3
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+5
-2
未找到文件。
source/libs/sync/inc/syncInt.h
浏览文件 @
5035e5e9
...
...
@@ -70,6 +70,7 @@ typedef struct SSyncTimer {
uint64_t
logicClock
;
uint64_t
counter
;
int32_t
timerMS
;
int64_t
timeStamp
;
SRaftId
destId
;
int64_t
hbDataRid
;
}
SSyncTimer
;
...
...
source/libs/sync/inc/syncMessage.h
浏览文件 @
5035e5e9
...
...
@@ -35,6 +35,7 @@ typedef struct SyncTimeout {
ESyncTimeoutType
timeoutType
;
uint64_t
logicClock
;
int32_t
timerMS
;
int64_t
timeStamp
;
void
*
data
;
// need optimized
}
SyncTimeout
;
...
...
source/libs/sync/inc/syncReplication.h
浏览文件 @
5035e5e9
...
...
@@ -48,7 +48,7 @@ extern "C" {
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
int32_t
syncNodeHeartbeatPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
pDestId
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
pDestId
,
SRpcMsg
*
pMsg
,
const
char
*
debugStr
);
int32_t
syncNodeReplicate
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeReplicateOne
(
SSyncNode
*
pSyncNode
,
SRaftId
*
pDestId
,
bool
snapshot
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
5035e5e9
...
...
@@ -691,6 +691,7 @@ static int32_t syncHbTimerInit(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer, SRa
pSyncTimer
->
timerMS
=
pSyncNode
->
hbBaseLine
;
pSyncTimer
->
timerCb
=
syncNodeEqPeerHeartbeatTimer
;
pSyncTimer
->
destId
=
destId
;
pSyncTimer
->
timeStamp
=
taosGetTimestampMs
();
atomic_store_64
(
&
pSyncTimer
->
logicClock
,
0
);
return
0
;
}
...
...
@@ -704,6 +705,7 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) {
pData
->
rid
=
syncHbTimerDataAdd
(
pData
);
}
pSyncTimer
->
hbDataRid
=
pData
->
rid
;
pSyncTimer
->
timeStamp
=
taosGetTimestampMs
();
pData
->
syncNodeRid
=
pSyncNode
->
rid
;
pData
->
pTimer
=
pSyncTimer
;
...
...
@@ -1897,7 +1899,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
return
;
}
sTrace
(
"enqueue ping msg"
);
//
sTrace("enqueue ping msg");
code
=
pNode
->
syncEqMsg
(
pNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
sError
(
"failed to sync enqueue ping msg since %s"
,
terrstr
());
...
...
@@ -2041,8 +2043,15 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
pSyncMsg
->
privateTerm
=
0
;
pSyncMsg
->
timeStamp
=
taosGetTimestampMs
();
// update reset time
int64_t
tsNow
=
taosGetTimestampMs
();
int64_t
timerElapsed
=
tsNow
-
pSyncTimer
->
timeStamp
;
pSyncTimer
->
timeStamp
=
tsNow
;
char
logBuf
[
64
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"timer-elapsed:%"
PRId64
,
timerElapsed
);
// send msg
syncNodeSendHeartbeat
(
pSyncNode
,
&
pSyncMsg
->
destId
,
&
rpcMsg
);
syncNodeSendHeartbeat
(
pSyncNode
,
&
pSyncMsg
->
destId
,
&
rpcMsg
,
logBuf
);
}
else
{
sTrace
(
"vgId:%d, do not send hb, timerLogicClock:%"
PRId64
", msgLogicClock:%"
PRId64
""
,
pSyncNode
->
vgId
,
...
...
@@ -2151,8 +2160,9 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
SyncHeartbeat
*
pMsg
=
pRpcMsg
->
pCont
;
int64_t
tsMs
=
taosGetTimestampMs
();
int64_t
timeDiff
=
tsMs
-
pMsg
->
timeStamp
;
char
buf
[
128
];
snprintf
(
buf
,
sizeof
(
buf
),
"
recv local time:%"
PRId64
,
tsMs
);
snprintf
(
buf
,
sizeof
(
buf
),
"
net elapsed:%"
PRId64
,
timeDiff
);
syncLogRecvHeartbeat
(
ths
,
pMsg
,
buf
);
SRpcMsg
rpcMsg
=
{
0
};
...
...
@@ -2229,8 +2239,9 @@ int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
SyncHeartbeatReply
*
pMsg
=
pRpcMsg
->
pCont
;
int64_t
tsMs
=
taosGetTimestampMs
();
int64_t
timeDiff
=
tsMs
-
pMsg
->
timeStamp
;
char
buf
[
128
];
snprintf
(
buf
,
sizeof
(
buf
),
"
recv local time:%"
PRId64
,
tsMs
);
snprintf
(
buf
,
sizeof
(
buf
),
"
net elapsed:%"
PRId64
,
timeDiff
);
syncLogRecvHeartbeatReply
(
ths
,
pMsg
,
buf
);
// update last reply time, make decision whether the other node is alive or not
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
5035e5e9
...
...
@@ -35,6 +35,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l
pTimeout
->
timeoutType
=
timeoutType
;
pTimeout
->
logicClock
=
logicClock
;
pTimeout
->
timerMS
=
timerMS
;
pTimeout
->
timeStamp
=
taosGetTimestampMs
();
pTimeout
->
data
=
pNode
;
return
0
;
}
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
5035e5e9
...
...
@@ -207,8 +207,8 @@ int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* dest
return
ret
;
}
int32_t
syncNodeSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destId
,
SRpcMsg
*
pMsg
)
{
syncLogSendHeartbeat
(
pSyncNode
,
pMsg
->
pCont
,
""
);
int32_t
syncNodeSendHeartbeat
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destId
,
SRpcMsg
*
pMsg
,
const
char
*
debugStr
)
{
syncLogSendHeartbeat
(
pSyncNode
,
pMsg
->
pCont
,
debugStr
);
return
syncNodeSendMsgById
(
destId
,
pSyncNode
,
pMsg
);
}
...
...
@@ -231,7 +231,7 @@ int32_t syncNodeHeartbeatPeers(SSyncNode* pSyncNode) {
pSyncMsg
->
timeStamp
=
ts
;
// send msg
syncNodeSendHeartbeat
(
pSyncNode
,
&
pSyncMsg
->
destId
,
&
rpcMsg
);
syncNodeSendHeartbeat
(
pSyncNode
,
&
pSyncMsg
->
destId
,
&
rpcMsg
,
"x"
);
}
return
0
;
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
5035e5e9
...
...
@@ -396,8 +396,11 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df
}
void
syncLogRecvTimer
(
SSyncNode
*
pSyncNode
,
const
SyncTimeout
*
pMsg
,
const
char
*
s
)
{
sNTrace
(
pSyncNode
,
"recv sync-timer {type:%s, lc:%"
PRId64
", ms:%d, data:%p}, %s"
,
syncTimerTypeStr
(
pMsg
->
timeoutType
),
pMsg
->
logicClock
,
pMsg
->
timerMS
,
pMsg
->
data
,
s
);
int64_t
tsNow
=
taosGetTimestampMs
();
int64_t
timeDIff
=
tsNow
-
pMsg
->
timeStamp
;
sNTrace
(
pSyncNode
,
"recv sync-timer {type:%s, lc:%"
PRId64
", ms:%d, ts:%"
PRId64
", elapsed:%"
PRId64
", data:%p}, %s"
,
syncTimerTypeStr
(
pMsg
->
timeoutType
),
pMsg
->
logicClock
,
pMsg
->
timerMS
,
pMsg
->
timeStamp
,
timeDIff
,
pMsg
->
data
,
s
);
}
void
syncLogRecvLocalCmd
(
SSyncNode
*
pSyncNode
,
const
SyncLocalCmd
*
pMsg
,
const
char
*
s
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录