Skip to content

Commit

Permalink
Fix forever hanging when HashAgg is called by apply (pingcap#12760) (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
SunRunAway authored and sre-bot committed Oct 17, 2019
1 parent f8932fb commit cf7f6f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ type HashAggExec struct {
isChildReturnEmpty bool

childResult *chunk.Chunk
executed bool
}

// HashAggInput indicates the input of hash agg exec.
Expand Down Expand Up @@ -214,6 +215,7 @@ func (e *HashAggExec) Close() error {
}
for range e.finalOutputCh {
}
e.executed = false
return e.baseExecutor.Close()
}

Expand Down Expand Up @@ -602,10 +604,14 @@ func (e *HashAggExec) parallelExec(ctx context.Context, chk *chunk.Chunk) error
e.prepared = true
}

if e.executed {
return nil
}
for !chk.IsFull() {
e.finalInputCh <- chk
result, ok := <-e.finalOutputCh
if !ok { // all finalWorkers exited
e.executed = true
if chk.NumRows() > 0 { // but there are some data left
return nil
}
Expand Down

0 comments on commit cf7f6f1

Please sign in to comment.