-
Notifications
You must be signed in to change notification settings - Fork 350
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
[QUESTION] different behavior for async and sync cluster #544
Comments
Can you show me the minimum code that reproduce your problem? You can try the following code, if you continue sending command to it, once the new master is elected, AsyncRedisCluster sends command to the new master node.
It should print the value, and once the master node is down, it prints error info: failed to connect to Redis (127.0.0.1:7001): Connection refused, err: 1, errno: 61, until the new mater is elected, and it print value again:
Regards |
Sure, here is example code:
the output would be:
in this case one request fails despite redis cluster being already in stable state. |
Thanks for the info! Both async and sync API sends command to the old master node, since the client has no idea that a new master has been elected (since master goes down but we don't interact with redis for now, for example doing some other work). Since the old master is down, redis client gets an IoError. However, the difference is that sync API updates node-slot mapping synchronously, and sends (retries) command to the new master, while the async API updates the mapping asynchronously, sets exception info and returns immediately. And that's why you got an error info with async api. Regards |
Such was my assumption. However, the question is if different behavior between synchronous and asynchronous APIs was intentional? In the asynchronous version. we encounter a situation where we receive an error even though everything is fine with the cluster. I guess it is possible to implement retry also in asynchronous version when mapping is updated. |
I have to admit that I didn't realize this problem before your issue. However, so far, it's not an easy job to implement the retry with async interface (you know the async stuff is much more complicated than the sync one). Instead, I might add some more aggressive strategy to update the mapping.
Yes, if you get an error, the cluster might be in an unhealthy state, and you might want to retry it in your application or give up the request, and report error message to your end user. Regards |
In a very simple scenario:
Given:
When:
1.one of redis master nodes goes down
2. replica takes over
3. couple seconds after redis node fail, client send get for key which is on the shard which master just failed
Then:
reds++ tries to connect to node which is down, when it fails Future holds exception for user code: "Failed to connect to Redis ... connection refused, err: 1, errno: 107.
Question: This behavior is different to what can be observed when we use synchronous version of RedisCluster. In synchronous version if connecting to node fails it updates slot mapping and then send request to newly elected master.
Why is that different?
Environment:
The text was updated successfully, but these errors were encountered: