-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In cluster, if connection was never established correctly it will never be established #2225
Comments
Workaround: in your own code check if connectionHandler.getNodes().isEmpty(). If it is, call connectionHandler.renewSlotCache(connectionHandler.getConnectionFromNode(hostAndPort)); (where hostAndPort are the initial ones). Do this in a loop, e.g. in a Timer.scheduleAtFixedRate. |
@bironran Thank you for providing the workaround. I'm trying to implement a similar workaround when using Jedis under Spring Data Redis. But I can't seem to figure out any way to get a handle on that connectionHandler instance. I don't suppose anyone might know of a way to implement such a workaround when the connections are being handled via the Spring Data Redis library which doesn't seem to provide a way to access this connectionHandler? |
@giladam sorry, not using Spring Data Redis. but I imagine you can sublcass |
@bironran Thank you! Subclassing JedisCluster and getting the JedisClusterConnectionHandler from inside there definitely works! |
Expected behavior
In redis cluster, if connection is defined with a set of of HostAndPort, even if it cannot be established during initialization, if it can be established later it will be
Actual behavior
Connection is never established.
JedisClusterConnectionHandler.renewSlotCache calls JedisClusterInfoCache.renewClusterSlots(null) which in turn makes JedisClusterInfoCache look at its internal Map<String, JedisPool> nodes field for information on how to renew the connection pool. However, if a connection was never successfully established before (e.g. if Redis was down during startup of the application using Jedis), this nodes field will remain empty. This causes the Jedis never recover from that type of error.
Steps to reproduce:
Start Jedis cluster connection pointing to a a redis host that is currently down.
Set a loop calling any Jedis method (e.g. get).
After a few seconds in the loop, start the redis server.
Connection is never actually established.
The text was updated successfully, but these errors were encountered: