Skip to content

Commit b2b4a88

Browse files
authored
Fix #2778: Run CheckInfoReplication even with HeartbeatConsistencyChecks (#2784)
* 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. * Add release notes
1 parent e151cd5 commit b2b4a88

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Current package versions:
1111
- Add support for hash field expiration (see [#2715](https://github.com/StackExchange/StackExchange.Redis/issues/2715)) ([#2716 by atakavci](https://github.com/StackExchange/StackExchange.Redis/pull/2716]))
1212
- Add support for `HSCAN NOVALUES` (see [#2721](https://github.com/StackExchange/StackExchange.Redis/issues/2721)) ([#2722 by atakavci](https://github.com/StackExchange/StackExchange.Redis/pull/2722))
1313
- Fix [#2763](https://github.com/StackExchange/StackExchange.Redis/issues/2763): Make ConnectionMultiplexer.Subscription thread-safe ([#2769 by Chuck-EP](https://github.com/StackExchange/StackExchange.Redis/pull/2769))
14+
- Fix [#2778](https://github.com/StackExchange/StackExchange.Redis/issues/2778): Run `CheckInfoReplication` even with `HeartbeatConsistencyChecks` ([#2784 by NickCraver and leachdaniel-clark](https://github.com/StackExchange/StackExchange.Redis/pull/2784))
1415

1516
## 2.8.0
1617

src/StackExchange.Redis/PhysicalBridge.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ internal void OnHeartbeat(bool ifConnectedOnly)
606606
tmp.BridgeCouldBeNull?.ServerEndPoint?.ClearUnselectable(UnselectableFlags.DidNotRespond);
607607
}
608608
int timedOutThisHeartbeat = tmp.OnBridgeHeartbeat();
609-
int writeEverySeconds = ServerEndPoint.WriteEverySeconds,
610-
checkConfigSeconds = ServerEndPoint.ConfigCheckSeconds;
609+
int writeEverySeconds = ServerEndPoint.WriteEverySeconds;
610+
bool configCheckDue = ServerEndPoint.ConfigCheckSeconds > 0 && ServerEndPoint.LastInfoReplicationCheckSecondsAgo >= ServerEndPoint.ConfigCheckSeconds;
611611

612612
if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive
613613
&& tmp.BridgeCouldBeNull?.Multiplexer.RawConfig.HeartbeatConsistencyChecks == true)
@@ -617,9 +617,15 @@ internal void OnHeartbeat(bool ifConnectedOnly)
617617
// If we don't get the expected response to that command, then the connection is terminated.
618618
// This is to prevent the case of things like 100% string command usage where a protocol error isn't otherwise encountered.
619619
KeepAlive(forceRun: true);
620+
621+
// If we're configured to check info replication, perform that too
622+
if (configCheckDue)
623+
{
624+
ServerEndPoint.CheckInfoReplication();
625+
}
620626
}
621627
else if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive
622-
&& checkConfigSeconds > 0 && ServerEndPoint.LastInfoReplicationCheckSecondsAgo >= checkConfigSeconds
628+
&& configCheckDue
623629
&& ServerEndPoint.CheckInfoReplication())
624630
{
625631
// that serves as a keep-alive, if it is accepted

0 commit comments

Comments
 (0)