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
+10
View File
@@ -27,3 +27,13 @@ func IsUniqueViolation(err error, uniqueConstraints ...UniqueConstraint) bool {
return false
}
// IsQueryCanceledError checks if the error is due to a query being canceled.
func IsQueryCanceledError(err error) bool {
var pqErr *pq.Error
if errors.As(err, &pqErr) {
return pqErr.Code.Name() == "query_canceled"
}
return false
}