Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
53774be0
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
53774be0
编写于
10月 14, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add debug info for sync module
上级
6f004e4c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
10 deletion
+37
-10
src/sync/inc/syncInt.h
src/sync/inc/syncInt.h
+3
-0
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+34
-10
未找到文件。
src/sync/inc/syncInt.h
浏览文件 @
53774be0
...
...
@@ -65,6 +65,9 @@ typedef struct {
typedef
struct
{
int8_t
role
;
int8_t
ack
;
int8_t
type
;
int8_t
reserved
[
3
];
uint16_t
tranId
;
uint64_t
version
;
SPeerStatus
peersStatus
[];
}
SPeersStatus
;
...
...
src/sync/src/syncMain.c
浏览文件 @
53774be0
...
...
@@ -48,7 +48,7 @@ static void * vgIdHash;
static
void
syncProcessSyncRequest
(
char
*
pMsg
,
SSyncPeer
*
pPeer
);
static
void
syncRecoverFromMaster
(
SSyncPeer
*
pPeer
);
static
void
syncCheckPeerConnection
(
void
*
param
,
void
*
tmrId
);
static
void
syncSendPeersStatusMsgToPeer
(
SSyncPeer
*
pPeer
,
char
ack
);
static
void
syncSendPeersStatusMsgToPeer
(
SSyncPeer
*
pPeer
,
char
ack
,
int8_t
type
,
uint16_t
tranId
);
static
void
syncProcessBrokenLink
(
void
*
param
);
static
int
syncProcessPeerMsg
(
void
*
param
,
void
*
buffer
);
static
void
syncProcessIncommingConnection
(
int
connFd
,
uint32_t
sourceIp
);
...
...
@@ -71,6 +71,28 @@ char* syncRole[] = {
"master"
};
typedef
enum
{
SYNC_STATUS_BROADCAST
,
SYNC_STATUS_BROADCAST_RSP
,
SYNC_STATUS_SETUP_CONN
,
SYNC_STATUS_SETUP_CONN_RSP
,
SYNC_STATUS_EXCHANGE_DATA
,
SYNC_STATUS_EXCHANGE_DATA_RSP
}
ESyncStatusType
;
char
*
statusType
[]
=
{
"broadcast"
,
"broadcast-rsp"
,
"setup-conn"
,
"setup-conn-rsp"
,
"exchange-data"
,
"exchange-data-rsp"
};
uint16_t
syncGenTranId
()
{
return
taosRand
()
&
0XFFFF
;
}
int32_t
syncInit
()
{
SPoolInfo
info
;
...
...
@@ -539,7 +561,7 @@ void syncBroadcastStatus(SSyncNode *pNode) {
for
(
int
i
=
0
;
i
<
pNode
->
replica
;
++
i
)
{
if
(
i
==
pNode
->
selfIndex
)
continue
;
pPeer
=
pNode
->
peerInfo
[
i
];
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
,
SYNC_STATUS_BROADCAST
,
syncGenTranId
()
);
}
}
...
...
@@ -894,14 +916,14 @@ static void syncProcessPeersStatusMsg(char *cont, SSyncPeer *pPeer) {
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SPeersStatus
*
pPeersStatus
=
(
SPeersStatus
*
)
cont
;
sDebug
(
"%s, status msg is received, self:%s ver:%"
PRIu64
" peer:%s ver:%"
PRIu64
", ack:%d"
,
pPeer
->
id
,
syncRole
[
nodeRole
],
nodeVersion
,
syncRole
[
pPeersStatus
->
role
],
pPeersStatus
->
version
,
pPeersStatus
->
ack
);
sDebug
(
"%s, status msg is received, self:%s ver:%"
PRIu64
" peer:%s ver:%"
PRIu64
", ack:%d
tranId:%u type:%s
"
,
pPeer
->
id
,
syncRole
[
nodeRole
],
nodeVersion
,
syncRole
[
pPeersStatus
->
role
],
pPeersStatus
->
version
,
pPeersStatus
->
ack
,
pPeersStatus
->
tranId
,
statusType
[
pPeersStatus
->
type
]
);
pPeer
->
version
=
pPeersStatus
->
version
;
syncCheckRole
(
pPeer
,
pPeersStatus
->
peersStatus
,
pPeersStatus
->
role
);
if
(
pPeersStatus
->
ack
)
{
syncSendPeersStatusMsgToPeer
(
pPeer
,
0
);
syncSendPeersStatusMsgToPeer
(
pPeer
,
0
,
pPeersStatus
->
type
+
1
,
pPeersStatus
->
tranId
);
}
}
...
...
@@ -958,7 +980,7 @@ static int syncProcessPeerMsg(void *param, void *buffer) {
#define statusMsgLen sizeof(SSyncHead) + sizeof(SPeersStatus) + sizeof(SPeerStatus) * TAOS_SYNC_MAX_REPLICA
static
void
syncSendPeersStatusMsgToPeer
(
SSyncPeer
*
pPeer
,
char
ack
)
{
static
void
syncSendPeersStatusMsgToPeer
(
SSyncPeer
*
pPeer
,
char
ack
,
int8_t
type
,
uint16_t
tranId
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
char
msg
[
statusMsgLen
]
=
{
0
};
...
...
@@ -973,6 +995,8 @@ static void syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack) {
pPeersStatus
->
version
=
nodeVersion
;
pPeersStatus
->
role
=
nodeRole
;
pPeersStatus
->
ack
=
ack
;
pPeersStatus
->
type
=
type
;
pPeersStatus
->
tranId
=
tranId
;
for
(
int
i
=
0
;
i
<
pNode
->
replica
;
++
i
)
{
pPeersStatus
->
peersStatus
[
i
].
role
=
pNode
->
peerInfo
[
i
]
->
role
;
...
...
@@ -981,8 +1005,8 @@ static void syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack) {
int
retLen
=
write
(
pPeer
->
peerFd
,
msg
,
statusMsgLen
);
if
(
retLen
==
statusMsgLen
)
{
sDebug
(
"%s, status msg is sent, self:%s ver:%"
PRIu64
", ack:%d"
,
pPeer
->
id
,
syncRole
[
pPeersStatus
->
role
],
pPeersStatus
->
version
,
pPeersStatus
->
ack
);
sDebug
(
"%s, status msg is sent, self:%s ver:%"
PRIu64
", ack:%d
tranId:%u type:%s
"
,
pPeer
->
id
,
syncRole
[
pPeersStatus
->
role
],
pPeersStatus
->
version
,
pPeersStatus
->
ack
,
pPeersStatus
->
tranId
,
statusType
[
pPeersStatus
->
type
]
);
}
else
{
sDebug
(
"%s, failed to send status msg, restart"
,
pPeer
->
id
);
syncRestartConnection
(
pPeer
);
...
...
@@ -997,7 +1021,7 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) {
taosTmrStopA
(
&
pPeer
->
timer
);
if
(
pPeer
->
peerFd
>=
0
)
{
sDebug
(
"%s, send role version to peer"
,
pPeer
->
id
);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
,
SYNC_STATUS_SETUP_CONN
,
syncGenTranId
()
);
return
;
}
...
...
@@ -1110,7 +1134,7 @@ static void syncProcessIncommingConnection(int connFd, uint32_t sourceIp) {
pPeer
->
pConn
=
taosAllocateTcpConn
(
tsTcpPool
,
pPeer
,
connFd
);
syncAddPeerRef
(
pPeer
);
sDebug
(
"%s, ready to exchange data"
,
pPeer
->
id
);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
,
SYNC_STATUS_EXCHANGE_DATA
,
syncGenTranId
()
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录