Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0ce12e8f
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看板
提交
0ce12e8f
编写于
12月 22, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2524
上级
f82f11e2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
7 deletion
+37
-7
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+37
-7
未找到文件。
src/sync/src/syncMain.c
浏览文件 @
0ce12e8f
...
...
@@ -59,6 +59,8 @@ static void syncRestartPeer(SSyncPeer *pPeer);
static
int32_t
syncForwardToPeerImpl
(
SSyncNode
*
pNode
,
void
*
data
,
void
*
mhandle
,
int32_t
qtyp
);
static
SSyncPeer
*
syncAddPeer
(
SSyncNode
*
pNode
,
const
SNodeInfo
*
pInfo
);
static
void
syncStartCheckPeerConn
(
SSyncPeer
*
pPeer
);
static
void
syncStopCheckPeerConn
(
SSyncPeer
*
pPeer
);
static
SSyncNode
*
syncAcquireNode
(
int64_t
rid
);
static
void
syncReleaseNode
(
SSyncNode
*
pNode
);
...
...
@@ -250,6 +252,11 @@ int64_t syncStart(const SSyncInfo *pInfo) {
(
*
pNode
->
notifyRole
)(
pNode
->
vgId
,
nodeRole
);
}
syncStartCheckPeerConn
(
pNode
->
peerInfo
[
TAOS_SYNC_MAX_REPLICA
]);
// arb
for
(
int32_t
index
=
0
;
index
<
pNode
->
replica
;
++
index
)
{
syncStartCheckPeerConn
(
pNode
->
peerInfo
[
index
]);
}
return
pNode
->
rid
;
}
...
...
@@ -292,6 +299,11 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg *pNewCfg) {
pthread_mutex_lock
(
&
pNode
->
mutex
);
syncStopCheckPeerConn
(
pNode
->
peerInfo
[
TAOS_SYNC_MAX_REPLICA
]);
// arb
for
(
int32_t
index
=
0
;
index
<
pNode
->
replica
;
++
index
)
{
syncStopCheckPeerConn
(
pNode
->
peerInfo
[
index
]);
}
for
(
i
=
0
;
i
<
pNode
->
replica
;
++
i
)
{
for
(
j
=
0
;
j
<
pNewCfg
->
replica
;
++
j
)
{
if
((
strcmp
(
pNode
->
peerInfo
[
i
]
->
fqdn
,
pNewCfg
->
nodeInfo
[
j
].
nodeFqdn
)
==
0
)
&&
...
...
@@ -348,6 +360,11 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg *pNewCfg) {
(
*
pNode
->
notifyRole
)(
pNode
->
vgId
,
nodeRole
);
}
syncStartCheckPeerConn
(
pNode
->
peerInfo
[
TAOS_SYNC_MAX_REPLICA
]);
// arb
for
(
int32_t
index
=
0
;
index
<
pNode
->
replica
;
++
index
)
{
syncStartCheckPeerConn
(
pNode
->
peerInfo
[
index
]);
}
pthread_mutex_unlock
(
&
pNode
->
mutex
);
sInfo
(
"vgId:%d, %d replicas are configured, quorum:%d"
,
pNode
->
vgId
,
pNode
->
replica
,
pNode
->
quorum
);
...
...
@@ -539,6 +556,26 @@ static void syncRemovePeer(SSyncPeer *pPeer) {
syncReleasePeer
(
pPeer
);
}
static
void
syncStartCheckPeerConn
(
SSyncPeer
*
pPeer
)
{
if
(
pPeer
==
NULL
)
return
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
int32_t
ret
=
strcmp
(
pPeer
->
fqdn
,
tsNodeFqdn
);
if
(
pPeer
->
nodeId
==
0
||
(
ret
>
0
)
||
(
ret
==
0
&&
pPeer
->
port
>
tsSyncPort
))
{
int32_t
checkMs
=
100
+
(
pNode
->
vgId
*
10
)
%
100
;
if
(
pNode
->
vgId
>
1
)
checkMs
=
tsStatusInterval
*
1000
+
checkMs
;
sDebug
(
"%s, check peer connection after %d ms"
,
pPeer
->
id
,
checkMs
);
taosTmrReset
(
syncCheckPeerConnection
,
checkMs
,
(
void
*
)
pPeer
->
rid
,
tsSyncTmrCtrl
,
&
pPeer
->
timer
);
}
}
static
void
syncStopCheckPeerConn
(
SSyncPeer
*
pPeer
)
{
if
(
pPeer
==
NULL
)
return
;
taosTmrStopA
(
&
pPeer
->
timer
);
sDebug
(
"%s, stop check peer connection"
,
pPeer
->
id
);
}
static
SSyncPeer
*
syncAddPeer
(
SSyncNode
*
pNode
,
const
SNodeInfo
*
pInfo
)
{
uint32_t
ip
=
taosGetIpFromFqdn
(
pInfo
->
nodeFqdn
);
if
(
ip
==
0xFFFFFFFF
)
{
...
...
@@ -565,13 +602,6 @@ static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) {
pPeer
->
rid
=
taosAddRef
(
tsPeerRefId
,
pPeer
);
sInfo
(
"%s, %p it is configured, ep:%s:%u rid:%"
PRId64
,
pPeer
->
id
,
pPeer
,
pPeer
->
fqdn
,
pPeer
->
port
,
pPeer
->
rid
);
int32_t
ret
=
strcmp
(
pPeer
->
fqdn
,
tsNodeFqdn
);
if
(
pPeer
->
nodeId
==
0
||
(
ret
>
0
)
||
(
ret
==
0
&&
pPeer
->
port
>
tsSyncPort
))
{
int32_t
checkMs
=
100
+
(
pNode
->
vgId
*
10
)
%
100
;
if
(
pNode
->
vgId
>
1
)
checkMs
=
tsStatusInterval
*
1000
+
checkMs
;
sDebug
(
"%s, check peer connection after %d ms"
,
pPeer
->
id
,
checkMs
);
taosTmrReset
(
syncCheckPeerConnection
,
checkMs
,
(
void
*
)
pPeer
->
rid
,
tsSyncTmrCtrl
,
&
pPeer
->
timer
);
}
(
void
)
syncAcquireNode
(
pNode
->
rid
);
return
pPeer
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录