Skip to content

Commit 00b9a3c

Browse files
authored
fix: prevent error log when pgcoord query is canceled (#8609)
1 parent aceedef commit 00b9a3c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

coderd/database/errors.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package database
22

33
import (
4+
"context"
45
"errors"
56

67
"github.com/lib/pq"
@@ -40,7 +41,9 @@ func IsUniqueViolation(err error, uniqueConstraints ...UniqueConstraint) bool {
4041
func IsQueryCanceledError(err error) bool {
4142
var pqErr *pq.Error
4243
if errors.As(err, &pqErr) {
43-
return pqErr.Code.Name() == "query_canceled"
44+
return pqErr.Code == "57014" // query_canceled
45+
} else if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
46+
return true
4447
}
4548

4649
return false

enterprise/tailnet/pgcoord.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func (b *binder) writeOne(bnd binding) error {
424424
default:
425425
panic("unhittable")
426426
}
427-
if err != nil {
427+
if err != nil && !database.IsQueryCanceledError(err) {
428428
b.logger.Error(b.ctx, "failed to write binding to database",
429429
slog.F("client_id", bnd.client),
430430
slog.F("agent_id", bnd.agent),

0 commit comments

Comments
 (0)