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
Next Next commit
fix: prevent error log when pgcoord query is canceled.
I believe this is what has been causing the `TestReplicas` flakes.
There's a race condition where if a query was in flight while the
`pgcoord` was closing, it would log an error. The error log then fails
the test since somewhere along the line we're creating a `slogtest`
logger.
  • Loading branch information
coadler committed Jul 19, 2023
commit 97ac7b9b799b6d0605e8f246e90c17d42b18039d
8 changes: 7 additions & 1 deletion 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 {
if err != nil && !pqErrIsCanceled(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,6 +434,12 @@ 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