From 5d16a838db8fa1dea4af88b92756fc121572b9ba Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 23 Jun 2014 14:04:09 +0200 Subject: [PATCH] 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. --- tests/sentinel/tests/includes/init-tests.tcl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/sentinel/tests/includes/init-tests.tcl b/tests/sentinel/tests/includes/init-tests.tcl index c48fb537..c8165dcf 100644 --- a/tests/sentinel/tests/includes/init-tests.tcl +++ b/tests/sentinel/tests/includes/init-tests.tcl @@ -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 test "(init) Create a master-slaves cluster of [expr $redis_slaves+1] instances" { create_redis_master_slave_cluster [expr {$redis_slaves+1}] @@ -22,7 +28,6 @@ test "(init) Sentinels can start monitoring a master" { set sentinels [llength $::sentinel_instances] set quorum [expr {$sentinels/2+1}] foreach_sentinel_id id { - catch {S $id SENTINEL REMOVE mymaster} S $id SENTINEL MONITOR mymaster \ [get_instance_attrib redis $master_id host] \ [get_instance_attrib redis $master_id port] $quorum -- GitLab