Skip to content

Commit

Permalink
Don't force the RandomPrimary logic (#195)
Browse files Browse the repository at this point in the history
This fixes a regression introduced by commit: 41de670

Signed-off-by: Eran Ifrah <[email protected]>
  • Loading branch information
eifrah-aws authored Oct 8, 2024
1 parent 41de670 commit 396536d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 1 addition & 0 deletions redis/src/aio/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{AsyncStream, RedisResult, RedisRuntime, SocketAddr};
use async_trait::async_trait;
#[allow(unused_imports)] // fixes "Duration" unused when built with non-default feature set
use std::{
future::Future,
io,
Expand Down
21 changes: 2 additions & 19 deletions redis/src/cluster_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,7 @@ impl RoutingInfo {
.and_then(|x| std::str::from_utf8(x).ok())
.and_then(|x| x.parse::<u64>().ok())?;
if key_count == 0 {
if is_readonly_cmd(cmd) {
Some(RoutingInfo::SingleNode(SingleNodeRoutingInfo::Random))
} else {
Some(RoutingInfo::SingleNode(
SingleNodeRoutingInfo::RandomPrimary,
))
}
Some(RoutingInfo::SingleNode(SingleNodeRoutingInfo::Random))
} else {
r.arg_idx(3).map(|key| RoutingInfo::for_key(cmd, key))
}
Expand Down Expand Up @@ -1116,23 +1110,12 @@ mod tests {
cmd("EVAL").arg(r#"redis.call("PING");"#).arg(0),
cmd("EVALSHA").arg(r#"redis.call("PING");"#).arg(0),
] {
// EVAL / EVALSHA are expected to be routed to a RandomPrimary
assert_eq!(
RoutingInfo::for_routable(cmd),
Some(RoutingInfo::SingleNode(
SingleNodeRoutingInfo::RandomPrimary
))
Some(RoutingInfo::SingleNode(SingleNodeRoutingInfo::Random))
);
}

// FCALL (with 0 keys) is expected to be routed to a random primary node
assert_eq!(
RoutingInfo::for_routable(cmd("FCALL").arg("foo").arg(0)),
Some(RoutingInfo::SingleNode(
SingleNodeRoutingInfo::RandomPrimary
))
);

// While FCALL with N keys is expected to be routed to a specific node
assert_eq!(
RoutingInfo::for_routable(cmd("FCALL").arg("foo").arg(1).arg("mykey")),
Expand Down

0 comments on commit 396536d

Please sign in to comment.