adrienmo / eredis_cluster

eredis_cluster is an erlang wrapper for eredis to support cluster mode of redis 3.0.0+
MIT License
79 stars 83 forks source link

Client does not update its state according to the Cluster Configuration #11

Closed tiroshanm closed 7 years ago

tiroshanm commented 7 years ago

Hi, I have noticed that the eredis_cluster client does not update its state ( master / slave nodes and other available nodes in the cluster). As an example lets say, we have given IPA:7000, IPA:7001 as init_nodes in app config where (IPA:7000, IPA:7001, IPA:7002 are Masters & IPB:7000, IPB:7001, IPC:7002 are slaves in the actual cluster setup. What if IPA:7000 & IPA:7001 all are down at once? I have noticed client is continuously giving error no_connection without recovering it self connecting to updated Masters in the cluster.

Am I correct ? Thanks.

adrienmo commented 7 years ago

Hi,

In case of failure, eredis cluster will try to reconnect to the initial nodes to get the new slot mapping (init_nodes). If for some reason all the nodes of the init_nodes are down, it won't be able to retrieve the new mapping. One solution to that would be to update init_nodes at runtime with all the values given by the "CLUSTER SLOTS" command and get the ips of both masters and slaves available:

It should fix this problem. In the current logic we don't consider what are the slaves of a given master, in case of problem we just reload everything, it makes the code implementation a little bit simpler, but we could also think of a way where we would only remap slots for dead nodes and use this information.

To answer your question, it depends of your init_nodes value, if init_nodes value only have IPA:7000 & IPA:7001, then it cannot recover, if init_nodes have the 6 addresses, then it should recover, if it is not the case, it is an unknown bug that needs to be investigated.

tiroshanm commented 7 years ago

Hi Adrienmo, Thanks for the quick reply. I am planning to change my eredis-cluster client as you have mentioned and just ask to clear my path.

Thanks.