Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b1093b4a
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b1093b4a
编写于
6月 13, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(sync): use fqdn instead of raftId
上级
34c906a1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
10 deletion
+61
-10
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+15
-10
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+14
-0
source/libs/sync/test/syncRaftIdCheck.cpp
source/libs/sync/test/syncRaftIdCheck.cpp
+32
-0
未找到文件。
source/libs/sync/src/syncMain.c
浏览文件 @
b1093b4a
...
...
@@ -35,7 +35,7 @@
#include "syncVoteMgr.h"
#include "tref.h"
bool
gRaftDetailLog
=
fals
e
;
bool
gRaftDetailLog
=
tru
e
;
static
int32_t
tsNodeRefId
=
-
1
;
...
...
@@ -216,25 +216,30 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pNewCfg) {
bool
IamInNew
=
false
;
for
(
int
i
=
0
;
i
<
pNewCfg
->
replicaNum
;
++
i
)
{
SRaftId
newId
;
newId
.
addr
=
syncUtilAddr2U64
((
pNewCfg
->
nodeInfo
)[
i
].
nodeFqdn
,
(
pNewCfg
->
nodeInfo
)[
i
].
nodePort
);
newId
.
vgId
=
pSyncNode
->
vgId
;
sTrace
(
"new[%d]: %lu, %d, my: %lu, %d"
,
i
,
newId
.
addr
,
newId
.
vgId
,
pSyncNode
->
myRaftId
.
addr
,
pSyncNode
->
myRaftId
.
vgId
);
if
(
syncUtilSameId
(
&
(
pSyncNode
->
myRaftId
),
&
newId
))
{
if
(
strcmp
((
pNewCfg
->
nodeInfo
)[
i
].
nodeFqdn
,
pSyncNode
->
myNodeInfo
.
nodeFqdn
)
==
0
&&
(
pNewCfg
->
nodeInfo
)[
i
].
nodePort
==
pSyncNode
->
myNodeInfo
.
nodePort
)
{
IamInNew
=
true
;
}
/*
// some problem in inet_addr
SRaftId newId = EMPTY_RAFT_ID;
newId.addr = syncUtilAddr2U64((pNewCfg->nodeInfo)[i].nodeFqdn, (pNewCfg->nodeInfo)[i].nodePort);
newId.vgId = pSyncNode->vgId;
if (syncUtilSameId(&(pSyncNode->myRaftId), &newId)) {
IamInNew = true;
}
*/
}
if
(
!
IamInNew
)
{
sError
(
"sync reconfig error, not in new config"
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
TAOS_SYNC_NOT_IN_NEW_CONFIG
;
}
char
*
newconfig
=
syncCfg2Str
((
SSyncCfg
*
)
pNewCfg
);
if
(
gRaftDetailLog
)
{
sInfo
(
"==syncReconfig== newconfig:%s"
,
newconfig
);
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
b1093b4a
add_executable
(
syncTest
""
)
add_executable
(
syncRaftIdCheck
""
)
add_executable
(
syncEnvTest
""
)
add_executable
(
syncPingTimerTest
""
)
add_executable
(
syncIOTickQTest
""
)
...
...
@@ -54,6 +55,10 @@ target_sources(syncTest
PRIVATE
"syncTest.cpp"
)
target_sources
(
syncRaftIdCheck
PRIVATE
"syncRaftIdCheck.cpp"
)
target_sources
(
syncEnvTest
PRIVATE
"syncEnvTest.cpp"
...
...
@@ -257,6 +262,11 @@ target_include_directories(syncTest
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncRaftIdCheck
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncEnvTest
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
...
...
@@ -508,6 +518,10 @@ target_link_libraries(syncTest
sync
gtest_main
)
target_link_libraries
(
syncRaftIdCheck
sync
gtest_main
)
target_link_libraries
(
syncEnvTest
sync
gtest_main
...
...
source/libs/sync/test/syncRaftIdCheck.cpp
0 → 100644
浏览文件 @
b1093b4a
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncIO.h"
#include "syncInt.h"
#include "syncUtil.h"
void
usage
(
char
*
exe
)
{
printf
(
"Usage: %s host port
\n
"
,
exe
);
printf
(
"Usage: %s u64
\n
"
,
exe
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
2
)
{
uint64_t
u64
=
atoll
(
argv
[
1
]);
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
printf
(
"%s:%d
\n
"
,
host
,
port
);
}
else
if
(
argc
==
3
)
{
uint64_t
u64
;
char
*
host
=
argv
[
1
];
uint16_t
port
=
atoi
(
argv
[
2
]);
syncUtilAddr2U64
(
host
,
port
);
printf
(
"%lu
\n
"
,
u64
);
}
else
{
usage
(
argv
[
0
]);
exit
(
-
1
);
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录