Skip to content
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

HttpContext dispose diagnostics don't get processed (not always) #53820

Open
jbroumels opened this issue Feb 5, 2024 · 2 comments
Open

HttpContext dispose diagnostics don't get processed (not always) #53820

jbroumels opened this issue Feb 5, 2024 · 2 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@jbroumels
Copy link

Description

When using the diagnostics, sometimes, they don't arrive.
This seems to happen because the HttpContext disposal is handing this.
The server that handled that context however, allows to shutdown.

Maybe due to GC running later there's a problem in this area.
It seems to have started with .net8

I did some tests and traces because of this PR: opentracing-contrib/csharp-netcore#104
(The delay shouldn't be needed. The host should wait for shutting down)

Quite often the diagnostics triggers don't hit before shutdown.
Which I believe eventually comes from the framework, which is allowing a shutdown before all data regarding a request (HttpContext with disposal) is finished

@

Reproduction Steps

opentracing-contrib/csharp-netcore#104
It started failing from .net8

Expected behavior

Host shouldn't shut down before processing all diagnostics

Actual behavior

Host shuts down before processing all diagnostics

Regression?

No response

Known Workarounds

Applying a Delay

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Feb 5, 2024
@ghost ghost added the untriaged label Feb 5, 2024
@MihaZupan MihaZupan transferred this issue from dotnet/runtime Feb 5, 2024
@Tratcher
Copy link
Member

Tratcher commented Feb 5, 2024

Are the requests themselves finishing before shutdown? There's a shutdown timeout that will cause incomplete requests to be abandon.

@jbroumels
Copy link
Author

jbroumels commented Feb 5, 2024

@Tratcher even if you put the host shutdown to 30 seconds, the same happens.
Yes, these requests are finished. On the side of the client. Client has had response etc.
But on serverside, the HttpContext for the request is not finished, at least, it's not disposed and thus the diagnostics are not fired for it.
And the host thinks it can shut down, because nothing is pending, but the disposal of the last request still is.

I don't believe it's a major issue, but it's a continuety problem. There's no guarantee all start requests diagnostics will also receive their related stop.
The listeners in between are allowed to be shut down (because the host allows that, despite the host shutdown period)

From the perspective of the client library, in this case OpenTracing, there's nothing the library can do to prevent this.
Therefore I believe I this is actually some kind of problem in the .net framework

@mkArtakMSFT mkArtakMSFT added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed untriaged needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

4 participants
@Tratcher @jbroumels @mkArtakMSFT and others