Commit e21e0ba3 authored by antirez's avatar antirez
Browse files

Sentinel test: more correct sentinels config reset.

In the initialization test for each instance we used to unregister the
old master and register it again to clear the config.
However there is a race condition doing this: as soon as we unregister
and re-register "mymaster", another Sentinel can update the new
configuration with the old state because of gossip "hello" messages.

So the correct procedure is instead, unregister "mymaster" from all the
sentinel instances, and re-register it everywhere again.
parent e3bae846
...@@ -12,6 +12,12 @@ test "(init) Restart killed instances" { ...@@ -12,6 +12,12 @@ test "(init) Restart killed instances" {
} }
} }
test "(init) Remove old master entry from sentinels" {
foreach_sentinel_id id {
catch {S $id SENTINEL REMOVE mymaster}
}
}
set redis_slaves 4 set redis_slaves 4
test "(init) Create a master-slaves cluster of [expr $redis_slaves+1] instances" { test "(init) Create a master-slaves cluster of [expr $redis_slaves+1] instances" {
create_redis_master_slave_cluster [expr {$redis_slaves+1}] create_redis_master_slave_cluster [expr {$redis_slaves+1}]
...@@ -22,7 +28,6 @@ test "(init) Sentinels can start monitoring a master" { ...@@ -22,7 +28,6 @@ test "(init) Sentinels can start monitoring a master" {
set sentinels [llength $::sentinel_instances] set sentinels [llength $::sentinel_instances]
set quorum [expr {$sentinels/2+1}] set quorum [expr {$sentinels/2+1}]
foreach_sentinel_id id { foreach_sentinel_id id {
catch {S $id SENTINEL REMOVE mymaster}
S $id SENTINEL MONITOR mymaster \ S $id SENTINEL MONITOR mymaster \
[get_instance_attrib redis $master_id host] \ [get_instance_attrib redis $master_id host] \
[get_instance_attrib redis $master_id port] $quorum [get_instance_attrib redis $master_id port] $quorum
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment