Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! fix: prevent error log when pgcoord query is canceled.
  • Loading branch information
coadler committed Jul 19, 2023
commit cf4a423eaf15e63569f8280d0a352544d12d491f
8 changes: 1 addition & 7 deletions enterprise/tailnet/pgcoord.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func (b *binder) writeOne(bnd binding) error {
default:
panic("unhittable")
}
if err != nil && !pqErrIsCanceled(err) {
if err != nil && !database.IsQueryCanceledError(err) {
b.logger.Error(b.ctx, "failed to write binding to database",
slog.F("client_id", bnd.client),
slog.F("agent_id", bnd.agent),
Expand All @@ -434,12 +434,6 @@ func (b *binder) writeOne(bnd binding) error {
return err
}

// This is returned when the context is canceled on a running query. pq does not
// export an error for this.
func pqErrIsCanceled(err error) bool {
return err.Error() == "pq: canceling statement due to user request"
}

// storeBinding stores the latest binding, where we interpret node == nil as removing the binding. This keeps the map
// from growing without bound.
func (b *binder) storeBinding(bnd binding) {
Expand Down