2013-03-08 3 views
4

저는 Autofac 사용자이므로 매우 골치 아픈 문제에 직면 해 있습니다. 나는이 질문에 Alex Alex와 Travis에게 질문을 받았으며 그들의 답장을 받았다. 그들의 도움에 감사한다. 이 문제를 철저히 확인하기 위해 Travis의 권장 사항을 수락했으며 여기에 세부 정보를 게시했습니다.Autofac으로 인한 교활한 IIS 교착 상태가 발생했습니다.

내 이메일 :

우리는 mvc3 프로젝트에 Autofac 2.6.3.862 사용합니다.

이제 우리는 IIS 교착 상태 문제에 와서는 심각한 종종 매달려, 우리는 마이크로 소프트 디버그 진단 도구 사용했던 서버는 처음 자물쇠로 을 의심, (분석 보고서를 둘러싸 리드)를 분석을 수행하는 LifetimeScope에서

나는 당신의 기사를 읽었지만, 기술적 세부 사항 중 일부는 막연하게 에 있습니다.() 구성 요소가 그래서 내가 사용과 같은 AA 아이의 평생 범위를 사용하지 않습니다() 해결 (VAR 범위는 = Container.BeginLifetimeScope는())

, 이것은인지 모를 때, SingleInstance 우리의 회원 가입의 대부분 교착 상태의 이유.

디버그 진단 분석 보고서

The following threads in 
w3wp.exe__hg__PID__3904__Date__03_07_2013__Time_11_01_07AM__974__Manual Dump.dmp are waiting to enter a .NET Lock which thread 39 is currently holding  
(26 34 42 43 44 45 46 47 48)  
16.67% of threads blocked  

====================================================================================== 

Detected possible blocking or leaked critical section at 0x0e758a00 owned by thread 26 in w3wp.exe__hg__PID__3904__Date__03_07_2013__Time_11_01_07AM__974__Manual Dump.dmp 

Impact of this lock  
1.85% of threads blocked 

(Threads 39) 

The following functions are trying to enter this critical section 

clr!UnsafeEEEnterCriticalSection+1c  

The following module(s) are involved with this critical section 

C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll 

====================================================================================== 

Thread 26 - System ID 7628 
Entry point 0x00000000 
Create time 2013/3/7 10:44:15 
Time spent in user mode 0 Days 00:00:00.218 
Time spent in kernel mode 0 Days 00:00:00.343 




This thread is waiting to enter a .NET Lock which thread 39 is currently holding 



.NET Call Stack 



Function 
System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef) 
System.Threading.Monitor.Enter(System.Object, Boolean ByRef) 
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Container.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1, System.Object ByRef) 
Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1) 
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext) 
Tunynet.DIContainer.Resolve[[System.__Canon, mscorlib]]() 
Spacebuilder.Common.ProfileRepository..cctor() 
Spacebuilder.Common.ProfileRepository..ctor() 
Spacebuilder.Common.UserProfileService..ctor() 
Spacebuilder.Common.User.get_Profile() 
ASP._Page_Themes_Channel_Default_Views_FindUser__QuickSearch_cshtml.Execute() 
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() 
Tunynet.UI.ThemedWebViewPage.ExecutePageHierarchy() 
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext, System.IO.TextWriter, System.Web.WebPages.WebPageRenderingBase) 
Tunynet.UI.ThemedRazorView.RenderView(System.Web.Mvc.ViewContext, System.IO.TextWriter, System.Object) 
System.Web.Mvc.BuildManagerCompiledView.Render(System.Web.Mvc.ViewContext, System.IO.TextWriter) 
System.Web.Mvc.ViewResultBase.ExecuteResult(System.Web.Mvc.ControllerContext) 
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionResult) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.b__19() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(System.Web.Mvc.ControllerContext, System.Collections.Generic.IList`1, System.Web.Mvc.ActionResult) 
System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String) 
System.Web.Mvc.Controller.ExecuteCore() 
System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext) 
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(System.Web.Routing.RequestContext) 
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.b__5() 
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.b__0() 
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass8`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].b__7(System.IAsyncResult) 
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].End() 
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.b__d() 
System.Web.Mvc.SecurityUtil.b__0(System.Action) 
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(System.Action) 
System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult) 
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(System.IAsyncResult) 
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception) 
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback) 
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32) 
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef) 
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32) 


