Open ignaciosalazarcalle opened 4 years ago
I am getting similar kind of error and couldn't find the method which one blocking the code. Please review logs below:
[12:40:05.621 WRN] Ben.Diagnostics.BlockingMonitor: Blocking method has been invoked and blocked, this can lead to threadpool starvation. at System.Threading.Monitor.ReliableEnter(Object obj, Boolean& lockTaken) at System.IO.Pipelines.Pipe.AllocateWriteHeadSynchronized(Int32 sizeHint) at System.IO.Pipelines.Pipe.GetSpan(Int32 sizeHint) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.PipeWriterHelpers.ConcurrentPipeWriter.GetSpan(Int32 sizeHint) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1OutputProducer.WriteChunkAsync(ReadOnlySpan
1 buffer, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.WritePipeAsync(ReadOnlyMemory1 data, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at Prometheus.TextSerializer.WriteMetricAsync(Byte[] identifier, Double value, CancellationToken cancel) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Prometheus.TextSerializer.WriteMetricAsync(Byte[] identifier, Double value, CancellationToken cancel) at Prometheus.Histogram.Child.CollectAndSerializeImplAsync(IMetricsSerializer serializer, CancellationToken cancel) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Prometheus.Histogram.Child.CollectAndSerializeImplAsync(IMetricsSerializer serializer, CancellationToken cancel) at Prometheus.Collector
1.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Prometheus.Collector1.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel) at Prometheus.CollectorRegistry.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Prometheus.CollectorRegistry.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel) at Prometheus.MetricServerMiddleware.Invoke(HttpContext context) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Prometheus.MetricServerMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context) at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext) at Ben.Diagnostics.BlockingDetectionMiddleware.Invoke(HttpContext httpContext) at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Ben.Diagnostics.BlockingDetectionMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication
1 application)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.AsyncStateMachineBox
1.MoveNext(Thread threadPoolThread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()`
Thanks!
@ignaciosalazarcalle Microsoft.Data.SqlClient.TdsParser.CheckResetConnection is a blocking call in sql server client. @sadik7266 System.IO.Pipelines.Pipe.AllocateWriteHeadSynchronized is a blocking call in System.IO.Pipelines.Pipe
nothing you can do about except open an issue in their repos maybe it can/will be fixed there.
Hello,
I'm executing this code's line:
And I always receive the same error:
I understand my code is async, then, Why does the library mark that code as a possible code lock?
Thanks,