zhchsf / redis_cluster

A redis cluster ruby client gem
MIT License
20 stars 10 forks source link

Breaks when any of the node in the list goes down #21

Open 15astro opened 6 years ago

15astro commented 6 years ago
require "redis_cluster"
rs = RedisCluster.new([{host: '10.x.x.1', port: 9000}, {host: '10.x.x.2', port: 8000},{host: '10.x.x.2', port: 7000},{host: '10.x.x.3', port: 8000}, {host: '10.x.x.2', port: 7000}, {host: '10.x.x.3', port: 9000}])
i=0
rs.pipelined do
    while i < 100000000 do
    rs.set "b", i
    i +=1
   end
end

I have above code snippet running, but when 10.0.0.1:7000 master in cluster goes down, it simply break, does not insert data in new master

/usr/local/rvm/gems/ruby-2.5.1/gems/redis-3.3.5/lib/redis/client.rb:121:incall': MOVED 3300 10.0.0.1:7000 (Redis::CommandError)`

redis_cluster (0.3.2) redis version: 4.0.11

zhchsf commented 6 years ago

It depend on health of redis clusters. When one master node goes down, redis clusters will be in self recovery. It maybe some error to execute command. After recovery completed, it will be fine to execute command.

15astro commented 6 years ago

@zhchsf, The new master is elected in less than a second. How can reconnection be tried in this case to connect to the newly elected master instead of breaking code?