Full Call Stack 



Function Source 
ntdll!KiFastSystemCallRet  
ntdll!NtWaitForMultipleObjects+c  
KERNELBASE!WaitForMultipleObjectsEx+100  
kernel32!WaitForMultipleObjectsExImplementation+e0  
clr!WaitForMultipleObjectsEx_SO_TOLERANT+56  
clr!Thread::DoAppropriateAptStateWait+4d  
clr!Thread::DoAppropriateWaitWorker+17d  
clr!Thread::DoAppropriateWait+60  
clr!CLREvent::WaitEx+106  
clr!CLREvent::Wait+19  
clr!AwareLock::EnterEpilogHelper+a8  
clr!AwareLock::EnterEpilog+42  
clr!AwareLock::Enter+5f  
clr!AwareLock::Contention+228  
clr!JITutil_MonReliableContention+e8  
System.Threading.Monitor.Enter(System.Object, Boolean ByRef)  
clr!CallDescrWorker+33  
clr!CallDescrWorkerWithHandler+8e  
clr!DispatchCallBody+20  
clr!DispatchCallDebuggerWrapper+75  
clr!DispatchCallNoEH+53  
clr!MethodTable::RunClassInitEx+f1  
clr!MethodTable::DoRunClassInitThrowing+53e  
clr!MethodDesc::DoPrestub+f1  
clr!PreStubWorker+12c  
0x00f80842  
clr!MethodTable::GetRestoredSlot+2a  
clr!MethodDesc::GetMethodEntryPoint+4e  
clr!MethodDesc::DoPrestub+51d  
clr!PreStubWorker+15d  
0x00f80842  
System.Web.WebPages.WebPageBase.ExecutePageHierarchy()  
System.Web.Mvc.WebViewPage.ExecutePageHierarchy()  
System.Collections.Generic.Stack`1[[System.__Canon, mscorlib]].Push(System.__Canon)  
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext, System.IO.TextWriter, System.Web.WebPages.WebPageRenderingBase)  
System.RuntimeType+ActivatorCacheEntry..ctor(System.Type, System.RuntimeMethodHandleInternal, Boolean)  
System.Web.Mvc.BuildManagerCompiledView.Render(System.Web.Mvc.ViewContext, System.IO.TextWriter)  
System.Web.Mvc.ViewResultBase.ExecuteResult(System.Web.Mvc.ControllerContext)  
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionResult)  
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()  
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1<System.Web.Mvc.ResultExecutedContext>)  
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()  
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()  
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()  
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()  
System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String)  
System.Web.Mvc.Controller.ExecuteCore()  
System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext)  
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(System.Web.Routing.RequestContext)  
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.<BeginProcessRequest>b__5()  
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.<MakeVoidDelegate>b__0()  
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.<EndProcessRequest>b__d()  
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(System.Action)  
System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult)  
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(System.IAsyncResult)  
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)  
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)  
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)  
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)  
webengine4!W3_MGD_HANDLER::ProcessNotification+5b  
webengine4!W3_MGD_HANDLER::DoWork+250  
webengine4!RequestDoWork+2da  
webengine4!CMgdEngHttpModule::OnExecuteRequestHandler+1a  
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+128  
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+305  
iiscore!NOTIFICATION_CONTEXT::CallModules+28  
iiscore!W3_CONTEXT::DoStateRequestExecuteHandler+36  
iiscore!W3_CONTEXT::DoWork+d7  
iiscore!W3_MAIN_CONTEXT::ContinueNotificationLoop+1f  
iiscore!W3_MAIN_CONTEXT::ProcessIndicateCompletion+1f  
iiscore!W3_CONTEXT::IndicateCompletion+75  
webengine4!W3_MGD_HANDLER::IndicateCompletion+3d  
webengine4!MgdIndicateCompletion+24  
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)  
clr!UM2MThunk_WrapperHelper+10  
clr!UM2MThunk_Wrapper+8c  
clr!Thread::DoADCallBack+f0  
clr!UM2MDoADCallBack+c0  
0x00f98c20  
webengine4!W3_MGD_HANDLER::ProcessNotification+5b  
webengine4!ProcessNotificationCallback+36  
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem+195  
clr!ThreadpoolMgr::NewWorkerThreadStart+20b  
clr!ThreadpoolMgr::WorkerThreadStart+3d1  
clr!Thread::intermediateThreadProc+4b  
kernel32!BaseThreadInitThunk+e  
ntdll!__RtlUserThreadStart+70  
ntdll!_RtlUserThreadStart+1b 


========================================================================= 

Thread 39 - System ID 4176 
Entry point 0x00000000 
Create time 2013/3/7 10:44:21 
Time spent in user mode 0 Days 00:00:00.140 
Time spent in kernel mode 0 Days 00:00:00.109 




This thread is not fully resolved and may or may not be a problem. Further analysis of these threads may be required. 



.NET Call Stack 



Function 
Spacebuilder.Common.ProfileRepository..ctor() 
Spacebuilder.Common.UserProfileService..ctor() 
Spacebuilder.Common.UserSearcher..ctor(System.String, System.String, Boolean, Int32) 
Spacebuilder.Environments.Starter.b__54(Autofac.IComponentContext) 
Autofac.RegistrationExtensions+<>c__DisplayClass10`1[[System.__Canon, mscorlib]].b__f(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.Builder.RegistrationBuilder+<>c__DisplayClass1`1[[System.__Canon, mscorlib]].b__0(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Resolving.InstanceLookup.b__0() 
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid, System.Func`1) 
Autofac.Core.Resolving.InstanceLookup.Execute() 
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope, Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4+<>c__DisplayClass6.b__1(Autofac.Core.IComponentRegistration) 
System.Linq.Enumerable+WhereSelectArrayIterator`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].MoveNext() 
System.Linq.Buffer`1[[System.__Canon, mscorlib]]..ctor(System.Collections.Generic.IEnumerable`1) 
System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib]](System.Collections.Generic.IEnumerable`1) 
Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4.b__0(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Resolving.InstanceLookup.Execute() 
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope, Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Resolving.ResolveOperation.Execute(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.Core.Container.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1) 
Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1, System.Object ByRef) 
Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1) 
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1) 
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext) 
Tunynet.DIContainer.Resolve[[System.__Canon, mscorlib]]() 
Spacebuilder.Search.SearcherFactory.GetSearcher(System.String) 
Spacebuilder.Common.FindUserController._InterestedWithAll(Int32, Int32, System.String) 
DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Web.Mvc.ControllerBase, System.Object[]) 
System.Web.Mvc.ActionMethodDispatcher.Execute(System.Web.Mvc.ControllerBase, System.Object[]) 
System.Web.Mvc.ReflectedActionDescriptor.Execute(System.Web.Mvc.ControllerContext, System.Collections.Generic.IDictionary`2) 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionDescriptor, System.Collections.Generic.IDictionary`2) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15.b__12() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(System.Web.Mvc.IActionFilter, System.Web.Mvc.ActionExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15+<>c__DisplayClass17.b__14() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(System.Web.Mvc.IActionFilter, System.Web.Mvc.ActionExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15+<>c__DisplayClass17.b__14() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(System.Web.Mvc.IActionFilter, System.Web.Mvc.ActionExecutingContext, System.Func`1) 
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15+<>c__DisplayClass17.b__14() 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(System.Web.Mvc.ControllerContext, System.Collections.Generic.IList`1, System.Web.Mvc.ActionDescriptor, System.Collections.Generic.IDictionary`2) 
System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String) 
System.Web.Mvc.Controller.ExecuteCore() 
System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext) 
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(System.Web.Routing.RequestContext) 
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.b__5() 
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.b__0() 
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass8`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].b__7(System.IAsyncResult) 
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].End() 
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.b__d() 
System.Web.Mvc.SecurityUtil.b__0(System.Action) 
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(System.Action) 
System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult) 
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(System.IAsyncResult) 
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception) 
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback) 
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32) 
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef) 
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32) 


