This repository was archived by the owner on Dec 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
And if you had a Demystifying logger attached it would look more like this warn: Microsoft.AspNetCore.Diagnostics.DetectBlocking[6]
Blocking method has been invoked and blocked, this can lead to threadpool starvation.
at bool System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, CancellationToken cancellationToken)
at bool System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, CancellationToken cancellationToken)
at bool System.Threading.Tasks.Task.InternalWait(int millisecondsTimeout, CancellationToken cancellationToken)
at void Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.FrameResponseStream.Write(byte[] buffer, int offset, int count)
at Task AoA.Gaia.Startup.BlockingWrite(HttpContext httpContext) in C:\Work\AoA\src\AoA.Gaia\Startup.cs:line 116
at Task AoA.Gaia.SpaceWebSocketsMiddleware.Invoke(HttpContext httpContext) in C:\Work\AoA\src\AoA.Gaia\SpaceWebSocketsMiddleware.cs:line 128
at Task Microsoft.AspNetCore.WebSockets.WebSocketMiddleware.Invoke(HttpContext context)
at async Task AoA.Space.ErrorHandlerMiddleware.Invoke(HttpContext httpContext) in C:\Work\AoA\src\AoA.Gaia\ErrorHandlerMiddleware.cs:line 29
at void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine>(ref TStateMachine stateMachine)
at Task AoA.Space.ErrorHandlerMiddleware.Invoke(HttpContext httpContext)
at async Task Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
at void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine>(ref TStateMachine stateMachine)
at Task Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
at async Task AoA.Gaia.BlockingDetection.BlockingDetectionMiddleware.Invoke(HttpContext httpContext) in C:\Work\AoA\src\AoA.Gaia\BlockingDetection\BlockingDetectionMiddleware.cs:line 33
at void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine>(ref TStateMachine stateMachine)
at Task AoA.Gaia.BlockingDetection.BlockingDetectionMiddleware.Invoke(HttpContext httpContext)
at async Task Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.Invoke(HttpContext httpContext)
at void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine>(ref TStateMachine stateMachine)
at Task Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.Invoke(HttpContext httpContext)
at Task Microsoft.AspNetCore.Hosting.Internal.HostingApplication.ProcessRequestAsync(Context context)
at async Task Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame<TContext>.ProcessRequestsAsync()
at void Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe._scheduleContinuation(object o)
at void Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.LoggingThreadPool.Schedule(Action<object> action, object state)+() => { }
at void Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.LoggingThreadPool.RunAction()+(object o) => { }
at bool System.Threading.ThreadPoolWorkQueue.Dispatch() |
f8d97b6
to
61391d4
Compare
61391d4
to
7f0802e
Compare
Should it be added by |
Also catches held locks 120: public Task LockedMethod(HttpContext httpContext)
121: {
122: var response = httpContext.Response;
123: response.StatusCode = 200;
124: response.ContentType = "text/plain";
125: lock (obj) // **********
126: {
127: // locked outside for 1 sec
128: }
129: var s = new string('n', 16);
130: response.ContentLength = s.Length;
131: return response.WriteAsync(s);
132: } Outputs (with some extra formatting) warn: Microsoft.AspNetCore.Diagnostics.DetectBlocking[6]
Blocking method has been invoked and blocked, this can lead to threadpool starvation.
at Task AoA.Gaia.Startup.LockedMethod(HttpContext httpContext)
in C:\Work\AoA\src\AoA.Gaia\Startup.cs:line 125 ********
at IApplicationBuilder Microsoft.AspNetCore.Builder.UseExtensions.Use(IApplicationBuilder app, Func<HttpContext, Func<Task>, Task> middleware)+() => { }
....
at void Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe._scheduleContinuation(object o)
at void Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.LoggingThreadPool.Schedule(Action<object> action, object state)+() => { }
at void Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.LoggingThreadPool.RunAction()+(object o) => { }
at bool System.Threading.ThreadPoolWorkQueue.Dispatch() |
Raised issue for sys calls https://github.com/dotnet/coreclr/issues/15675 |
This issue was moved to dotnet/aspnetcore#2571 |
Sorry I was a bad bot. Re-opening this PR. |
Hi @benaadams. Thanks for your effort. Can we, however, make it optional? /cc: @davidfowl, @rynowak |
Has gone stale |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Warning when blocking calls are made on the threadpool.
Doesn't detect everything...
Body.Write
)File.Read(...)
,Thread.Sleep
)Will detect CLR initiated waits
lock
,ManualResetEventSlim
,Semaphore{Slim}
,Task.Wait
,Task.Result
etc; if they do block.e.g. if you had a method like:
And
UseDeveloperExceptionPage
is added, it will ouput/cc @davidfowl @stephentoub