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

executor: avoid ProjectoinExec's goroutine leak #14127

Merged
merged 9 commits into from
Dec 25, 2019

Conversation

fzhedu
Copy link
Contributor

@fzhedu fzhedu commented Dec 18, 2019

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

  • No code

Code changes

  • N/A

Side effects

  • N/A

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Write release note for bug-fix or new feature.

@fzhedu fzhedu added the type/bugfix This PR fixes a bug. label Dec 18, 2019
err := Next(ctx, e.analyzeExec, chk)
if err != nil {
return nil, err
next_err = Next(ctx, e.analyzeExec, chk)
Copy link
Contributor

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.

@winoros winoros changed the title avoid goroutine leak executor: avoid goroutine leak when doing EXPLAIN ANALYZE Dec 19, 2019
Comment on lines 86 to 101
close_err = e.analyzeExec.Close()
if next_err != nil {
return nil, next_err
}
Copy link
Contributor

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())

Copy link
Contributor

@SunRunAway SunRunAway left a 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?

@@ -15,6 +15,7 @@ package executor

import (
"context"
"github.com/pingcap/errors"
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

executor/explain.go Show resolved Hide resolved
@winoros winoros changed the title executor: avoid goroutine leak when doing EXPLAIN ANALYZE executor: avoid ProjectoinExec's goroutine leak Dec 24, 2019
@bb7133 bb7133 added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Dec 24, 2019
if panicErr := recover(); panicErr != nil && !closed {
err = e.analyzeExec.Close()
closed = true
}
Copy link
Contributor

@SunRunAway SunRunAway Dec 25, 2019

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() }
}()

Copy link
Contributor Author

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.

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

@fzhedu
Copy link
Contributor Author

fzhedu commented Dec 25, 2019

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 25, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 25, 2019

/run-all-tests

@SunRunAway SunRunAway added status/LGT1 Indicates that a PR has LGTM 1. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 25, 2019
@sre-bot sre-bot merged commit aa2f716 into pingcap:master Dec 25, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 25, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Dec 25, 2019

cherry pick to release-2.1 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

execution: go routine leak when executing explain analyze
7 participants