Skip to content

Commit 396536d

Browse files
authored
Don't force the RandomPrimary logic (#195)
This fixes a regression introduced by commit: 41de670 Signed-off-by: Eran Ifrah <[email protected]>
1 parent 41de670 commit 396536d

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

redis/src/aio/tokio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::{AsyncStream, RedisResult, RedisRuntime, SocketAddr};
22
use async_trait::async_trait;
3+
#[allow(unused_imports)] // fixes "Duration" unused when built with non-default feature set
34
use std::{
45
future::Future,
56
io,

redis/src/cluster_routing.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,7 @@ impl RoutingInfo {
613613
.and_then(|x| std::str::from_utf8(x).ok())
614614
.and_then(|x| x.parse::<u64>().ok())?;
615615
if key_count == 0 {
616-
if is_readonly_cmd(cmd) {
617-
Some(RoutingInfo::SingleNode(SingleNodeRoutingInfo::Random))
618-
} else {
619-
Some(RoutingInfo::SingleNode(
620-
SingleNodeRoutingInfo::RandomPrimary,
621-
))
622-
}
616+
Some(RoutingInfo::SingleNode(SingleNodeRoutingInfo::Random))
623617
} else {
624618
r.arg_idx(3).map(|key| RoutingInfo::for_key(cmd, key))
625619
}
@@ -1116,23 +1110,12 @@ mod tests {
11161110
cmd("EVAL").arg(r#"redis.call("PING");"#).arg(0),
11171111
cmd("EVALSHA").arg(r#"redis.call("PING");"#).arg(0),
11181112
] {
1119-
// EVAL / EVALSHA are expected to be routed to a RandomPrimary
11201113
assert_eq!(
11211114
RoutingInfo::for_routable(cmd),
1122-
Some(RoutingInfo::SingleNode(
1123-
SingleNodeRoutingInfo::RandomPrimary
1124-
))
1115+
Some(RoutingInfo::SingleNode(SingleNodeRoutingInfo::Random))
11251116
);
11261117
}
11271118

1128-
// FCALL (with 0 keys) is expected to be routed to a random primary node
1129-
assert_eq!(
1130-
RoutingInfo::for_routable(cmd("FCALL").arg("foo").arg(0)),
1131-
Some(RoutingInfo::SingleNode(
1132-
SingleNodeRoutingInfo::RandomPrimary
1133-
))
1134-
);
1135-
11361119
// While FCALL with N keys is expected to be routed to a specific node
11371120
assert_eq!(
11381121
RoutingInfo::for_routable(cmd("FCALL").arg("foo").arg(1).arg("mykey")),

0 commit comments

Comments
 (0)