Skip to content
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

Improved redirection error handling #857

Merged
merged 1 commit into from
Jun 19, 2023
Merged

Conversation

jaymell
Copy link
Contributor

@jaymell jaymell commented Jun 5, 2023

This PR adds proper ASK redirection for the async cluster implementation, so rather than simply rebuilding slots, which may not be an appropriate response to ASK anyway, it issues the relevant ASKING command to the redirected node and issues the query.

A Redirect enum has been added for better handling of both redirect scenarios.

The async cluster MOVED implementation has also been tweaked. Instead of immediately refreshing slots, the redirected node will be queried, and slots will be refreshed after the redirected request has been made. The same approach has not been taken on the sync implementation for now because doing so would require greater refactoring than is appropriate here.

Copy link
Contributor

@nihohit nihohit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation is fine, a couple of comments on the tests

redis/tests/test_cluster.rs Outdated Show resolved Hide resolved
redis/tests/test_cluster_async.rs Outdated Show resolved Hide resolved
redis/tests/test_cluster_async.rs Outdated Show resolved Hide resolved
redis/tests/test_cluster_async.rs Outdated Show resolved Hide resolved
redis/tests/test_cluster_async.rs Outdated Show resolved Hide resolved
redis/src/cluster.rs Show resolved Hide resolved
redis/src/cluster_async/mod.rs Show resolved Hide resolved
redis/src/cluster_async/mod.rs Show resolved Hide resolved
redis/src/cluster_async/mod.rs Outdated Show resolved Hide resolved
redis/src/cluster_async/mod.rs Outdated Show resolved Hide resolved
redis/src/cluster_async/mod.rs Show resolved Hide resolved
redis/tests/test_cluster_async.rs Outdated Show resolved Hide resolved
This PR adds proper `ASK` redirection for the async cluster
implementation, so rather than simply rebuilding slots, which may
not be an appropriate response to `ASK` anyway, it issues the
relevant `ASKING` command to the redirected node and issues the
query.

A `Redirect` enum has been added for better handling of both redirect
scenarios.

The async cluster implementation has also been tweaked.
1) Instead of immediately refreshing slots, the redirected node will
   be queried, and slots will be refreshed after the redirected
   request has been made. The same approach has not been taken on the
   sync implementation for now because doing so would require greater
   refactoring than is appropriate here.
2) To support 1), async-cluster requests have been refactored to try
   and create a connection to the redirected node if it doesn't
   already exist in the connection-map (which is likely, of course, if
   a new node has been added to the cluster).

A couple existing tests have also been renamed for clarity.
Copy link
Contributor

@nihohit nihohit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jaymell jaymell merged commit 3ce6a9f into redis-rs:main Jun 19, 2023
9 checks passed
@jaymell jaymell deleted the async-ask branch June 19, 2023 20:17
altanozlu pushed a commit to altanozlu/redis-rs that referenced this pull request Aug 16, 2023
This PR adds proper `ASK` redirection for the async cluster
implementation, so rather than simply rebuilding slots, which may
not be an appropriate response to `ASK` anyway, it issues the
relevant `ASKING` command to the redirected node and issues the
query.

A `Redirect` enum has been added for better handling of both redirect
scenarios.

The async cluster implementation has also been tweaked as follows:
1) Instead of immediately refreshing slots, the redirected node will
   be queried, and slots will be "scheduled" for refresh after the 
   redirected request (and other "in-flight requests") has been made. 
   The same approach has not been taken on the sync implementation for
   now because doing so would require greater refactoring than is  
   appropriate here.
2) To support 1), async-cluster requests have been refactored to 
   potentially create a connection to the appropriate address if an 
   existing one cannot be found or obtained (which is likely, of 
   course, if a new node has been added to the cluster). This matches 
   existing functionality in the sync implementation.

A couple existing tests have also been renamed for clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants