dadhi / DryIoc

DryIoc is fast, small, full-featured IoC Container for .NET
MIT License
1.02k stars 123 forks source link

DryIoc 4.0.5 withoutFastExpressionCompiler deadlock issue #157

Closed Havunen closed 5 years ago

Havunen commented 5 years ago

Hi,

We have an issue with DryIoc where development server gets stuck sometimes on application startup or quickly after it. We are now constructing Container withoutFastExpressionCompiler so that is not the cause here.

We have finally successfully created memory dump from the w3wp process when it got stuck. 54% of threads are blocked by thread-51 which is not resolved.

image

Thread 51

.NET Call Stack

[[PrestubMethodFrame] (App.Rest.API.RestApiIocModule+_Closure$__._Lambda$__6-3)] App.Rest.API.RestApiIocModule+_Closure$__._Lambda$__6-3(DryIoc.IResolverContext) 
App_IoC!DryIoc.Registrator.ToFactoryDelegate[[System.__Canon, mscorlib]](System.Func`2, DryIoc.IResolverContext)+14 
App_IoC!DryIoc.Interpreter.TryInterpret(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Object ByRef)+9b2 
App_IoC!DryIoc.Interpreter.TryInterpret(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Object ByRef)+56e 
App_IoC!DryIoc.Interpreter.TryInterpretAndUnwrapContainerException(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Object ByRef)+18 
App_IoC!DryIoc.Factory+<>c.b__33_2(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean)+2b 
App_IoC!DryIoc.Scope.TryGetOrAddWithoutClosure(Int32, DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Func`4, Int32)+119 
App_IoC!DryIoc.Factory.ApplyReuse(FastExpressionCompiler.LightExpression.Expression, DryIoc.Request)+271 
App_IoC!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request)+2ae 
App_IoC!DryIoc.ReflectionFactory.TryResolveParameterExpressions(System.Reflection.ParameterInfo[], System.Func`2, DryIoc.Request, Int32 ByRef)+66f 
App_IoC!DryIoc.ReflectionFactory.CreateExpressionOrDefault(DryIoc.Request)+23a 
App_IoC!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request)+248 
App_IoC!DryIoc.ReflectionFactory.TryResolveParameterExpressions(System.Reflection.ParameterInfo[], System.Func`2, DryIoc.Request, Int32 ByRef)+66f 
App_IoC!DryIoc.ReflectionFactory.CreateExpressionOrDefault(DryIoc.Request)+23a 
App_IoC!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request)+248 
App_IoC!DryIoc.Container.DryIoc.IResolver.Resolve(System.Type, System.Object, DryIoc.IfUnresolved, System.Type, DryIoc.Request, System.Object[])+5a6 
App_IoC!DryIoc.Container.ResolveAndCacheFactoryDelegate(System.Type, DryIoc.IfUnresolved)+12a 
System_Web_Http!System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(System.Net.Http.HttpRequestMessage, System.Type, System.Func`1 ByRef)+26 
System_Web_Http!System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(System.Net.Http.HttpRequestMessage, System.Web.Http.Controllers.HttpControllerDescriptor, System.Type)+60 
System_Web_Http!System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15.MoveNext()+12d 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15, System.Web.Http]](d__15 ByRef)+7a 
System_Web_Http!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83 
System_Net_Http!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64 
System_Web_Http!System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+257 
System_Net_Http!System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 
App_IoC!DryIoc.WebApi.RegisterRequestMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+29 
System_Net_Http!System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 
System_Web_Http!System.Web.Http.HttpServer+d__24.MoveNext()+18c 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+d__24, System.Web.Http]](d__24 ByRef)+7a 
System_Web_Http!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83 
System_Net_Http!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64 
System_Web_Http_Owin!System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20.MoveNext()+25a 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20, System.Web.Http.Owin]](d__20 ByRef)+80 
System_Web_Http_Owin!System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse)+7b 
Microsoft_Owin_Security!Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]].MoveNext()+229 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]], Microsoft.Owin.Security]](d__5 ByRef)+a4 
Microsoft_Owin_Security!Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[[System.__Canon, mscorlib]].Invoke(Microsoft.Owin.IOwinContext)+9e 
Microsoft_Owin_Host_SystemWeb!Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7.MoveNext()+3c 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7, Microsoft.Owin.Host.SystemWeb]](d__7 ByRef)+80 
Microsoft_Owin_Host_SystemWeb!Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func`2,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary`2, System.Threading.Tasks.TaskCompletionSource`1, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)+80 
Microsoft_Owin_Host_SystemWeb!Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)+266 
System_Web!System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+182 
System_Web!System.Web.HttpApplication+<>c__DisplayClass285_0.b__0()+25 
System_Web!System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep)+9b 
System_Web!System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+83 
System_Web!System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+74d 
System_Web!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+83 
System_Web!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+1e2 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+441 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 
System_Web!DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 
System_Web!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+7e 
[[InlinedCallFrame] (System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion)] System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatusByRef) 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+504 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 
System_Web!DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 
[[ContextTransitionFrame]] 

Full call stack


ntdll!NtWaitForAlertByThreadId+14 
ntdll!RtlpWaitOnAddressWithTimeout+43 
ntdll!RtlpWaitOnAddress+b2 
ntdll!RtlpWaitOnCriticalSection+db 
ntdll!RtlpEnterCriticalSectionContended+cc 
ntdll!RtlEnterCriticalSection+40 
clr!CrstBase::SpinEnter+ac 
clr!CrstBase::Enter+10d 
clr!ListLockEntry::LockHolder::DeadlockAwareAcquire+4b 
clr!MethodTable::DoRunClassInitThrowing+1be 
clr!MethodTable::CheckRunClassInitThrowing+a3 
clr!CEEInfo::initClass+747 
clrjit!Compiler::impInitClass+50 
clrjit!Compiler::impImportBlockCode+4bdc 
clrjit!Compiler::impImportBlock+7d 
clrjit!Compiler::impImport+2f7 
clrjit!Compiler::compCompile+99 
clrjit!Compiler::compCompileHelper+2a7 
clrjit!Compiler::compCompile+24b 
clrjit!jitNativeCode+26a 
clrjit!CILJit::compileMethod+a2 
clr!invokeCompileMethodHelper+ce 
clr!invokeCompileMethod+97 
clr!CallCompileMethodWithSEHWrapper+52 
clr!UnsafeJitFunction+7ea 
clr!MethodDesc::MakeJitWorker+498 
clr!MethodDesc::DoPrestub+94c 
clr!PreStubWorker+3cc 
clr!ThePreStub+55 
App_IoC!DryIoc.Registrator.ToFactoryDelegate[[System.__Canon, mscorlib]](System.Func`2<DryIoc.IResolverContext,System.__Canon>, DryIoc.IResolverContext)+14 
App_IoC!DryIoc.Interpreter.TryInterpret(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Object ByRef)+9b2 
App_IoC!DryIoc.Interpreter.TryInterpret(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Object ByRef)+56e 
App_IoC!DryIoc.Interpreter.TryInterpretAndUnwrapContainerException(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Object ByRef)+18 
App_IoC!DryIoc.Factory+<>c.<ApplyReuse>b__33_2(DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean)+2b 
App_IoC!DryIoc.Scope.TryGetOrAddWithoutClosure(Int32, DryIoc.IResolverContext, FastExpressionCompiler.LightExpression.Expression, Boolean, System.Func`4<DryIoc.IResolverContext,FastExpressionCompiler.LightExpression.Expression,Boolean,System.Object>, Int32)+119 
App_IoC!DryIoc.Factory.ApplyReuse(FastExpressionCompiler.LightExpression.Expression, DryIoc.Request)+271 
App_IoC!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request)+2ae 
App_IoC!DryIoc.ReflectionFactory.TryResolveParameterExpressions(System.Reflection.ParameterInfo[], System.Func`2<System.Reflection.ParameterInfo,DryIoc.ParameterServiceInfo>, DryIoc.Request, Int32 ByRef)+66f 
App_IoC!DryIoc.ReflectionFactory.CreateExpressionOrDefault(DryIoc.Request)+23a 
App_IoC!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request)+248 
App_IoC!DryIoc.ReflectionFactory.TryResolveParameterExpressions(System.Reflection.ParameterInfo[], System.Func`2<System.Reflection.ParameterInfo,DryIoc.ParameterServiceInfo>, DryIoc.Request, Int32 ByRef)+66f 
App_IoC!DryIoc.ReflectionFactory.CreateExpressionOrDefault(DryIoc.Request)+23a 
App_IoC!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request)+248 
App_IoC!DryIoc.Container.DryIoc.IResolver.Resolve(System.Type, System.Object, DryIoc.IfUnresolved, System.Type, DryIoc.Request, System.Object[])+5a6 
App_IoC!DryIoc.Container.ResolveAndCacheFactoryDelegate(System.Type, DryIoc.IfUnresolved)+12a 
System_Web_Http!System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(System.Net.Http.HttpRequestMessage, System.Type, System.Func`1<System.Web.Http.Controllers.IHttpController> ByRef)+26 
System_Web_Http!System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(System.Net.Http.HttpRequestMessage, System.Web.Http.Controllers.HttpControllerDescriptor, System.Type)+60 
System_Web_Http!System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15.MoveNext()+12d 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15, System.Web.Http]](<SendAsync>d__15 ByRef)+7a 
System_Web_Http!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83 
System_Net_Http!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64 
System_Web_Http!System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+257 
System_Net_Http!System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 
App_IoC!DryIoc.WebApi.RegisterRequestMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+29 
System_Net_Http!System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 
System_Web_Http!System.Web.Http.HttpServer+<SendAsync>d__24.MoveNext()+18c 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+<SendAsync>d__24, System.Web.Http]](<SendAsync>d__24 ByRef)+7a 
System_Web_Http!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83 
System_Net_Http!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64 
System_Web_Http_Owin!System.Web.Http.Owin.HttpMessageHandlerAdapter+<InvokeCore>d__20.MoveNext()+25a 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+<InvokeCore>d__20, System.Web.Http.Owin]](<InvokeCore>d__20 ByRef)+80 
System_Web_Http_Owin!System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse)+7b 
Microsoft_Owin_Security!Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+<Invoke>d__5[[System.__Canon, mscorlib]].MoveNext()+229 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+<Invoke>d__5[[System.__Canon, mscorlib]], Microsoft.Owin.Security]](<Invoke>d__5<System.__Canon> ByRef)+a4 
Microsoft_Owin_Security!Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[[System.__Canon, mscorlib]].Invoke(Microsoft.Owin.IOwinContext)+9e 
Microsoft_Owin_Host_SystemWeb!Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+<RunApp>d__7.MoveNext()+3c 
mscorlib_ni!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+<RunApp>d__7, Microsoft.Owin.Host.SystemWeb]](<RunApp>d__7 ByRef)+80 
Microsoft_Owin_Host_SystemWeb!Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func`2<System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary`2<System.String,System.Object>, System.Threading.Tasks.TaskCompletionSource`1<System.Object>, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)+80 
Microsoft_Owin_Host_SystemWeb!Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)+266 
System_Web!System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+182 
System_Web!System.Web.HttpApplication+<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()+25 
System_Web!System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep)+9b 
System_Web!System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+83 
System_Web!System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+74d 
System_Web!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+83 
System_Web!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+1e2 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+441 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 
System_Web!DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 
clr!UMThunkStub+6e 
webengine4!W3_MGD_HANDLER::ProcessNotification+8e 
webengine4!W3_MGD_HANDLER::DoWork+3a5 
webengine4!RequestDoWork+3fc 
webengine4!CMgdEngHttpModule::OnAcquireRequestState+1f 
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+b9 
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+19c 
iiscore!NOTIFICATION_CONTEXT::CallModules+36 
iiscore!NOTIFICATION_MAIN::DoWork+1cf 
iiscore!W3_CONTEXT_BASE::IndicateCompletion+d6 
webengine4!W3_MGD_HANDLER::IndicateCompletion+5d 
webengine4!MgdIndicateCompletion+22 
System_Web!DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+7e 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+504 
System_Web!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 
System_Web!DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 
clr!UM2MThunk_WrapperHelper+43 
clr!UM2MThunk_Wrapper+60 
clr!Thread::DoADCallBack+13d 
clr!UM2MDoADCallBack+b3 
clr!UMThunkStub+26d 
webengine4!W3_MGD_HANDLER::ProcessNotification+8e 
webengine4!ProcessNotificationCallback+42 
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem+1bc 
clr!ThreadpoolMgr::ExecuteWorkRequest+64 
clr!ThreadpoolMgr::WorkerThreadStart+f5 
clr!Thread::intermediateThreadProc+86 
kernel32!BaseThreadInitThunk+14 
ntdll!RtlUserThreadStart+21 

