Skip to content

Commit

Permalink
Fix forever hanging when HashAgg is called by apply (#12760) (#12766)
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 b0ccf68 commit 8485ccd
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 @@ -163,6 +163,7 @@ type HashAggExec struct {
isChildReturnEmpty bool

childResult *chunk.Chunk
executed bool
}

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

Expand Down Expand Up @@ -614,10 +616,14 @@ func (e *HashAggExec) parallelExec(ctx context.Context, chk *chunk.Chunk) error
}
})

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 8485ccd

Please sign in to comment.