-
Notifications
You must be signed in to change notification settings - Fork 946
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
Best practice for Cluster Topology Refresh #339
Comments
Thanks for your question. You deal with a couple of issues here. First, and most important, the attached gist depicts a bug. Would you care to file an issue? About topology refreshing: There are different use-cases, and the only true refresh mechanism is no topology changes/no refreshing at all. Every other approach is trying to compensate in the one or other way. I know that a frozen topology is not feasible for the real world, so we have to stick to the one or the other refreshing mechanism. My rationale why the current refreshing mechanism possibilities are compensation:
How to improve Redis Cluster topology updates: About About your gist: The gist shows a bug. The command is redirected to a host that was not connected before. The connection attempt fails with a deadlock. This issue is not related to reconnection. |
Thanks for your immediate response.
And about the exception's gist I attached here, I filed another issue #340 so I'm closing this one. |
What does this means ?
That's ok for slot changes but in a case of a master/slave failover, that happens before the client opens a connection, there's currently no chance to discover that. I think lettuce could improve here by checking the cluster node role after connecting. |
This is rather a question than an issue or bug report.
My lettuce version: 4.2.1
Recently I found an issue discussing the Topology refresh and the use of ClusterClientOptions. In this comment @mp911de recommends to enable
ClusterTopologyRefreshOptions#enableAllAdaptiveRefreshTriggers
and set relatively longer period of time toClusterTopologyRefreshOptions#enablePeriodicRefresh
or even get rid of periodic refresh.It makes sense to me because the adaptive refresh is only triggered by MOVED, ASK, and reconnection timeout event so the cost is minimal. The official document also recommend this kind of strategy:
So here comes my question.
What is the best practice for Cluster Topology Refresh settings?
Currently the wiki has a sample code of below, which states both periodic refresh and adaptive refresh trigger:
https://github.com/mp911de/lettuce/wiki/Client-options#cluster-specific-options
I understand this is not necessarily the recommended settings for topology refresh, but it kind of confuses me so let me make sure.
My assumptions are:
ClusterTopologyRefreshOptions#enableAllAdaptiveRefreshTriggers
, for regular purpose since this refreshes topology view on demand.RedisClusterClient
instance is used for pub/sub purpose and expects to reconnect on master-slave failover, the client still needs to setClusterTopologyRefreshOptions#enablePeriodicRefresh
with reasonable interval depending on application use so that the subscribing connection can check its target node’s state.To supplement 2nd assumption -- I still have vague understanding, though --
ClusterTopologyRefreshOptions#cancelCommandsOnReconnectFailure
is used to reset enqueued command on reconnection fail. And it doesn't handle the command retrial caused by topology refresh. It seems like com.lambdaworks.redis.cluster. PooledClusterConnectionProvider#getConnection still have a chance to throws Exception on first connection fetch during or after topology refresh. ref. gistI still wonder how I should detect those command failure caused by this particular case and handle retrial.
To sum up, the option setting for regular usage becomes one like below:
And for cluster pub/sub, it’ll be something like below:
Am I right about my above assumption, and is there any recommended way to handle retiral?
Thanks in advance.
The text was updated successfully, but these errors were encountered: