Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoConfigure detects protocol failure HeartBeats allow ReplicaReconfig #2779

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/StackExchange.Redis/PhysicalBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,20 +610,20 @@ internal void OnHeartbeat(bool ifConnectedOnly)
checkConfigSeconds = ServerEndPoint.ConfigCheckSeconds;

if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive
&& tmp.BridgeCouldBeNull?.Multiplexer.RawConfig.HeartbeatConsistencyChecks == true)
&& checkConfigSeconds > 0 && ServerEndPoint.LastInfoReplicationCheckSecondsAgo >= checkConfigSeconds
&& ServerEndPoint.CheckInfoReplication())
{
// that serves as a keep-alive, if it is accepted
}
else if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive
&& tmp.BridgeCouldBeNull?.Multiplexer.RawConfig.HeartbeatConsistencyChecks == true)
{
// If HeartbeatConsistencyChecks are enabled, we're sending a PING (expecting PONG) or ECHO (expecting UniqueID back) every single
// heartbeat as an opt-in measure to react to any network stream drop ASAP to terminate the connection as faulted.
// 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);
}
else if (state == (int)State.ConnectedEstablished && ConnectionType == ConnectionType.Interactive
&& checkConfigSeconds > 0 && ServerEndPoint.LastInfoReplicationCheckSecondsAgo >= checkConfigSeconds
&& ServerEndPoint.CheckInfoReplication())
{
// that serves as a keep-alive, if it is accepted
}
else if (writeEverySeconds > 0 && tmp.LastWriteSecondsAgo >= writeEverySeconds)
{
Trace("OnHeartbeat - overdue");
Expand Down
13 changes: 12 additions & 1 deletion src/StackExchange.Redis/ResultProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,20 @@ public override bool SetResult(PhysicalConnection connection, Message message, i
Log?.LogInformation($"{Format.ToString(server)}: Auto-configured role: replica");
server.IsReplica = true;
}

return base.SetResult(connection, message, result);
}

return base.SetResult(connection, message, result);
var success = base.SetResult(connection, message, result);

if (!success && connection.BridgeCouldBeNull?.IsConnected == true)
{
connection.RecordConnectionFailed(
ConnectionFailureType.ProtocolFailure,
new InvalidOperationException($"unexpected auto-configure reply to {message.Command}: {result.ToString()}"));
}

return success;
}

protected override bool SetResultCore(PhysicalConnection connection, Message message, in RawResult result)
Expand Down
Loading