mirror of
https://github.com/predis/predis.git
synced 2026-08-24 21:39:38 +00:00
d0cc7a5947
When the connection to a node in the cluster fails in the attempt to execute a command, Predis now removes the failed connection from the cluster pool and contacts a random node to ask for a fresh slots map and tries to execute the command once again. When the cluster is configured to have each master replicated to one or more slaves, one the slaves is automatically promoted to the role of master by redis-cluster with this change being reflected in the output of CLUSTER SLOTS, so the next execution should run just fine. Our current approach is relatively naive as CLUSTER SLOTS is executed against a random master node, meaning that the client must open a new connection and execute one more roundtrip only to fetch the new slots map. For now it is enough, it is still better than having the client fail when you actually have somes slaves in your redis-cluster setup, but one improvement could consist in caching the list of slaves for each master returned in the response of CLUSTER SLOTS so that when a connection fails the client can try to guess which connection should use for the next attempt. This commit closes #173, closes #215, and closes #314.