Commit 09f9d8ab authored by Marc Gravell's avatar Marc Gravell

Avoid overlapped per-endpoint heartbeats and heartbeat error reports; we don't want them backing up

parent d881e28c
...@@ -970,6 +970,8 @@ private ConnectionMultiplexer(ConfigurationOptions configuration) ...@@ -970,6 +970,8 @@ private ConnectionMultiplexer(ConfigurationOptions configuration)
{ {
((ConnectionMultiplexer)state).OnHeartbeat(); ((ConnectionMultiplexer)state).OnHeartbeat();
}; };
private int _activeHeartbeatErrors;
private void OnHeartbeat() private void OnHeartbeat()
{ {
try try
...@@ -982,9 +984,20 @@ private void OnHeartbeat() ...@@ -982,9 +984,20 @@ private void OnHeartbeat()
var tmp = serverSnapshot; var tmp = serverSnapshot;
for (int i = 0; i < tmp.Length; i++) for (int i = 0; i < tmp.Length; i++)
tmp[i].OnHeartbeat(); tmp[i].OnHeartbeat();
} catch(Exception ex) }
catch (Exception ex)
{ {
OnInternalError(ex); if (Interlocked.CompareExchange(ref _activeHeartbeatErrors, 1, 0) == 0)
{
try
{
OnInternalError(ex);
}
finally
{
Interlocked.Exchange(ref _activeHeartbeatErrors, 0);
}
}
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StackExchange.Redis namespace StackExchange.Redis
...@@ -531,17 +532,28 @@ internal bool CheckInfoReplication() ...@@ -531,17 +532,28 @@ internal bool CheckInfoReplication()
} }
private int lastInfoReplicationCheckTicks; private int lastInfoReplicationCheckTicks;
private int _heartBeatActive;
internal void OnHeartbeat() internal void OnHeartbeat()
{ {
try // don't overlap operations on an endpoint
{ if (Interlocked.CompareExchange(ref _heartBeatActive, 1, 0) == 0)
interactive?.OnHeartbeat(false);
subscription?.OnHeartbeat(false);
} catch(Exception ex)
{ {
multiplexer.OnInternalError(ex, EndPoint); try
} {
interactive?.OnHeartbeat(false);
subscription?.OnHeartbeat(false);
}
catch (Exception ex)
{
multiplexer.OnInternalError(ex, EndPoint);
}
finally
{
Interlocked.Exchange(ref _heartBeatActive, 0);
}
}
} }
internal Task<T> QueueDirectAsync<T>(Message message, ResultProcessor<T> processor, object asyncState = null, PhysicalBridge bridge = null) internal Task<T> QueueDirectAsync<T>(Message message, ResultProcessor<T> processor, object asyncState = null, PhysicalBridge bridge = null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment