You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Net 7 Kestrel windows service hangs after a period of time #82207
We just update our projects to .NET 7 from .NET 5 and are experiencing hangs where Kestrel quits responding. It works for a day or so and then the windows service needs to be restarted. This was not an issue on .NET5. I gathered a memory dump to see if I can figure out what is causing it to hang. Here are some screenshots. This was gathered using ProcDump.
This API is installed at many unique locations and several have reported the same issue that they need to restart the service daily. For some locations, we use Azure relay. So far, the locations that go through the relay have not had any issues.
@davidfowl Absolutely, we ran through that issue extensively before we submitted our own. Was there something specific that would be helpful? I have the memory dump. All the requests are http not https. So far, it seems that the issue occurs after the API sits idle for a period of time. Our users work banker's hours, so it works all day long, but when they come back the next morning Kestrel is no longer responding to any requests until we restart the windows service it's running in.
The client does not get a response back, the requests just hang. Unfortunately, we haven't found anything in the logs or event viewer yet. We'll try increasing the detailed logging to see if we can get anything better. The windows service on the server is still running but just not responding.
@sccrgoalie1 Thanks for sharing the dump. I looked through it and didn't spot any immediate issues that jumped out. Just curious, did taking the dump cause the process to "unhang" or was it still in the stuck/unresponsive state?
As a side note (maybe not related to the problem you're hitting), I see a bunch of threads doing things related to performance counters, which are running code from aspnet_perf.dll. Do you know what's causing that?
AFAICT aspnet_perf is an old ASP.NET framework component so I'm wondering what it's doing in the context of a ASP.NET Core app.
@sccrgoalie1 Thanks for sharing the dump. I looked through it and didn't spot any immediate issues that jumped out. Just curious, did taking the dump cause the process to "unhang" or was it still in the stuck/unresponsive state?
No, taking the dump did not unstick it. At one of the sites having to restart daily we converted them to use Microsoft.Azure.Relay.AspNetCore and since then they have been running for days without any issues. I'm not sure at what level that package intertwines with Kestrel, but it seems to prevent the hang we are experiencing.
As a side note (maybe not related to the problem you're hitting), I see a bunch of threads doing things related to performance counters, which are running code from aspnet_perf.dll. Do you know what's causing that?
AFAICT aspnet_perf is an old ASP.NET framework component so I'm wondering what it's doing in the context of a ASP.NET Core app.
The only thing I can think of that might be doing that is Application Insights but we are using the NetCore version (Microsoft.ApplicationInsights.AspNetCore)
We have several .NET 7.0.2 applications running on Windows Server 2019. We run the apps as HashiCorp Nomad Jobs.
We noticed that HTTP requests to an application start to fail if we open the Windows "Resource Monitor" application and select the dotnet process running our app from the list (toggle checkbox on).
After selecting the application, it takes some time before HTTP requests, such as health checks start to fail (hang). To make the app work again, restart is required.
You can also select more than one apps, and all the selected apps start to fail. Apps that are not selected work without problems.
Another thing to look into perhaps is why the IO completion with ERROR_OPERATION_ABORTED is not causing some kind of error to occur. Edit: It's being treated similarly to the IO being canceled normally.
ghost added
in-prThere is an active PR which will close this issue when it is merged
Activity
danmoseley commentedon Feb 2, 2023
Just curious does it repro on 6.0?
sccrgoalie1 commentedon Feb 2, 2023
Not sure, we skipped over 6.0 and went straight to 7.0. We might be able to backtrack if that will help in diagnosing.
davidfowl commentedon Feb 3, 2023
There was another issue like this with similar symptoms (hanging after a day or something). Can you look at parallel stacks?
sccrgoalie1 commentedon Feb 3, 2023
Yeah, it was this one dotnet/aspnetcore#45215. I reviewed that one and I don't think a solution was found, just not enough info to diagnose.
davidfowl commentedon Feb 3, 2023
@sccrgoalie1 Can you run through all of the same steps?
sccrgoalie1 commentedon Feb 6, 2023
@davidfowl Absolutely, we ran through that issue extensively before we submitted our own. Was there something specific that would be helpful? I have the memory dump. All the requests are http not https. So far, it seems that the issue occurs after the API sits idle for a period of time. Our users work banker's hours, so it works all day long, but when they come back the next morning Kestrel is no longer responding to any requests until we restart the windows service it's running in.
adityamandaleeka commentedon Feb 6, 2023
@sccrgoalie1 Is it possible for you to share the dump with us (we'd understand if you cannot)?
adityamandaleeka commentedon Feb 6, 2023
Can you share more info about what exactly happens on the client and server when this happens?
For instance, does the client get a response back? Do the server logs show anything interesting? Perhaps you may get some interesting output if you enable more detailed logging on the server. See here for more info on configuring logging: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-7.0#configure-logging
sccrgoalie1 commentedon Feb 7, 2023
@adityamandaleeka Sure, here is the memory dump.
Memory Dump
sccrgoalie1 commentedon Feb 7, 2023
The client does not get a response back, the requests just hang. Unfortunately, we haven't found anything in the logs or event viewer yet. We'll try increasing the detailed logging to see if we can get anything better. The windows service on the server is still running but just not responding.
adityamandaleeka commentedon Feb 9, 2023
@sccrgoalie1 Thanks for sharing the dump. I looked through it and didn't spot any immediate issues that jumped out. Just curious, did taking the dump cause the process to "unhang" or was it still in the stuck/unresponsive state?
adityamandaleeka commentedon Feb 10, 2023
As a side note (maybe not related to the problem you're hitting), I see a bunch of threads doing things related to performance counters, which are running code from aspnet_perf.dll. Do you know what's causing that?
AFAICT aspnet_perf is an old ASP.NET framework component so I'm wondering what it's doing in the context of a ASP.NET Core app.
sccrgoalie1 commentedon Feb 10, 2023
No, taking the dump did not unstick it. At one of the sites having to restart daily we converted them to use Microsoft.Azure.Relay.AspNetCore and since then they have been running for days without any issues. I'm not sure at what level that package intertwines with Kestrel, but it seems to prevent the hang we are experiencing.
sccrgoalie1 commentedon Feb 10, 2023
The only thing I can think of that might be doing that is Application Insights but we are using the NetCore version (Microsoft.ApplicationInsights.AspNetCore)
heikkilamarko commentedon Feb 12, 2023
We have several .NET 7.0.2 applications running on Windows Server 2019. We run the apps as HashiCorp Nomad Jobs.
We noticed that HTTP requests to an application start to fail if we open the Windows "Resource Monitor" application and select the dotnet process running our app from the list (toggle checkbox on).
After selecting the application, it takes some time before HTTP requests, such as health checks start to fail (hang). To make the app work again, restart is required.
You can also select more than one apps, and all the selected apps start to fail. Apps that are not selected work without problems.
The problem reproduces consistently.
14 remaining items
kouvel commentedon Feb 15, 2023
I've transferred the issue over to the runtime repo now
kouvel commentedon Feb 15, 2023
Another thing to look into perhaps is why the IO completion with
ERROR_OPERATION_ABORTEDis not causing some kind of error to occur. Edit: It's being treated similarly to the IO being canceled normally.Check for pending IO in the portable thread pool's worker threads (#8…
[6.0] Check for pending IO in the portable thread pool's worker threa…
[7.0] Check for pending IO in the portable thread pool's worker threa…