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

Execute multi-node requests using try_request. #14

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

nihohit
Copy link

@nihohit nihohit commented Jul 27, 2023

This means multi node operations now get error handling, and can trigger MOVED, etc.

Additionally, func was removed from CmdArg::Cmd/Pipeline. This removes the need
to allocate a box on every request, and reduces code complexity by eliminating an
unnecessary generic type.

@nihohit nihohit changed the title Remove func from CmdArg::Cmd/Pipeline. Execute multi-node requests using try_request. Jul 27, 2023
@nihohit nihohit requested a review from barshaul July 27, 2023 12:07
This means multi node operations now get error handling, and can trigger
MOVED, etc.

Additionally, func was removed from CmdArg::Cmd/Pipeline. This removes
the need to allocate a box on every request, and slightly reduces code
complexity.
let result = conn.req_packed_command(&cmd).await.map(Response::Single);
return (addr.into(), result);
}
None
Copy link

Choose a reason for hiding this comment

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

so, if 'asking', we get a random node? why?

Copy link

Choose a reason for hiding this comment

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

If we already have the connection, why won't we just do something like (in 723)

let mut conn = conn.await;
if asking {      
   let _ = conn.req_packed_command(&crate::cmd::cmd("ASKING")).await;
}
let result = conn.req_packed_command(&cmd).await.map(Response::Single);
return (addr.into(), result);

Is it even possible that we'll get a CommandRouting::Connection, and asking == true?

Copy link
Author

Choose a reason for hiding this comment

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

so, if 'asking', we get a random node? why?

No, if asking then we'll get the redirected connection when calling get_connection.

If we already have the connection, why won't we just do something like

Because then we'd use the old connection instead of getting the redirected connection.

@@ -699,20 +711,30 @@ where

async fn try_cmd_request(
Copy link

Choose a reason for hiding this comment

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

This function is a bit hard to understand. can you add some comments, e.g., in the first part - single node request without routing, second - multi node request, third - single node request with routing. something that will explain it a bit more, I got lost between the CommandRouting, routing, route_option, RoutingInfo...

Copy link
Author

@nihohit nihohit Aug 2, 2023

Choose a reason for hiding this comment

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

added some comments and restructured the function, please tell me if they are sufficient.

Copy link

Choose a reason for hiding this comment

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

looks great now, thanks

@@ -454,12 +449,12 @@ where
let inner = Arc::new(InnerCore {
conn_lock: RwLock::new((connections, Default::default())),
cluster_params,
pending_requests: Mutex::new(Vec::new()),
Copy link

Choose a reason for hiding this comment

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

why did you move it to InnerCore?

Copy link
Author

Choose a reason for hiding this comment

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

otherwise it won't be accessible from within execute_on_multiple_nodes, and you won't be able to add the new requests to the queue.

redis/src/cluster_async/mod.rs Outdated Show resolved Hide resolved
redis/src/cluster_async/mod.rs Outdated Show resolved Hide resolved
@nihohit
Copy link
Author

nihohit commented Aug 2, 2023

@barshaul round

@nihohit nihohit merged commit e474b7e into main Aug 3, 2023
9 checks passed
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.

2 participants