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

fix race condition when context is canceled #1562

Merged
merged 3 commits into from
Mar 17, 2024
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
8 changes: 7 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,13 @@ func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
// finish is called when the query has canceled.
func (mc *mysqlConn) cancel(err error) {
mc.canceled.Set(err)
mc.cleanup()
nc := mc.netConn
if nc != nil {
_ = nc.SetDeadline(time.Now()) // wake up pending reads/writes
// Ignore error because:
// - If the connection is already closed, thats fine.
// - If the connection return error other reasons, we can not do anything about it.
}
methane marked this conversation as resolved.
Show resolved Hide resolved
}

// finish is called when the query has succeeded.
Expand Down
Loading