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: break innerTable fetcher is error happend during fetching outer table #7554

Merged
merged 4 commits into from
Aug 30, 2018
Merged
Changes from 3 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
14 changes: 14 additions & 0 deletions executor/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func (e *HashJoinExec) Close() error {
close(e.closeCh)
e.finished.Store(true)
if e.prepared {
if e.innerFinished != nil {
for range e.innerFinished {
}
}
if e.joinResultCh != nil {
for range e.joinResultCh {
}
Expand Down Expand Up @@ -264,6 +268,9 @@ func (e *HashJoinExec) fetchInnerRows(ctx context.Context) (err error) {
e.innerResult.GetMemTracker().AttachTo(e.memTracker)
e.innerResult.GetMemTracker().SetLabel("innerResult")
for {
if e.finished.Load().(bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the outer table error happened after this and before Next, there is still race.

Copy link
Member

Choose a reason for hiding this comment

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

we need a wait group or mutex to block the close operation on child until this goroutine finishes.

return nil
}
chk := e.children[e.innerIdx].newChunk()
err = e.innerExec.Next(ctx, chk)
if err != nil || chk.NumRows() == 0 {
Expand Down Expand Up @@ -511,6 +518,10 @@ func (e *HashJoinExec) fetchInnerAndBuildHashTable(ctx context.Context) {
return
}

if e.finished.Load().(bool) {
return
}

if err := e.buildHashTableForList(); err != nil {
e.innerFinished <- errors.Trace(err)
return
Expand All @@ -533,6 +544,9 @@ func (e *HashJoinExec) buildHashTableForList() error {
valBuf = make([]byte, 8)
)
for i := 0; i < e.innerResult.NumChunks(); i++ {
if e.finished.Load().(bool) {
Copy link
Member

Choose a reason for hiding this comment

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

this check can be removed, because we only need to guarantee not calling the next function of the child.

return nil
}
chk := e.innerResult.GetChunk(i)
for j := 0; j < chk.NumRows(); j++ {
hasNull, keyBuf, err = e.getJoinKeyFromChkRow(false, chk.GetRow(j), keyBuf)
Expand Down