-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deadlock in integration tests after upgrading to ASP.NET Core 6 #38649
Comments
I'm surprised this doesn't hang in .NET 5. Why should |
@halter73 It is not the 5 second hang that is the problem, that is naturally expected as shown in Windows logs above. What is unexpected is deadlock and infinite hang on Ubuntu, only on .NET6. |
Could you try using a Noop IHostLifetime implementation and see if the hang still occurs. |
Hi @angularsen. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@BrennanConroy I am certain that a Noop IHostLifetime works, because the workaround I described was to remove the Task.Delay in StopAsync of our IHostedService implementation. This fixed our tests. I believe this is effectively the same as the Noop implementation, because our implementation did little beyond logging and waiting on stop. |
Thanks for contacting us. |
Thanks for contacting us. |
Receiving this error "System.AggregateException : One or more hosted services failed to stop. (Not started. Call Start first" From tests using WebApplicationFactory . Info here: dotnet/aspnetcore#38649 And possible solution here: https://github.com/dotnet/aspnetcore/pull/23761/files
Receiving this error "System.AggregateException : One or more hosted services failed to stop. (Not started. Call Start first" From tests using WebApplicationFactory . Info here: dotnet/aspnetcore#38649 And possible solution here: https://github.com/dotnet/aspnetcore/pull/23761/files
Looks like @BrennanConroy's change merged in, I'm assuming this is the long term fix for this issue. Re-open if it isn't Brennan. |
@mitchdenny which change were you referring to? Can you kindly add a link so I could see if it would fix our issue as well? |
Describe the bug
After upgrading from ASP.NET Core 5 to 6, our integration tests would hang indefinitely on Azure Pipelines with
ubuntu-20.04
.After analyzing dumps with
dotnet test --blame-hang-timeout
, we found a deadlock onWebApplicationFactory.Dispose()
and concurrent tests calling the API.The root cause
WebApplicationFactory
instance per test class, reused by its test methods to call the API.Task.Delay(TimeSpan.FromSeconds(5), ct)
in itsIHostedService.StopAsync()
, which is used to flush logs and telemetry before the API is allowed to shut down.Workaround
Do not delay
IHostedService.StopAsync()
for "Test" environment.Investigation
dotnet test
on Azure Pipelinesubuntu-20.04
would hang indefinitely after upgrading to ASP.NET Core 6windows-2019
dotnet test
To Reproduce
Detailed description and repro integration tests here:
Repro hang of integration tests after upgrading to ASP.NET Core 6 - Pull Request #1 · angularsen/NET6-Testing
Exceptions (if any)
On Ubuntu, deadlock.
On Windows (as expected):
Further technical details
dotnet --info
:dotnet --info Output
WSL Ubuntu 20.10:
Windows:
The text was updated successfully, but these errors were encountered: