Nordix / hiredis-cluster

C client library for Valkey/Redis Cluster. This project is used and sponsored by Ericsson. It is a fork of the now unmaintained hiredis-vip.
BSD 3-Clause "New" or "Revised" License
87 stars 42 forks source link

return error when master node failover #140

Closed youfeiyou closed 1 year ago

youfeiyou commented 1 year ago

hello, i have a redis cluster with three master and three slave. when one master or slave node is down, function command() will return error "server closed connection". i try to set retry option but useless, is there any ways to solve it? thanks (my request way is Synchronous blocking )

zuiderkwast commented 1 year ago

Hi You.

The option max_retry_count is only used for redirects and -TRYAGAIN responses. There is no retry for other errors.

Why? Because we don't know if the command has been executed on the Redis node or not before the error happened. For some commands like INCR or LPUSH it is not safe to run them twice.

Maybe we can implement automatic retry for some commands where it it safe to do it, but for now I think you will need to do retry in a loop in your code.

youfeiyou commented 1 year ago

ok ,thank you, i wll try it