fix: stop logging error on canceled query (#11506)

Fixes flake seen here: https://github.com/coder/coder/actions/runs/7447779208/job/20260756050
This commit is contained in:
Spike Curtis
2024-01-09 14:38:56 +04:00
committed by GitHub
parent 0c953b4b8c
commit 21093c00f0

View File

@ -242,10 +242,8 @@ func (s *server) heartbeatLoop() {
}
start := s.timeNow()
hbCtx, hbCancel := context.WithTimeout(s.lifecycleCtx, s.heartbeatInterval)
if err := s.heartbeat(hbCtx); err != nil {
if !xerrors.Is(err, context.DeadlineExceeded) && !xerrors.Is(err, context.Canceled) {
s.Logger.Error(hbCtx, "heartbeat failed", slog.Error(err))
}
if err := s.heartbeat(hbCtx); err != nil && !database.IsQueryCanceledError(err) {
s.Logger.Error(hbCtx, "heartbeat failed", slog.Error(err))
}
hbCancel()
elapsed := s.timeNow().Sub(start)