fix: don't log disconnect error when the database is shutting down (#6309)

* fix: don't log disconnect error when the database is shutting down

Seen in: https://github.com/coder/coder/actions/runs/4244980490/jobs/7379867681

* Generalize the query close error
This commit is contained in:
Kyle Carberry
2023-02-22 16:07:26 -06:00
committed by GitHub
parent bbdf24686d
commit 2a8a147e7d
2 changed files with 13 additions and 1 deletions

View File

@ -644,7 +644,9 @@ func (api *API) workspaceAgentCoordinate(rw http.ResponseWriter, r *http.Request
// This is a bug with unit tests that cancel the app context and
// cause this error log to be generated. We should fix the unit tests
// as this is a valid log.
if !xerrors.Is(err, context.Canceled) {
//
// The pq error occurs when the server is shutting down.
if !xerrors.Is(err, context.Canceled) && !database.IsQueryCanceledError(err) {
api.Logger.Error(ctx, "failed to update agent disconnect time",
slog.Error(err),
slog.F("workspace", build.WorkspaceID),