Skip to content

Make SignalR Redis test thread-safe - #41564

Merged
BrennanConroy merged 1 commit into
mainfrom
brecon/redist
May 21, 2022
Merged

BrennanConroy merged 1 commit into
mainfrom
brecon/redist

Conversation

@BrennanConroy

Copy link
Copy Markdown
Member

TestServer could shut down right after the first handler in

foreach (var (_, handler) in handlers)
{
    handler(channel, message);
}

is invoked, which creates a race with the second iteration of the loop checking for another item in the list while the list is cleared by the TestServer closing.

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label May 6, 2022
@BrennanConroy
BrennanConroy requested a review from halter73 as a code owner May 6, 2022 22:57
@BrennanConroy
BrennanConroy requested review from halter73 and removed request for halter73 May 20, 2022 15:53
@halter73

Copy link
Copy Markdown
Member

It took me a while to find a sample failure.

Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests.RedisHubLifetimeManagerTests.ClientDisconnectsWithoutCompletingClientResultOnSecondServer
Assert.Throws() Failure
Expected: typeof(System.Exception)
Actual:   typeof(System.InvalidOperationException): Collection was modified; enumeration operation may not execute.
---- System.InvalidOperationException : Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at Microsoft.AspNetCore.SignalR.Tests.TestRedisServer.Publish(RedisChannel channel, RedisValue message, CommandFlags flags) in /_/src/SignalR/server/StackExchangeRedis/test/TestConnectionMultiplexer.cs:line 235
   at Microsoft.AspNetCore.SignalR.Tests.TestSubscriber.Publish(RedisChannel channel, RedisValue message, CommandFlags flags) in /_/src/SignalR/server/StackExchangeRedis/test/TestConnectionMultiplexer.cs:line 313
   at Microsoft.AspNetCore.SignalR.Tests.TestSubscriber.PublishAsync(RedisChannel channel, RedisValue message, CommandFlags flags) in /_/src/SignalR/server/StackExchangeRedis/test/TestConnectionMultiplexer.cs:line 319
   at Microsoft.AspNetCore.SignalR.StackExchangeRedis.RedisHubLifetimeManager`1.PublishAsync(String channel, Byte[] payload) in /_/src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs:line 320
   at Microsoft.AspNetCore.SignalR.StackExchangeRedis.RedisHubLifetimeManager`1.InvokeConnectionAsync[T](String connectionId, String methodName, Object[] args, CancellationToken cancellationToken) in /_/src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs:line 422

https://dev.azure.com/dnceng/public/_test/analytics?definitionId=278&contextType=build

@BrennanConroy

Copy link
Copy Markdown
Member Author

It took me a while to find a sample failure.

Whoops, sorry

@BrennanConroy
BrennanConroy merged commit 4c922a8 into main May 21, 2022
@BrennanConroy
BrennanConroy deleted the brecon/redist branch May 21, 2022 03:23
@ghost ghost added this to the 7.0-preview5 milestone May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants