fix: prevent error log when pgcoord query is canceled (#8609)

This commit is contained in:
Colin Adler
2023-07-19 16:40:57 -05:00
committed by GitHub
parent aceedefce3
commit 00b9a3ce58
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package database
import (
"context"
"errors"
"github.com/lib/pq"
@ -40,7 +41,9 @@ func IsUniqueViolation(err error, uniqueConstraints ...UniqueConstraint) bool {
func IsQueryCanceledError(err error) bool {
var pqErr *pq.Error
if errors.As(err, &pqErr) {
return pqErr.Code.Name() == "query_canceled"
return pqErr.Code == "57014" // query_canceled
} else if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return true
}
return false