-
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: fix hashjoin goleak #39023
Conversation
Signed-off-by: xhe <xw897002528@gmail.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
@@ -70,6 +69,8 @@ type HashJoinExec struct { | |||
|
|||
// closeCh add a lock for closing executor. | |||
closeCh chan struct{} | |||
worker util.WaitGroupWrapper | |||
waiter util.WaitGroupWrapper |
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.
waitJoinWorkersAndCloseResultChan
will call worker.Wait()
, but it is running in another goroutine. So waiter
is to prevent leak of waitJoinWorkersAndCloseResultChan
.
@@ -43,7 +43,7 @@ func (w *WaitGroupWrapper) RunWithRecover(exec func(), recoverFn func(r interfac | |||
go func() { | |||
defer func() { | |||
r := recover() | |||
if r != nil && recoverFn != nil { | |||
if recoverFn != nil { |
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.
util.WithRecovery
will always call recoveryFn
, align with it and hashjoin relies on this behavior.
defer close(chkCh) | ||
var err error | ||
failpoint.Inject("issue30289", func(val failpoint.Value) { | ||
if val.(bool) { | ||
err = errors.Errorf("issue30289 build return error") | ||
e.buildFinished <- errors.Trace(err) | ||
errCh <- errors.Trace(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.
fetchBuildSideRows
and fetchAndBuildHashTable
are running in parallel. So fetchAndBuildHashTable
may close buildFinished
before fetchBuildSideRows
is finised.
Signed-off-by: xhe <xw897002528@gmail.com>
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 2fdb71a
|
In response to a cherrypick label: new pull request created: #39054. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #39055. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: cannot checkout |
In response to a cherrypick label: new pull request created: #39056. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #39057. |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created: #39058. |
TiDB MergeCI notify✅ Well Done! New fixed [1] after this pr merged.
|
Signed-off-by: xhe xw897002528@gmail.com
What problem does this PR solve?
Issue Number: close #39026
Problem Summary:
fetchAndBuildHashTable
leaked even afterrs.Close()
.What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.