Grokzen / redis-py-cluster

Python cluster client for the official redis cluster. Redis 3.0+.
https://redis-py-cluster.readthedocs.io/
MIT License
1.1k stars 316 forks source link

Bugfix/fix move errors #477

Open JonathanWylie opened 2 years ago

JonathanWylie commented 2 years ago

2 bug fixes here and a logging improvement and a testing improvement: 1/ Startup nodes were not being populated correctly when initialising the node manager. 2/ Handling of SlotNotCoveredError was raising the exception one attempt too early, before it had used all allowed TTL. 3/ When a command is executed and it succeeds it's nice not to have a bunch of error exception logs. Instead only log the exception if all attempts are used up, otherwise log a warning. It's useful to be able to differentiate between a command that failed fatally, and one that was ultimately successful, with perhaps some warnings about short lived problems along the way. 4/ It took me forever to work out what kind of cluster I need to run the tests against. It was fairly simple in the end, but I have included a docker_compose.yml file which can be used to start the redis cluster for the tests.

Could you could also give a rationale for picking a random node when a timeout error happens? I am also curious as to what conditions it is trying to handle. Every time I have seen this in action, picking a different node, just results in a moved error, pointing the client back to the original node. So it's unclear to me why it doesn't just keep trying the correct node, instead of picking an incorrect node only to be redirect back.