Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Current package versions:
| [![StackExchange.Redis](https://img.shields.io/nuget/v/StackExchange.Redis.svg)](https://www.nuget.org/packages/StackExchange.Redis/) | [![StackExchange.Redis](https://img.shields.io/nuget/vpre/StackExchange.Redis.svg)](https://www.nuget.org/packages/StackExchange.Redis/) | [![StackExchange.Redis MyGet](https://img.shields.io/myget/stackoverflow/vpre/StackExchange.Redis.svg)](https://www.myget.org/feed/stackoverflow/package/nuget/StackExchange.Redis) |

## Unreleased
- Fix: Respect `IReconnectRetryPolicy` timing in the case that a node that was present disconnects indefinitely ([#2853 by NickCraver](https://github.com/StackExchange/StackExchange.Redis/pull/2853))
- Fix: Respect `IReconnectRetryPolicy` timing in the case that a node that was present disconnects indefinitely ([#2853](https://github.com/StackExchange/StackExchange.Redis/pull/2853) & [#2856](https://github.com/StackExchange/StackExchange.Redis/pull/2856) by NickCraver)
- Changes max default retry policy backoff to 60 seconds ([#2853 by NickCraver](https://github.com/StackExchange/StackExchange.Redis/pull/2853))
- Fix [#2652](https://github.com/StackExchange/StackExchange.Redis/issues/2652): Track client-initiated shutdown for any pipe type ([#2814 by bgrainger](https://github.com/StackExchange/StackExchange.Redis/pull/2814))

Expand Down
12 changes: 8 additions & 4 deletions src/StackExchange.Redis/PhysicalBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,12 @@ internal void OnFullyEstablished(PhysicalConnection connection, string source)
private int connectStartTicks;
private long connectTimeoutRetryCount = 0;

private bool DueForConnectRetry()
{
int connectTimeMilliseconds = unchecked(Environment.TickCount - Thread.VolatileRead(ref connectStartTicks));
return Multiplexer.RawConfig.ReconnectRetryPolicy.ShouldRetry(Interlocked.Read(ref connectTimeoutRetryCount), connectTimeMilliseconds);
}

internal void OnHeartbeat(bool ifConnectedOnly)
{
bool runThisTime = false;
Expand All @@ -575,9 +581,7 @@ internal void OnHeartbeat(bool ifConnectedOnly)
switch (state)
{
case (int)State.Connecting:
int connectTimeMilliseconds = unchecked(Environment.TickCount - Thread.VolatileRead(ref connectStartTicks));
bool shouldRetry = Multiplexer.RawConfig.ReconnectRetryPolicy.ShouldRetry(Interlocked.Read(ref connectTimeoutRetryCount), connectTimeMilliseconds);
if (shouldRetry)
if (DueForConnectRetry())
{
Interlocked.Increment(ref connectTimeoutRetryCount);
var ex = ExceptionFactory.UnableToConnect(Multiplexer, "ConnectTimeout");
Expand Down Expand Up @@ -679,7 +683,7 @@ internal void OnHeartbeat(bool ifConnectedOnly)
shouldResetConnectionRetryCount = false;
Interlocked.Exchange(ref connectTimeoutRetryCount, 0);
}
if (!ifConnectedOnly)
if (!ifConnectedOnly && DueForConnectRetry())
{
Multiplexer.Trace("Resurrecting " + ToString());
Multiplexer.OnResurrecting(ServerEndPoint.EndPoint, ConnectionType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public async Task FastNoticesFailOnConnectingSyncCompletion()
try
{
using var conn = Create(keepAlive: 1, connectTimeout: 10000, allowAdmin: true, shared: false);
conn.RawConfig.ReconnectRetryPolicy = new LinearRetry(200);

var db = conn.GetDatabase();
db.Ping();
Expand Down Expand Up @@ -57,6 +58,7 @@ public async Task FastNoticesFailOnConnectingAsyncCompletion()
try
{
using var conn = Create(keepAlive: 1, connectTimeout: 10000, allowAdmin: true, shared: false);
conn.RawConfig.ReconnectRetryPolicy = new LinearRetry(200);

var db = conn.GetDatabase();
db.Ping();
Expand Down
Loading