sync-over-async in ConnectionMultiplexer (original) (raw)

Hi,

While I was searching for deadlocks in our UTs projects, I've found multiple 3rd libraries use sync-over-async (anti-)pattern.
One of which was redis.stackexchange

var task = muxer.ReconfigureAsync(first: true, reconfigureAll: false, logProxy, null, "connect");
if (!task.Wait(muxer.SyncConnectTimeout(true)))

It's even a bigger problem considering xUnit is using 2 SynchronizationContexts, even in .NET Core: xunit/xunit#2573
And that ASP.NET Core itself is using blocking apis: dotnet/aspnetcore#43353

Since adding DataProtection is being done on application startup:
public void ConfigureServices(IServiceCollection services), we cannot use the async versions of redis.stackexchange.

For reference, @mgravell's post from 8 years ago about the wonders of sync-over-async... 😉
https://blog.marcgravell.com/2014/03/beware-jamming-thread-pool.html