The current work around to this problem is restarting application pool. And then it magically solves the problem. I will try to reproduce this in LoadTest.

Havunen commented 5 years ago

Ok. I have reproduced this issue in v4.0.5. The thing is there is no error, no stack overflow. But it seems it never ends, it uses 32GB ram on my computer and then starts using Disk as RAM until your computer is so stuck that nothing works.

Havunen commented 5 years ago

In master branch things seem little different. Memory usage is not increasing, but threads are sleep waiting each other.

Havunen commented 5 years ago

I think this bug (the current state in master branch) happens because of new lock scaling system. The id which is generated for type (factoryID) shouldn't it be so that its same one id per one full resolution chain? Scaling from smallest resolution to bigger? Now what happens is that all threads wait some other thread to finish because lock-ID changes and they conflict.

dadhi commented 5 years ago

The id which is generated for type (factoryID) shouldn't it be so that its same one id per one full resolution chain?

Not sure I am following. The FactoryID is assigned when the factory is created / registered and doesn't change since then.

Havunen commented 5 years ago

Yes, If I understood the code correctly, that factory object needs another factories to be able to complete the full resolve request. Now these factories depend on each other and their ID is incremented when its registered. This factory Id is also used for lock scaling, which will result into deadlock, because they wait each other to finish.

One idea to make this bullet-proof is to scale the locks based on dependency tree of service so it locks it until it has fully resolved the service type. And then increment the lock id based on these dependency trees. This way one thread can always finish its job, or the thread which is running can finish its job to free the one waiting.

Edit: However I'm not sure if this would work in case of circular dependencies

Havunen commented 5 years ago

This issue seems to have disappeared, its no longer reproducible in master branch / Release 4.1.0-preview-01. I think we can close this issue, maybe the PR could be merged anyway because it expands the load test.