-
Couldn't load subscription status.
- Fork 1k
Description
Pardon me if I've missed something, but it appears that even when connecting to sentinel, Redis.new() requires the client to know which redis host is currently the master? This defeats the point of connecting to the sentinels at all.
e.g., I have 2 redis hosts on redis1 and redis2. redis1 is master, redis2 is slave (and I have a 3rd sentinel instance running on a host named arbiter). I connect like:
sentinels = [
{ :host => 'redis1', :port => 26379},
{ :host => 'redis2', :port => 26379},
{ :host => 'arbiter', :port => 26379}]
redis = Redis.new(:url => 'redis://redis1', "sentinels" => sentinels, :role => :master)
and everything works fine.
However, if failover has occurred and redis1 and redis2 have swapped their roles as master and slave, if I restart my rails server or boot a new instance, the same connect incantation above yields:
Redis::CommandError: READONLY You can't write against a read only slave.
i.e., even though it has connected to the sentinels, it is not aware of the current master instance and attempts to write to the instance specified in the :url parameter regardless of the current master/slave configuration.
Am I missing something?