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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy