Skip to content
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

sql/pgwire: close cancel request conn as soon as possible #76476

Merged
merged 1 commit into from
Feb 14, 2022
Merged
Changes from all commits
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
11 changes: 5 additions & 6 deletions pkg/sql/pgwire/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,16 +747,15 @@ func (s *Server) handleCancel(ctx context.Context, conn net.Conn, buf *pgwirebas
log.Sessions.Warningf(ctx, "unexpected while handling pgwire cancellation request: %v", err)
}
telemetry.Inc(sqltelemetry.CancelRequestCounter)

// The connection that issued the cancel is not a SQL session -- it's an
// entirely new connection that's created just to send the cancel. There
// isn't anything left for the server to do after it handles the
// pgwire cancel request.
_ = conn.Close()
}()

var backendKeyDataBits uint64
backendKeyDataBits, err = buf.GetUint64()
// The connection that issued the cancel is not a SQL session -- it's an
// entirely new connection that's created just to send the cancel. We close
// the connection as soon as possible after reading the data, since there
// is nothing to send back to the client.
_ = conn.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may be worth logging this error somewhere just in case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i'd prefer not to. the client is also allowed to close the conn first. even apart from that i don't feel that it's that actionable if this errors out

if err != nil {
return
}
Expand Down