Fix race condition in Sentinel connection multiplexer by ewisuri · Pull Request #2133 · StackExchange/StackExchange.Redis
Expand Up
@@ -331,7 +331,15 @@ internal void OnManagedConnectionFailed(object? sender, ConnectionFailedEventArg
}
finally
{
connection.sentinelPrimaryReconnectTimer?.Change(TimeSpan.FromSeconds(1), Timeout.InfiniteTimeSpan);
try
{
connection.sentinelPrimaryReconnectTimer?.Change(TimeSpan.FromSeconds(1), Timeout.InfiniteTimeSpan);
}
catch (ObjectDisposedException)
{
// If we get here the managed connection was restored and the timer was
// disposed by another thread, so there's no need to run the timer again.
}
}
}, null, TimeSpan.Zero, Timeout.InfiniteTimeSpan);
}
Expand Down