dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.52k stars 10.04k forks source link

Kestrel Metrics can crash local test run #57579

Open BrennanConroy opened 2 months ago

BrennanConroy commented 2 months ago

Local test runs (running tests in debug mode) sometimes fails with a crash:

Process terminated. Assertion failed.
reason != ConnectionEndReason.Unset
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelMetrics.AddConnectionEndReason(ConnectionMetricsContext context, ConnectionEndReason reason, Boolean overwrite) in C:\github\aspnetcore\src\Servers\Kestrel\Core\src\Internal\Infrastructure\KestrelMetrics.cs:line 435
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3.Http3Connection.Abort(ConnectionAbortedException ex, Http3ErrorCode errorCode, ConnectionEndReason reason) in C:\github\aspnetcore\src\Servers\Kestrel\Core\src\Internal\Http3\Http3Connection.cs:line 187
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3.Http3Connection.ProcessRequestsAsync[TContext](IHttpApplication`1 application) in C:\github\aspnetcore\src\Servers\Kestrel\Core\src\Internal\Http3\Http3Connection.cs:line 549
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Internal.QuicConnectionContext.AcceptAsync(CancellationToken cancellationToken) in C:\github\aspnetcore\src\Servers\Kestrel\Transport.Quic\src\Internal\QuicConnectionContext.cs:line 97
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.ExecutionContextCallback(Object s)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining)
   at System.Threading.Tasks.Task.RunContinuations(Object continuationObject)
   at System.Threading.Tasks.Task.FinishSlow(Boolean userDelegateExecute)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetException(Exception exception, Task`1& taskField)
   at System.Net.Quic.QuicConnection.AcceptInboundStreamAsync(CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Not sure if that means sometimes metrics might not have an end reason?

cc @JamesNK

amcasey commented 2 months ago

https://github.com/dotnet/aspnetcore/blob/542f2b9877da67e90cca6ce1b65aa9557fbb2aa8/src/Servers/Kestrel/Core/src/Internal/Http3/Http3Connection.cs#L466 should probably be outside the if