-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #2392: Dequeue all timed out messages from the backlog when not c…
…onnected, even when no completion is needed, to be able to dequeue and complete other timed out messages. (#2397) When the client is not connected timed out fire and forget messages currently are not removed from the backlog that also results in subsequent timed out messages not being marked as timed out, as described in #2392.
- Loading branch information
Showing
3 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace StackExchange.Redis.Tests.Issues | ||
{ | ||
public class Issue2392Tests : TestBase | ||
{ | ||
public Issue2392Tests(ITestOutputHelper output) : base(output) { } | ||
|
||
[Fact] | ||
public async Task Execute() | ||
{ | ||
var options = new ConfigurationOptions() | ||
{ | ||
BacklogPolicy = new() | ||
{ | ||
QueueWhileDisconnected = true, | ||
AbortPendingOnConnectionFailure = false, | ||
}, | ||
AbortOnConnectFail = false, | ||
ConnectTimeout = 1, | ||
ConnectRetry = 0, | ||
AsyncTimeout = 1, | ||
SyncTimeout = 1, | ||
AllowAdmin = true, | ||
}; | ||
options.EndPoints.Add("127.0.0.1:1234"); | ||
|
||
using var conn = await ConnectionMultiplexer.ConnectAsync(options, Writer); | ||
var key = Me(); | ||
var db = conn.GetDatabase(); | ||
var server = conn.GetServerSnapshot()[0]; | ||
|
||
// Fail the connection | ||
conn.AllowConnect = false; | ||
server.SimulateConnectionFailure(SimulatedFailureType.All); | ||
Assert.False(conn.IsConnected); | ||
|
||
await db.StringGetAsync(key, flags: CommandFlags.FireAndForget); | ||
var ex = await Assert.ThrowsAnyAsync<Exception>(() => db.StringGetAsync(key).WithTimeout(5000)); | ||
Assert.True(ex is RedisTimeoutException or RedisConnectionException); | ||
} | ||
} | ||
} |