-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: avoid ProjectoinExec
's goroutine leak
#14127
Conversation
executor/explain.go
Outdated
err := Next(ctx, e.analyzeExec, chk) | ||
if err != nil { | ||
return nil, err | ||
next_err = Next(ctx, e.analyzeExec, chk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Golang idiomatic name convention.
EXPLAIN ANALYZE
executor/explain.go
Outdated
close_err = e.analyzeExec.Close() | ||
if next_err != nil { | ||
return nil, next_err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better?
defer terror.Log(e.analyzeExec.Close())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some unit tests?
bc7de31
to
ca53c94
Compare
executor/explain.go
Outdated
@@ -15,6 +15,7 @@ package executor | |||
|
|||
import ( | |||
"context" | |||
"github.com/pingcap/errors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please group the import path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
EXPLAIN ANALYZE
ProjectoinExec
's goroutine leak
ca53c94
to
83683ec
Compare
if panicErr := recover(); panicErr != nil && !closed { | ||
err = e.analyzeExec.Close() | ||
closed = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call recover
here, the panic will be recovered here, which is not we want.
Suggest just check closed
.
defer func() {
// close if panic happens
if !closed { e.analyzeExec.Close() }
}()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if without recover, the goroutine will panic, and test will not work.
6460ad9
to
d090ccc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
/merge |
/run-all-tests |
cherry pick to release-3.0 failed |
cherry pick to release-2.1 failed |
What problem does this PR solve?
fix #14125
What is changed and how it works?
invoke close() even next() errors in explain statements
Check List
Tests
Code changes
Side effects
Related changes
Release note