Skip to content

HeartbeatSlow warning missing context #12760

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

Closed
benaadams opened this issue Jul 31, 2019 · 6 comments · Fixed by #15273
Closed

HeartbeatSlow warning missing context #12760

benaadams opened this issue Jul 31, 2019 · 6 comments · Fixed by #15273
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions good first issue Good for newcomers. help wanted Up for grabs. We would accept a PR to help resolve this issue
Milestone

Comments

@benaadams
Copy link
Member

benaadams commented Jul 31, 2019

The warning outputs

Heartbeat took longer than 00:00:01 at 31/07/2019 14:14:00.
This could be caused by thread pool starvation.

It would be good it it included in the message how long it took, rather than just the threshold.

e.g. was it 1ms over, 1sec over, 1min over, 1hr over etc; they are all very different magnitudes

/cc @halter73

@analogrelay
Copy link
Contributor

Sounds like a good idea. We wouldn't be able to go below 1s of precision though since we're using the cached system clock that has a maximum precision of 1s.

@analogrelay analogrelay added good first issue Good for newcomers. help wanted Up for grabs. We would accept a PR to help resolve this issue labels Aug 6, 2019
@analogrelay
Copy link
Contributor

Basically just a matter of comparing now against _systemClock.UtcNow again before emitting the heartbeat slow event in https://github.com/aspnet/AspNetCore/blob/060d35cd04db1ce06dc816a8ec0faf9fd88d7a29/src/Servers/Kestrel/Core/src/Internal/Infrastructure/Heartbeat.cs#L43

@analogrelay analogrelay added this to the Backlog milestone Aug 6, 2019
@halter73
Copy link
Member

That @zHaytam. I agree that it makes sense change the signature of the (I)KestrelTrace.HeartBeatSlow methods and Action to take another argument representing duration. I'd probably make the argument a TimeSpan but just print out TimeSpan.TotalSeconds in the log message.

@zHaytam
Copy link
Contributor

zHaytam commented Aug 22, 2019

I have another question:
If this is a timer that runs every _interval, and in every run checks if the method in use:

  • Not used: heartbeat is performed normally.
  • Used: HeartbeatSlow event is emitted

Then wouldn't calculating the difference between now and _systemClock.UtcNow would not represent the duration, since its the last heartbeat who hold the method for too long.

@zHaytam
Copy link
Contributor

zHaytam commented Aug 22, 2019

After thinking about it some more, if the timer runs every _interval and the next heartbeat checks if the last heartbeat isn't done yet, then the duration will always equal the interval no?

Maybe we could add another event inside the finally block where it's fired if the difference between _systemClock.UtcNow and now was greater than _interval, which should give us a
meaningful duration.

https://github.com/aspnet/AspNetCore/blob/060d35cd04db1ce06dc816a8ec0faf9fd88d7a29/src/Servers/Kestrel/Core/src/Internal/Infrastructure/Heartbeat.cs#L62

@ghost ghost locked as resolved and limited conversation to collaborators Dec 5, 2019
@Tratcher Tratcher modified the milestones: Backlog, 5.0.0 Aug 11, 2020
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions good first issue Good for newcomers. help wanted Up for grabs. We would accept a PR to help resolve this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants