Open nullpainter opened 1 year ago
Please try https://www.nuget.org/packages/AspNetCore.HealthChecks.SqlServer/7.0.0-rc2.11 . v7 release is coming soon.
Dear friends @nullpainter and @sungam3r
I am glad to announce that after hours of investigation, i could identify and fix the root cause of this behavior.
In my scenario, it was happening because of a lack of CPU. (My container was running with only 0.5 CPU units of AWS ECS Fargate).
Look: every period of 5 min, when my app perform a healthcheck, the CPU usage spikes to 100%.
Glad to hear. Closing?
Time profile shows that usually after 1 second request ends with
System.Threading.Tasks.TaskCanceledException: A task was canceled. at HealthChecks.SqlServer.SqlServerHealthCheck.CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken) in /_/src/HealthChecks.SqlServer/SqlServerHealthCheck.cs:line 28
which provides exactly none clue.
I am experiencing bizarre timeouts with the SQL Server provider, and cannot work out why. For example:
I am using
AspNetCore.HealthChecks.SqlServer
version 6.0.2 and am callingAddSqlServer()
with a 10 second timeout.I have a
BackgroundService
which is explicitly callingHealthCheckService.CheckHealthAsync()
, passing in a cancellation token which is a combination of another timeout of 20s, and theBackgroundService
'sstoppingToken
.Simplified, the code is:
(the actual code utilises a
PeriodicTimer
to poll for health repeatedly)I can see that my cancellation token is being passed down to
SqlServerHealthCheck
, and I can also see that the 10s timeout is being used inDefaultHealthCheckService
when constructing its own cancellation token.My questions are two-fold:
stoppingToken
? My understanding is that this should only happen if my application was shutting down.SqlCommand.ExecuteScalarAsync()
has a default timeout of 30s. The code which generates this log message looks straightforward.The more I look into this and the more I debug it, the more confused I'm becoming.