aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
Other
858 stars 354 forks source link

ASP.NET graceful shutdown takes 60+ seconds on Windows 2022 to get notified #404

Closed chunye closed 1 year ago

chunye commented 1 year ago

I am currently stuck investigating an issue on an app running on Windows 2022, ASP.NET 4.6/4.7.2. On a graceful shutdown, the same app running on Windows 2016 gets stopped in a few seconds (its IRegisterObject.Stop method gets called in seconds). But on Windows 2022, it will take around 60+ seconds to have the Stop method getting called.

I traced a bit and found the PipelineRuntime.StopProcessing started the AppDomain unwinding, but I couldn’t have more stack trace to debug further and figure out why it takes so long on Windows 2022 to call PipelineRuntime.StopProcessing.

Can someone tell me which area/code should I look at next?

The disconnect is initiated with the IIS native call SendStopQueue from another process.

_wpIpmPipe.SendStopQueue("http", 0, 0);

The graceful disconnect works on a sample ASP.NET app running on Windows 2022 that implements the IRegisterObject interface. The affected app is Kudu (refer https://github.com/projectkudu/kudu). Check the code in Kudu.Core JobsManagerBase.cs.

Please contact me if you need any more details or repro.

Thanks.

davidfowl commented 1 year ago

Does the application have any long running connections (websockets etc)?

mkArtakMSFT commented 1 year ago

Closing as we have never heard back from the customer.