Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2baa7188
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看板
提交
2baa7188
编写于
1月 02, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: logging states of sync log repl mgrs and the ring buffer in syncPrintNodeLog
上级
cb433c19
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
29 deletion
+55
-29
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+55
-29
未找到文件。
source/libs/sync/src/syncUtil.c
浏览文件 @
2baa7188
...
...
@@ -17,6 +17,7 @@
#include "syncUtil.h"
#include "syncIndexMgr.h"
#include "syncMessage.h"
#include "syncPipeline.h"
#include "syncRaftCfg.h"
#include "syncRaftStore.h"
#include "syncSnapshot.h"
...
...
@@ -163,45 +164,67 @@ bool syncUtilUserPreCommit(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP &&
bool
syncUtilUserRollback
(
tmsg_t
msgType
)
{
return
msgType
!=
TDMT_SYNC_NOOP
&&
msgType
!=
TDMT_SYNC_LEADER_TRANSFER
;
}
void
syncCfg2SimpleStr
(
const
SSyncCfg
*
pCfg
,
char
*
buf
,
int32_t
bufLen
)
{
int32_t
len
=
snprintf
(
buf
,
bufLen
,
"{r-num:%d, my:%d, "
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
int32_t
len
=
snprintf
(
buf
,
bufLen
,
"{num:%d, idx:%d, ["
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s:%d"
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
pCfg
->
nodeInfo
[
i
].
nodePort
);
if
(
i
<
pCfg
->
replicaNum
-
1
)
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s:%d, "
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
pCfg
->
nodeInfo
[
i
].
nodePort
);
}
else
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s:%d}"
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
pCfg
->
nodeInfo
[
i
].
nodePort
);
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
", "
);
}
}
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"]}"
);
}
// for leader
static
void
syncHearbeatReplyTime2Str
(
SSyncNode
*
pSyncNode
,
char
*
buf
,
int32_t
bufLen
)
{
int32_t
len
=
5
;
int32_t
len
=
0
;
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"{"
);
for
(
int32_t
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
++
i
)
{
int64_t
tsMs
=
syncIndexMgrGetRecvTime
(
pSyncNode
->
pMatchIndex
,
&
(
pSyncNode
->
replicasId
[
i
]));
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
,
i
,
tsMs
);
if
(
i
<
pSyncNode
->
replicaNum
-
1
)
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
","
,
i
,
tsMs
);
}
else
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
"}"
,
i
,
tsMs
);
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
","
);
}
}
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"}"
);
}
// for follower
static
void
syncHearbeatTime2Str
(
SSyncNode
*
pSyncNode
,
char
*
buf
,
int32_t
bufLen
)
{
int32_t
len
=
4
;
int32_t
len
=
0
;
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"{"
);
for
(
int32_t
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
++
i
)
{
int64_t
tsMs
=
syncIndexMgrGetRecvTime
(
pSyncNode
->
pNextIndex
,
&
(
pSyncNode
->
replicasId
[
i
]));
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
,
i
,
tsMs
);
if
(
i
<
pSyncNode
->
replicaNum
-
1
)
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
","
,
i
,
tsMs
);
}
else
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%"
PRId64
"}"
,
i
,
tsMs
);
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
","
);
}
}
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"}"
);
}
static
void
syncLogBufferStates2Str
(
SSyncNode
*
pSyncNode
,
char
*
buf
,
int32_t
bufLen
)
{
SSyncLogBuffer
*
pBuf
=
pSyncNode
->
pLogBuf
;
if
(
pBuf
==
NULL
)
{
return
;
}
int
len
=
0
;
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"[%"
PRId64
" %"
PRId64
" %"
PRId64
", %"
PRId64
")"
,
pBuf
->
startIndex
,
pBuf
->
commitIndex
,
pBuf
->
matchIndex
,
pBuf
->
endIndex
);
}
static
void
syncLogReplMgrStates2Str
(
SSyncNode
*
pSyncNode
,
char
*
buf
,
int32_t
bufLen
)
{
int
len
=
0
;
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"{"
);
for
(
int32_t
i
=
0
;
i
<
pSyncNode
->
replicaNum
;
i
++
)
{
SSyncLogReplMgr
*
pMgr
=
pSyncNode
->
logReplMgrs
[
i
];
if
(
pMgr
==
NULL
)
break
;
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%d:%d [%"
PRId64
" %"
PRId64
", %"
PRId64
")"
,
i
,
pMgr
->
restored
,
pMgr
->
startIndex
,
pMgr
->
matchIndex
,
pMgr
->
endIndex
);
if
(
i
+
1
<
pSyncNode
->
replicaNum
)
{
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
", "
);
}
}
len
+=
snprintf
(
buf
+
len
,
bufLen
-
len
,
"%s"
,
"}"
);
}
static
void
syncPeerState2Str
(
SSyncNode
*
pSyncNode
,
char
*
buf
,
int32_t
bufLen
)
{
...
...
@@ -243,20 +266,23 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
int32_t
cacheHit
=
pNode
->
pLogStore
->
cacheHit
;
int32_t
cacheMiss
=
pNode
->
pLogStore
->
cacheMiss
;
char
cfgStr
[
1024
];
char
cfgStr
[
1024
]
=
""
;
if
(
pNode
->
pRaftCfg
!=
NULL
)
{
syncCfg2SimpleStr
(
&
(
pNode
->
pRaftCfg
->
cfg
),
cfgStr
,
sizeof
(
cfgStr
));
}
else
{
return
;
}
char
peerStr
[
1024
]
=
"{"
;
syncPeerState2Str
(
pNode
,
peerStr
,
sizeof
(
peerStr
));
char
replMgrStatesStr
[
1024
]
=
""
;
syncLogReplMgrStates2Str
(
pNode
,
replMgrStatesStr
,
sizeof
(
replMgrStatesStr
));
char
bufferStatesStr
[
256
]
=
""
;
syncLogBufferStates2Str
(
pNode
,
bufferStatesStr
,
sizeof
(
bufferStatesStr
));
char
hbrTimeStr
[
256
]
=
"
hbr:{
"
;
char
hbrTimeStr
[
256
]
=
""
;
syncHearbeatReplyTime2Str
(
pNode
,
hbrTimeStr
,
sizeof
(
hbrTimeStr
));
char
hbTimeStr
[
256
]
=
"
hb:{
"
;
char
hbTimeStr
[
256
]
=
""
;
syncHearbeatTime2Str
(
pNode
,
hbTimeStr
,
sizeof
(
hbTimeStr
));
int32_t
quorum
=
syncNodeDynamicQuorum
(
pNode
);
...
...
@@ -279,16 +305,16 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
taosPrintLog
(
flags
,
level
,
dflag
,
"vgId:%d, %s, sync:%s, term:%"
PRIu64
", commit-index:%"
PRId64
", first-ver:%"
PRId64
", last-ver:%"
PRId64
", min:%"
PRId64
", snap:%"
PRId64
", snap-term:%"
PRIu64
", elect-times:%d, as-leader-times:%d, cfg-ch-times:%d, h
it:%d, mis:%d, h
b-slow:%d, hbr-slow:%d, "
", elect-times:%d, as-leader-times:%d, cfg-ch-times:%d, hb-slow:%d, hbr-slow:%d, "
"aq-items:%d, snaping:%"
PRId64
", replicas:%d, last-cfg:%"
PRId64
", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%"
PRId64
", hb:%"
PRId64
", %s, %s, %s, %s"
,
", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%"
PRId64
", hb:%"
PRId64
", buffer:%s, log-repl-mgrs:%s, members:%s, hb:%s, hb-reply:%s"
,
pNode
->
vgId
,
eventLog
,
syncStr
(
pNode
->
state
),
currentTerm
,
pNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
pNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pNode
->
electNum
,
pNode
->
becomeLeaderNum
,
pNode
->
configChangeNum
,
cacheHit
,
cacheMiss
,
pNode
->
hbSlowNum
,
pNode
->
hbrSlowNum
,
aqItems
,
pNode
->
snapshottingIndex
,
pNode
->
replicaNum
,
pNode
->
pRaftCfg
->
lastConfigIndex
,
pNode
->
changing
,
pNode
->
restoreFinish
,
quorum
,
pNode
->
electTimerLogicClock
,
pNode
->
heartbeatTimerLogicClockUser
,
peerStr
,
cfgStr
,
hbTimeStr
,
hbrTimeStr
);
pNode
->
becomeLeaderNum
,
pNode
->
configChangeNum
,
pNode
->
hbSlowNum
,
pNode
->
hbrSlowNum
,
aqItems
,
pNode
->
snapshottingIndex
,
pNode
->
replicaNum
,
pNode
->
pRaftCfg
->
lastConfigIndex
,
pNode
->
changing
,
pNode
->
restoreFinish
,
quorum
,
pNode
->
electTimerLogicClock
,
pNode
->
heartbeatTimerLogicClockUser
,
bufferStatesStr
,
replMgrStatesStr
,
cfgStr
,
hbTimeStr
,
hbrTimeStr
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录