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

Fix forever hanging when HashAgg is called by apply (#12760) #12769

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