This repository was archived by the owner on Oct 17, 2018. It is now read-only.
This repository was archived by the owner on Oct 17, 2018. It is now read-only.
KeyRingProvider initialization causes thread pool starvation when server starts under load #233
Closed
Description
my application give me frequent
asp.net core 1.1.2 behind load balancer iis arr3
HTTP Error 502.3 - Bad Gateway
The specified CGI application encountered an error and the server terminated the process.
i made a dump file and inspected it using windbg i encountered the following lines. it's like all thread are waiting for keymanagement
could you please take a look at it my app crashes frequently and its a high traffic website
any help would be appreciated
0000001c6f67d5e8 00007ffa506f6c24 [GCFrame: 0000001c6f67d5e8]
0000001c6f67d838 00007ffa506f6c24 [GCFrame: 0000001c6f67d838]
0000001c6f67d878 00007ffa506f6c24 [HelperMethodFrame_1OBJ: 0000001c6f67d878] System.Threading.Monitor.ReliableEnterTimeout(System.Object, Int32, Boolean ByRef)
0000001c6f67d9a0 00007ff9bdcbd2fd Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(System.DateTime)
0000001c6f67da50 00007ff9bdcbc5a1 Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[])
0000001c6f67db10 00007ff9bdcbb839 Microsoft.AspNetCore.Session.CookieProtection.Protect(Microsoft.AspNetCore.DataProtection.IDataProtector, System.String)
0000001c6f67db40 00007ff9bdcb7966 Microsoft.AspNetCore.Session.SessionMiddleware+d__9.MoveNext()
0000001c6f67dbd0 00007ff9bdcb6d45 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Session.SessionMiddleware+d__9, Microsoft.AspNetCore.Session]](d__9 ByRef)
0000001c6f67dc30 00007ff9bdcb6cc9 Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
0000001c6f67dce0 00007ff9bdcb30f9 Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext()
0000001c6f67dd40 00007ff9bdcb2a95 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Builder.RouterMiddleware+d__4, Microsoft.AspNetCore.Routing]](d__4 ByRef)
0000001c6f67dda0 00007ff9bdcb2a19 Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
0000001c6f67de50 00007ff9bdcb2563 Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+d__6.MoveNext()
0000001c6f67def0 00007ff9bdcb2105 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+d__6, Microsoft.AspNetCore.Diagnostics]](d__6 ByRef)
0000001c6f67df50 00007ff9bdcb208f Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
0000001c6f67e010 00007ff9bdcb1b7a Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware+d__3.MoveNext()
0000001c6f67e080 00007ff9bdcb1a25 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware+d__3, Microsoft.AspNetCore.Diagnostics]](d__3 ByRef)
0000001c6f67e0e0 00007ff9bdcb19a9 Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
0000001c6f67e190 00007ff9bdcb0b35 Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware+d__8.MoveNext()
0000001c6f67e280 00007ff9bdcafec5 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware+d__8, Microsoft.AspNetCore.Server.IISIntegration]](d__8 ByRef)
0000001c6f67e2e0 00007ff9bdcafe49 Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
0000001c6f67e390 00007ff9bdca9ed5 Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware+d__3.MoveNext()
0000001c6f67e3e0 00007ff9bdca9c35 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware+d__3, Microsoft.AspNetCore.Hosting]](d__3 ByRef)
0000001c6f67e440 00007ff9bdca9bb9 Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
0000001c6f67e4f0 00007ff9bdca9b12 Microsoft.AspNetCore.Hosting.Internal.HostingApplication.ProcessRequestAsync(Context)
0000001c6f67e520 00007ff9bdc8e13e Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1+d__2[[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context, Microsoft.AspNetCore.Hosting]].MoveNext()
0000001c6f67e620 00007ff9bdc87275 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1+d__2[[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context, Microsoft.AspNetCore.Hosting]], Microsoft.AspNetCore.Server.Kestrel]](d__2 ByRef)
0000001c6f67e680 00007ff9bdc8719d Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1[[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context, Microsoft.AspNetCore.Hosting]].RequestProcessingAsync()
0000001c6f67e770 00007ffa191676b5 System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib]].InnerInvoke()
0000001c6f67e7c0 00007ffa19135a26 System.Threading.Tasks.Task.Execute()
0000001c6f67e800 00007ffa190d16ee System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
0000001c6f67e870 00007ffa19135f93 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
0000001c6f67e920 00007ffa19135d2f System.Threading.Tasks.Task.ExecuteEntry(Boolean)
0000001c6f67e960 00007ffa191966bc System.Threading.ThreadPoolWorkQueue.Dispatch()
@blowdart @natemcmaster @shanselman
it may be related to #228
the way i initialized redis at startup is :
{
var redis = RedisConnectionManager.SafeCoonect;
services
.AddDataProtection()
.SetApplicationName("xxxxxx")
.PersistKeysToRedis(redis, "xxxzzzz"
return services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromHours(12);
options.CookieName = "m";
});
}
and safeconnect
is
private static Lazy<ConfigurationOptions> configOptions
= new Lazy<ConfigurationOptions>(() =>
{
var configOptions = new ConfigurationOptions();
configOptions.EndPoints.Add("xxx.xxx.xxx.xxxx:6379");
configOptions.SyncTimeout = 4000;
configOptions.AbortOnConnectFail = false;
return configOptions;
});
private static readonly Lazy<ConnectionMultiplexer> LazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
var connection = ConnectionMultiplexer.Connect(configOptions.Value);
connection.PreserveAsyncOrder = false;
return connection;
});
public static ConnectionMultiplexer SafeCoonect
{
get
{
return LazyConnection.Value;
}
}