Full Call Stack 



Function Source 
ntdll!KiFastSystemCallRet  
ntdll!NtWaitForSingleObject+c  
ntdll!RtlpWaitOnCriticalSection+13e  
ntdll!RtlEnterCriticalSection+150  
clr!UnsafeEEEnterCriticalSection+1c  
clr!CrstBase::Enter+1ad  
clr!ListLockEntry::FinishDeadlockAwareEnter+25  
clr!ListLockEntry::LockHolder::DeadlockAwareAcquire+28  
clr!MethodTable::DoRunClassInitThrowing+4c2  
clr!MethodDesc::DoPrestub+f1  
clr!PreStubWorker+12c  
0x00f80842  
clr!PreStubWorker+165  
System.Linq.Enumerable+WhereSelectArrayIterator`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].MoveNext()  
System.Linq.Buffer`1[[System.__Canon, mscorlib]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)  
System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib]](System.Collections.Generic.IEnumerable`1<System.__Canon>)  
System.Collections.Generic.Stack`1[[System.__Canon, mscorlib]].Push(System.__Canon)  
clr!JIT_Stelem_Ref+25  
System.Collections.Generic.Stack`1[[System.__Canon, mscorlib]].Push(System.__Canon) 

알렉스 답글 :

이 까다로운 하나 같은 소리 않습니다. 을 수행하는 DIContainer 클래스는 무엇이며 InstancePerHttpRequest, 또는 InstancePerLifetimeScope로 등록 된 구성 요소가 있습니까? 백그라운드에서 일부 석영 작업 이있는 것 같습니다. 어떻게 컨테이너와 상호 작용합니까?

트래비스는 회신 : 스택 추적에서

매우 빠른보기 당신이 Spacebuilder.Environments.Starter, Spacebuilder에서 일어나는 몇 가지 장기 실행 작업 또는 잠금 장치가있을 수 있습니다 나타냅니다. Common.UserSearcher.ctor, Spacebuilder.UserProfileService.ctor 또는 Spacebuilder.Common.ProfileRepository. 내가 뭘보고 있는데 흥미로운 것은 RESOLVE 작업 중에 어떤 것이 든 구성 요소가 해결되면 내부 레지스터가 진행된다는 것입니다. 코드를 보지 않고도 무슨 일이 벌어지고 있는지 말할 수는 없지만, 그 스레드 - # 39 - 그것이 제가 보았던 것입니다.

컨트롤러 동작이 호출 중임 클로저 (DynamicClass.lambda_method)에서 실행중인 람다 종류 - 파이프 라인에 커스텀 정의가 있습니다. SearcherFactory.GetSearcher 수작업으로 해결하려고 시도합니다. GetSearcher의 해결 중에는 서비스의 숫자가 IEnumerable 인 것과 같은 컬렉션이 필요합니다. 생성자 매개 변수?여기에 이 이상하게 보입니다. 그 IEnumerable을 해결하는 동안 새로운 평생 범위 인 이 생성되고 무언가가 에 등록 된 것처럼 보입니까? LifetimeScope.ResolveComponent 호출은 잠금을 수행하여 해상도가 스레드로부터 안전한지 확인합니다. 교착 상태가 발생한다는 사실 두 개의 다른 스레드가 동일한 평생 범위 (컨테이너?)를 해결하려고 시도하고 있다는 것을 의미합니다. 동시에 MVC에서는 피해야 할 항목이 있습니다. 예를 들어 과 같이 실행하면 이후 HttpRequest 수명 범위에서만 해결할 수 있습니다. 한 번에 하나의 스레드에서만이를 수행 할 수 있습니다. 또는 서비스 위치를 수행 할 목적으로 앱에서 평생 스코프를 전달할 수 있으며 빨간색 깃발이 될 수도 있습니다. https://code.google.com/p/autofac/wiki/Concurrency

을 그 당신이 필요로하는 방향으로 가야하지 않는 경우, 내가 다시, 이후 토론 포럼에 게시물을 추천 :

일부 포인터를 당신에게 줄 수있는 동시성에 대한 위키 페이지가 , 나는 정말로 에게 개인적인 도움을 적시에 제공 할 수는 없습니다. 그걸로 다른 눈을 얻을 것이고 당신을 좀 빨리 도울 수 있습니다. 문제에 대한 설명 (예 : 본 이메일에있는 내용)은 무엇이 발생할지에 대해 세부 정보 (예 : 컨트롤러 동작 인 ㅋㅋㅋ)에 대한 설명입니다. 스레드를 차단하는 의 스택 추적. 물건이 막히는 곳의 코드 : 의 등록 방법을 보여주는 초기 ContainerBuilder 등록. 그 생성자와 무엇에 매달려있는 인 것들. 그 정보는 사람들이 더 빨리 문제를 근절하는 데 도움이 될 것입니다. 즉 당신이 일에 대해 에보고해야한다 물건

을 고정하기이기도 내 보충 질문의 세부 사항 : 우리는 IISRESET 명령을 사용 util을

서버는 종종 불규칙 매달려은, 브라우저가 갑자기 응답을 중지한다 서버를 다시 시작하십시오. 컨트롤러가 불려지거나 Quartz 태스크가 그 시간을 트리거했는지는 확실치 않습니다.

Application_Start()에서 ContainerBuilder.Register()를 사용하여 동일한 루트 수명 범위의 여러 구성 요소를 등록합니다. 그리고이 구성 요소들은 서로를 호출 할 수 있습니다. InstancePerHttpRequest, 관련 각 요청 이러한 구성 요소의 초기화로 등록

containerBuilder.Register(c => new DefaultCacheService(new MemcachedCache())).As<ICacheService>().SingleInstance(); 
containerBuilder.Register(c => new QuartzTaskScheduler()).As<ITaskScheduler>().SingleInstance(); 
containerBuilder.Register(c => new UserService()).As<IUserService>().SingleInstance(); 
containerBuilder.Register(c => new UserSearcher("~/App_Data/IndexFiles/User")).As<ISearcher>().SingleInstance(); 
containerBuilder.Register(c => new TagSearcher("~/App_Data/IndexFiles/Tag")).As<ISearcher>().SingleInstance(); 

불과 몇 :

대부분 그들과 같은, SingleInstance로 등록.

containerBuilder.Register(c => new FormsAuthenticationService()).As<IAuthenticationService>().InstancePerHttpRequest(); 

클래스를 제공합니다 (DIContainer)는 구성 요소 해결을위한 몇 가지 간단한 정적 메서드를 제공합니다. 정적 메서드는 일부 컨트롤러, 서비스, 저장소 (DAO) 또는 Quartz 작업 에서처럼 구성 요소를 해결할 때 호출됩니다.

IContainer container = containerBuilder.Build(); 
DIContainer.RegisterContainer(container); 
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); 

public class DIContainer 
{ 
    private static IContainer _container; 

    public static void RegisterContainer(IContainer container) 
    { 
     _container = container; 
    } 

    public static TService Resolve<TService>() 
    { 
     return _container.Resolve<TService>(); 
    } 
    ...... 
} 

우리는 전체 텍스트 검색 서비스를 Lucene.Net를 사용, 각 ISearcher 검색의 유형과 색인 디렉토리에 해당합니다. ISearcher는 필요할 때 SearcherFactory.GetSearcher()에서 해결됩니다.

public static ISearcher GetSearcher(string IndexPath) 
{ 
    return DIContainer.Resolve<IEnumerable<ISearcher>>().Where(s => s.IndexPath.Equals(IndexPath, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); 
} 

그럼에도 불구하고 근본적인 이유는 아직 알 수 없습니다. 도와 줘서.

+1

모든 코드와 스택 추적을 보지 않고 말하기는 어렵지만 최초의 적색 플래그는 * "우리는 클래스 (DIContainer)에 구성 요소 해결을위한 간단한 정적 메소드를 제공합니다."* <- 왜 그냥 Autofac에 의해 구현 된 것처럼 생성자 주입을 사용합니까? 콘트롤러, 서비스 등에 의존성을 주입 할 것입니다. 이와 같이 컨테이너 주위를 돌아 다니는'정적 인 '코드에 의지하지 않아도됩니다. 왜 당신은'ISearcher' 인스턴스를 계속 해결할 것입니까? SearcherFactory의 수명 동안 고정 된 세트가 아니므로 해당 생성자에 삽입됩니까? –

+0

자물쇠를 잡고있는 스레드가 'Spacebuilder.Common.ProfileRepository..ctor()','Spacebuilder.Common.UserProfileServiceService..ctor()','Spacebuilder.Common.UserSearcher..ctor (System.String, System.String, Boolean, Int32)','Spacebuilder.Environments.Starter.b__54 (Autofac.IComponentContext)'체인을 사용하면 코드를 볼 필요가 있습니다. –

답변

1

Resolve 메서드의 내부 구현은 LifetimeScope.GetOrCreateAndShare이며이 메서드는 스레드 잠금을 사용합니다. ProfileRepository의 정적 생성자를 확인하십시오. 아마도 생성자의 스레드 잠금과 autofac의 스레드 잠금이 교착 상태를 구성 할 수 있습니다.

관련 문제