From b99979a51c443ef99e5330e5388fbdeb5377ecd6 Mon Sep 17 00:00:00 2001 From: Ali Alp Date: Mon, 14 Jun 2021 19:08:20 +0300 Subject: [PATCH 1/6] doccumentation spelling issue resolved (#1764) --- src/StackExchange.Redis/Interfaces/IBatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StackExchange.Redis/Interfaces/IBatch.cs b/src/StackExchange.Redis/Interfaces/IBatch.cs index c98e9013b..34f125332 100644 --- a/src/StackExchange.Redis/Interfaces/IBatch.cs +++ b/src/StackExchange.Redis/Interfaces/IBatch.cs @@ -12,7 +12,7 @@ public interface IBatch : IDatabaseAsync { /// /// Execute the batch operation, sending all queued commands to the server. - /// Note that this operation is neither synchronous nor truly asyncronous - it + /// Note that this operation is neither synchronous nor truly asynchronous - it /// simply enqueues the buffered messages. To check on completion, you should /// check the individual responses. /// From ca13715ab907063ff7f73ccd93999b723d4bbba3 Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Tue, 15 Jun 2021 08:25:51 -0400 Subject: [PATCH 2/6] Redis: add command attempted to NOAUTH results (#1757) This will help us in debugging what command is trying to be sent in the failure. --- src/StackExchange.Redis/ResultProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StackExchange.Redis/ResultProcessor.cs b/src/StackExchange.Redis/ResultProcessor.cs index c46bcad9d..cde0e5a12 100644 --- a/src/StackExchange.Redis/ResultProcessor.cs +++ b/src/StackExchange.Redis/ResultProcessor.cs @@ -2081,7 +2081,7 @@ public override bool SetResult(PhysicalConnection connection, Message message, i { if (result.StartsWith(CommonReplies.authFail_trimmed) || result.StartsWith(CommonReplies.NOAUTH)) { - connection.RecordConnectionFailed(ConnectionFailureType.AuthenticationFailure, new Exception(result.ToString() + " Verify if the Redis password provided is correct.")); + connection.RecordConnectionFailed(ConnectionFailureType.AuthenticationFailure, new Exception(result.ToString() + " Verify if the Redis password provided is correct. Attempted command: " + message.Command)); } else if (result.StartsWith(CommonReplies.loading)) { From 0c027b6543737c67a8c29b3a536f0a6ac1f874f9 Mon Sep 17 00:00:00 2001 From: Tim Lovell-Smith Date: Tue, 15 Jun 2021 09:34:25 -0700 Subject: [PATCH 3/6] Micro optimization - repeated dictionary lookups (#1765) FWLIW. Not really a hot path, but why not save some electrons. --- src/StackExchange.Redis/ConnectionMultiplexer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/StackExchange.Redis/ConnectionMultiplexer.cs b/src/StackExchange.Redis/ConnectionMultiplexer.cs index de404b3da..db5322c31 100644 --- a/src/StackExchange.Redis/ConnectionMultiplexer.cs +++ b/src/StackExchange.Redis/ConnectionMultiplexer.cs @@ -2359,8 +2359,8 @@ public ConnectionMultiplexer GetSentinelMasterConnection(ConfigurationOptions co lock (sentinelConnectionChildren) { - if (sentinelConnectionChildren.ContainsKey(config.ServiceName) && !sentinelConnectionChildren[config.ServiceName].IsDisposed) - return sentinelConnectionChildren[config.ServiceName]; + if (sentinelConnectionChildren.TryGetValue(config.ServiceName, out var sentinelConnectionChild) && !sentinelConnectionChild.IsDisposed) + return sentinelConnectionChild; } bool success = false; From 6a6a48ce72f072ee4af2fd980077653cbab0a1f4 Mon Sep 17 00:00:00 2001 From: Laura Uzcategui Date: Tue, 15 Jun 2021 17:41:49 +0100 Subject: [PATCH 4/6] Update Cluster AutoDiscovery after failover (#1684) The following commits address: https://github.com/StackExchange/StackExchange.Redis/issues/1659 Where basically after manual failover the replicas endpoint list is not refreshed. ServerSelectionStrategy.cs Updated: - SetClusterConfiguration to call new method UpdateNodeRelations with the configuration Added: - UpdateNodeRelations to have the same update logic that it was before in SetClusterConfiguration so it could be used in ConnectionMultiplexer ConnectionMultiplexer.cs Updated: - GetEndpointsFromClusterNodes, to call UpdateNodeRelations and refresh the configuration before returning the endpoints list --- .../ConnectionMultiplexer.cs | 14 ++++++- src/StackExchange.Redis/ServerEndPoint.cs | 38 +++++++++++-------- 2 files changed, 35 insertions(+), 17 deletions(-) mode change 100644 => 100755 src/StackExchange.Redis/ConnectionMultiplexer.cs mode change 100644 => 100755 src/StackExchange.Redis/ServerEndPoint.cs diff --git a/src/StackExchange.Redis/ConnectionMultiplexer.cs b/src/StackExchange.Redis/ConnectionMultiplexer.cs old mode 100644 new mode 100755 index db5322c31..1f11f19f0 --- a/src/StackExchange.Redis/ConnectionMultiplexer.cs +++ b/src/StackExchange.Redis/ConnectionMultiplexer.cs @@ -1953,7 +1953,19 @@ private async Task GetEndpointsFromClusterNodes(ServerEndPoi try { var clusterConfig = await ExecuteAsyncImpl(message, ResultProcessor.ClusterNodes, null, server).ForAwait(); - return new EndPointCollection(clusterConfig.Nodes.Select(node => node.EndPoint).ToList()); + var clusterEndpoints = new EndPointCollection(clusterConfig.Nodes.Select(node => node.EndPoint).ToList()); + // Loop through nodes in the cluster and update nodes relations to other nodes + ServerEndPoint serverEndpoint = null; + foreach (EndPoint endpoint in clusterEndpoints) + { + serverEndpoint = GetServerEndPoint(endpoint); + if (serverEndpoint != null) + { + serverEndpoint.UpdateNodeRelations(clusterConfig); + } + + } + return clusterEndpoints; } catch (Exception ex) { diff --git a/src/StackExchange.Redis/ServerEndPoint.cs b/src/StackExchange.Redis/ServerEndPoint.cs old mode 100644 new mode 100755 index f67c92491..b05366698 --- a/src/StackExchange.Redis/ServerEndPoint.cs +++ b/src/StackExchange.Redis/ServerEndPoint.cs @@ -196,26 +196,32 @@ public void SetClusterConfiguration(ClusterConfiguration configuration) Multiplexer.Trace("Updating cluster ranges..."); Multiplexer.UpdateClusterRange(configuration); Multiplexer.Trace("Resolving genealogy..."); - var thisNode = configuration.Nodes.FirstOrDefault(x => x.EndPoint.Equals(EndPoint)); - if (thisNode != null) + UpdateNodeRelations(configuration); + Multiplexer.Trace("Cluster configured"); + } + } + + public void UpdateNodeRelations(ClusterConfiguration configuration) + { + var thisNode = configuration.Nodes.FirstOrDefault(x => x.EndPoint.Equals(EndPoint)); + if (thisNode != null) + { + Multiplexer.Trace($"Updating node relations for {thisNode.EndPoint.ToString()}..."); + List replicas = null; + ServerEndPoint master = null; + foreach (var node in configuration.Nodes) { - List replicas = null; - ServerEndPoint master = null; - foreach (var node in configuration.Nodes) + if (node.NodeId == thisNode.ParentNodeId) + { + master = Multiplexer.GetServerEndPoint(node.EndPoint); + } + else if (node.ParentNodeId == thisNode.NodeId) { - if (node.NodeId == thisNode.ParentNodeId) - { - master = Multiplexer.GetServerEndPoint(node.EndPoint); - } - else if (node.ParentNodeId == thisNode.NodeId) - { - (replicas ?? (replicas = new List())).Add(Multiplexer.GetServerEndPoint(node.EndPoint)); - } + (replicas ?? (replicas = new List())).Add(Multiplexer.GetServerEndPoint(node.EndPoint)); } - Master = master; - Replicas = replicas?.ToArray() ?? Array.Empty(); } - Multiplexer.Trace("Cluster configured"); + Master = master; + Replicas = replicas?.ToArray() ?? Array.Empty(); } } From 9c8e2147e7d97aed2cd2dda3782ef0d26d01e5aa Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Tue, 15 Jun 2021 13:21:02 -0400 Subject: [PATCH 5/6] Test results in GitHub Actions, we hope (#1767) Adding the test results as a step in GitHub actions for better visibility. --- .github/workflows/CI.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4d9e34502..55df4d94c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -30,7 +30,13 @@ jobs: working-directory: ./tests/RedisConfigs run: docker-compose -f docker-compose.yml up -d - name: StackExchange.Redis.Tests - run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger GitHubActions /p:CI=true + run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger trx --results-directory ./test-results/ /p:CI=true + - uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: StackExchange.Redis.Tests - Results + path: 'test-results/*.trx' + reporter: dotnet-trx - name: .NET Lib Pack run: dotnet pack src/StackExchange.Redis/StackExchange.Redis.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true @@ -56,7 +62,13 @@ jobs: - name: .NET Build run: dotnet build Build.csproj -c Release /p:CI=true - name: NRedisSearch.Tests - run: dotnet test tests/NRediSearch.Test/NRediSearch.Test.csproj -c Release --logger GitHubActions /p:CI=true + run: dotnet test tests/NRediSearch.Test/NRediSearch.Test.csproj -c Release --logger trx --results-directory ./test-results/ /p:CI=true + - uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: NRedisSearch.Tests - Results + path: 'test-results/*.trx' + reporter: dotnet-trx - name: .NET Lib Pack run: dotnet pack src/NRediSearch/NRediSearch.csproj --no-build -c Release /p:Packing=true /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true @@ -97,4 +109,10 @@ jobs: .\redis-server.exe --service-install --service-name "redis-26381" "..\Sentinel\sentinel-26381.conf" --sentinel Start-Service redis-* - name: StackExchange.Redis.Tests - run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger GitHubActions /p:CI=true \ No newline at end of file + run: dotnet test tests/StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj -c Release --logger trx --results-directory ./test-results/ /p:CI=true + - uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: StackExchange.Redis.Tests (Windows Server 2019) - Results + path: 'test-results/*.trx' + reporter: dotnet-trx From d2133cb182844f828d03723c7e1fcfb9b32b9c8b Mon Sep 17 00:00:00 2001 From: Philo Date: Tue, 15 Jun 2021 13:02:40 -0700 Subject: [PATCH 6/6] Add release note for replica refresh fix (#1768) For PR: #1684 --- docs/ReleaseNotes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index dfff1a2aa..da5b32152 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -4,6 +4,7 @@ - performance optimization for PING accuracy (#1714 via eduardobr) - improvement to reconnect logic (exponential backoff) (#1735 via deepakverma) +- refresh replica endpoint list on failover (#1684 by laurauzcategui) ## 2.2.4