From f64f11b81fbd169323916fb2f64612779fdb5ed4 Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Mon, 7 Oct 2024 20:31:01 +0300 Subject: [PATCH] Don't force the RandomPrimary logic This fixes a regression introduced by commit: 41de670 Signed-off-by: Eran Ifrah --- redis/src/aio/tokio.rs | 1 + redis/src/cluster_routing.rs | 21 ++------------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/redis/src/aio/tokio.rs b/redis/src/aio/tokio.rs index cb6663225..3a68c0ebf 100644 --- a/redis/src/aio/tokio.rs +++ b/redis/src/aio/tokio.rs @@ -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, diff --git a/redis/src/cluster_routing.rs b/redis/src/cluster_routing.rs index ded53bc35..bfe6ae203 100644 --- a/redis/src/cluster_routing.rs +++ b/redis/src/cluster_routing.rs @@ -613,13 +613,7 @@ impl RoutingInfo { .and_then(|x| std::str::from_utf8(x).ok()) .and_then(|x| x.parse::().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)) } @@ -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")),