Skip to content

Commit

Permalink
Added CommandMap check before requesting cluster nodes (#2014)
Browse files Browse the repository at this point in the history
Fixes #2012

Co-authored-by: Nick Craver <nrcraver@gmail.com>
  • Loading branch information
tylerohlsen and NickCraver authored Feb 26, 2022
1 parent 32dea99 commit 65c1f28
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
- Adds Envoy proxy support (#1989 via rkarthick)
- When `SUBSCRIBE` is disabled, give proper errors and connect faster (#2001 via NickCraver)
- Adds `GET` on `SET` command support (present in Redis 6.2+ - #2003 via martinekvili)
- Improve concurrent load performance when backlogs are utilized (#2008 via NickCraver)
- Improves concurrent load performance when backlogs are utilized (#2008 via NickCraver)
- Improves cluster connections when `CLUSTER` command is disabled (#2014 via tylerohlsen)

## 2.5.27 (prerelease)

Expand Down
2 changes: 1 addition & 1 deletion src/StackExchange.Redis/ConnectionMultiplexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, LogP
break;
}

if (clusterCount > 0 && !encounteredConnectedClusterServer)
if (clusterCount > 0 && !encounteredConnectedClusterServer && CommandMap.IsAvailable(RedisCommand.CLUSTER))
{
// We have encountered a connected server with a cluster type for the first time.
// so we will get list of other nodes from this server using "CLUSTER NODES" command
Expand Down
18 changes: 18 additions & 0 deletions tests/StackExchange.Redis.Tests/ConnectCustomConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ public void DisabledCommandsStillConnect(string disabledCommands)
Assert.True(db.IsConnected(default(RedisKey)));
}

[Theory]
[InlineData("config")]
[InlineData("info")]
[InlineData("get")]
[InlineData("cluster")]
[InlineData("config,get")]
[InlineData("info,get")]
[InlineData("config,info,get")]
[InlineData("config,info,get,cluster")]
public void DisabledCommandsStillConnectCluster(string disabledCommands)
{
using var muxer = Create(allowAdmin: true, configuration: TestConfig.Current.ClusterServersAndPorts, disabledCommands: disabledCommands.Split(','), log: Writer);

var db = muxer.GetDatabase();
db.Ping();
Assert.True(db.IsConnected(default(RedisKey)));
}

[Fact]
public void TieBreakerIntact()
{
Expand Down

0 comments on commit 65c1f28

Please sign in to comment.