You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are sometimes seeing this error while trying to configure the client to connect to the master node in a 3 node sentinel setup:
Redis::ConnectionError (Instance role mismatch. Expected master, got slave.)
For example:
module DataCache
class << self
def redis
@redis ||= Redis.new(redis_opts)
end
def redis_opts
svc = 'redis-headless'
# query headless svc to get all sentinel addresses
sentinels = Resolv.getaddresses(svc).map do |address|
{ host: address, port: 26379, password: ENV["REDIS_PASSWORD"] }
end
# connect to master for read/write
{
host: "mymaster",
sentinels: sentinels,
password: ENV["REDIS_PASSWORD"],
role: :master
}
end
end
end
Our setup (mostly aligned with this one) includes 1 master and 2 slave nodes. It is unclear to me how the client ever gets connected to a slave node given we are configuring it with role :master? But it appears to be selecting any of the 3 nodes indiscriminately (there is no error on the times when the client correctly connects to the master node)
I saw this same error, and it wound up being a redis config issue similar to bitnami/charts#10745 (we're running redis in kubernetes). The misconfiguration caused the sentinels to disagree about which node was the master, and that broke failover. When the service rolled, master would get demoted to slave but the client wouldn't be informed, hence the error. After all the nodes had rolled, the error would change from the one you're seeing to "No sentinels found".
@branweb1 are you using istio too or plain k8s ? We face the same issue where a node gets demoted from master to slave but the redis client does not get informed or does not try to get the new master.
Hello,
We are sometimes seeing this error while trying to configure the client to connect to the master node in a 3 node sentinel setup:
Redis::ConnectionError (Instance role mismatch. Expected master, got slave.)
For example:
Our setup (mostly aligned with this one) includes 1 master and 2 slave nodes. It is unclear to me how the client ever gets connected to a slave node given we are configuring it with role
:master
? But it appears to be selecting any of the 3 nodes indiscriminately (there is no error on the times when the client correctly connects to the master node)I'm hoping I just have something misconfigured and someone might kindly point me in the right direction
The text was updated successfully, but these errors were encountered: