From 4f3409c1cb42dd78e65b8f998d231e0c809b51d7 Mon Sep 17 00:00:00 2001 From: Nick Craver Date: Tue, 3 Sep 2024 10:46:38 -0400 Subject: [PATCH] Fix #2778: Run CheckInfoReplication even with HeartbeatConsistencyChecks This is an issue identified in ##2778 and #2779 where we're not updating replication topology if heartbeat consistency checks are enabled because we exit the `if` structure early. This still runs that check if it's due in both cases, without changing the behavior of the result processor. --- src/StackExchange.Redis/PhysicalBridge.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/StackExchange.Redis/PhysicalBridge.cs b/src/StackExchange.Redis/PhysicalBridge.cs index 0755c939e..6cc8aa6f6 100644 --- a/src/StackExchange.Redis/PhysicalBridge.cs +++ b/src/StackExchange.Redis/PhysicalBridge.cs @@ -606,8 +606,8 @@ internal void OnHeartbeat(bool ifConnectedOnly) tmp.BridgeCouldBeNull?.ServerEndPoint?.ClearUnselectable(UnselectableFlags.DidNotRespond); } int timedOutThisHeartbeat = tmp.OnBridgeHeartbeat(); - int writeEverySeconds = ServerEndPoint.WriteEverySeconds, - checkConfigSeconds = ServerEndPoint.ConfigCheckSeconds; + int writeEverySeconds = ServerEndPoint.WriteEverySeconds; + bool configCheckDue = ServerEndPoint.ConfigCheckSeconds > 0 && ServerEndPoint.LastInfoReplicationCheckSecondsAgo >= ServerEndPoint.ConfigCheckSeconds; if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive && tmp.BridgeCouldBeNull?.Multiplexer.RawConfig.HeartbeatConsistencyChecks == true) @@ -617,9 +617,15 @@ internal void OnHeartbeat(bool ifConnectedOnly) // If we don't get the expected response to that command, then the connection is terminated. // This is to prevent the case of things like 100% string command usage where a protocol error isn't otherwise encountered. KeepAlive(forceRun: true); + + // If we're configured to check info replication, perform that too + if (configCheckDue) + { + ServerEndPoint.CheckInfoReplication(); + } } else if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive - && checkConfigSeconds > 0 && ServerEndPoint.LastInfoReplicationCheckSecondsAgo >= checkConfigSeconds + && configCheckDue && ServerEndPoint.CheckInfoReplication()) { // that serves as a keep-alive, if it is accepted