Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
02e38516
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
02e38516
编写于
7月 03, 2018
作者:
S
Salvatore Sanfilippo
提交者:
GitHub
7月 03, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5081 from trevor211/fixClusterFailover
cluster failover bug
上级
2edcafb3
2e167f7d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
1 deletion
+78
-1
src/replication.c
src/replication.c
+1
-1
tests/cluster/tests/05-slave-selection.tcl
tests/cluster/tests/05-slave-selection.tcl
+77
-0
未找到文件。
src/replication.c
浏览文件 @
02e38516
...
@@ -1087,6 +1087,7 @@ void replicationCreateMasterClient(int fd, int dbid) {
...
@@ -1087,6 +1087,7 @@ void replicationCreateMasterClient(int fd, int dbid) {
if
(
server
.
master
->
reploff
==
-
1
)
if
(
server
.
master
->
reploff
==
-
1
)
server
.
master
->
flags
|=
CLIENT_PRE_PSYNC
;
server
.
master
->
flags
|=
CLIENT_PRE_PSYNC
;
if
(
dbid
!=
-
1
)
selectDb
(
server
.
master
,
dbid
);
if
(
dbid
!=
-
1
)
selectDb
(
server
.
master
,
dbid
);
server
.
repl_down_since
=
0
;
}
}
void
restartAOF
()
{
void
restartAOF
()
{
...
@@ -1950,7 +1951,6 @@ void replicationSetMaster(char *ip, int port) {
...
@@ -1950,7 +1951,6 @@ void replicationSetMaster(char *ip, int port) {
* our own parameters, to later PSYNC with the new master. */
* our own parameters, to later PSYNC with the new master. */
if
(
was_master
)
replicationCacheMasterUsingMyself
();
if
(
was_master
)
replicationCacheMasterUsingMyself
();
server
.
repl_state
=
REPL_STATE_CONNECT
;
server
.
repl_state
=
REPL_STATE_CONNECT
;
server
.
repl_down_since
=
0
;
}
}
/* Cancel replication, setting the instance as a master itself. */
/* Cancel replication, setting the instance as a master itself. */
...
...
tests/cluster/tests/05-slave-selection.tcl
浏览文件 @
02e38516
...
@@ -92,3 +92,80 @@ test "Node #10 should eventually replicate node #5" {
...
@@ -92,3 +92,80 @@ test "Node #10 should eventually replicate node #5" {
fail
"#10 didn't became slave of #5"
fail
"#10 didn't became slave of #5"
}
}
}
}
source
"../tests/includes/init-tests.tcl"
# Create a cluster with 3 master and 15 slaves, so that we have 5
# slaves for eatch master.
test
"Create a 3 nodes cluster"
{
create_cluster 3 15
}
test
"Cluster is up"
{
assert_cluster_state ok
}
test
"The first master has actually 5 slaves"
{
assert
{[
llength
[
lindex
[
R 0 role
]
2
]]
== 5
}
}
test
{
Slaves of #0 are instance #3, #6, #9, #12 and #15 as expected
}
{
set port0
[
get_instance_attrib redis 0 port
]
assert
{[
lindex
[
R 3 role
]
2
]
== $port0
}
assert
{[
lindex
[
R 6 role
]
2
]
== $port0
}
assert
{[
lindex
[
R 9 role
]
2
]
== $port0
}
assert
{[
lindex
[
R 12 role
]
2
]
== $port0
}
assert
{[
lindex
[
R 15 role
]
2
]
== $port0
}
}
test
{
Instance #3, #6, #9, #12 and #15 synced with the master
}
{
wait_for_condition 1000 50
{
[
RI 3 master_link_status
]
eq
{
up
}
&&
[
RI 6 master_link_status
]
eq
{
up
}
&&
[
RI 9 master_link_status
]
eq
{
up
}
&&
[
RI 12 master_link_status
]
eq
{
up
}
&&
[
RI 15 master_link_status
]
eq
{
up
}
}
else
{
fail
"Instance #3 or #6 or #9 or #12 or #15 master link status is not up"
}
}
proc master_detected
{
instances
}
{
foreach instance
[
dict keys $instances
]
{
if
{[
RI $instance role
]
eq
{
master
}}
{
return true
}
}
return false
}
test
"New Master down consecutively"
{
set instances
[
dict create 0 1 3 1 6 1 9 1 12 1 15 1
]
set loops
[
expr
{[
dict size $instances
]
-1
}]
for
{
set i 0
}
{
$i
< $loops
}
{
incr i
}
{
set master_id -1
foreach instance
[
dict keys $instances
]
{
if
{[
RI $instance role
]
eq
{
master
}}
{
set master_id $instance
break
;
}
}
if
{
$master
_id eq -1
}
{
fail
"no master detected, #loop
$i
"
}
set instances
[
dict remove $instances $master_id
]
kill_instance redis $master_id
wait_for_condition 1000 50
{
[
master_detected $instances
]
}
else
{
failover
"No failover detected when master
$master
_id fails"
}
assert_cluster_state ok
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录