Skip to content

Redis driver unable to recover after one of the redis cluster master is killed #802

Closed
@mayankgoyal

Description

@mayankgoyal

I am using Redis driver 4.0.3 with a redis cluster (4.0.10 - 3 master/3 slaves) and have noticed that the driver caches cluster information early on a fails to update when a cluster master is killed and is failover by a slave. The driver still tries to connect to the older node indefinitely if the master never comes back up.

Scenario:

  1. Start a Redis cluster as described here https://redis.io/topics/cluster-tutorial#creating-and-using-a-redis-cluster
  2. Connect driver with all 1 to 6 nodes in the cluster
::Redis.new({replica: true, cluster: [{host: "localhost", port: 7000}]})
  1. Read/write some random keys in an infinite loop from the cluster with a rescue to make sure ::Redis::CannotConnectError is handled and the script does not crash.
  2. Kill a master node
  3. Notice the client is stuck and cannot connect to the shard master.
  4. Notice the redis cluster has elected the slave as master.
  5. Notice the client is still trying to connect to the original master node and not to the slave.

I would assume that this would have worked with a CLUSTER FAILOVER command was issued, but not for crashes as the cluster state is never refreshed in this scenario?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions