Skip to content

Commit

Permalink
executor: fix data race of parallel apply operator (#24257) (#24345)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jun 18, 2021
1 parent d233624 commit 2c4be62
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion executor/parallel_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ func (e *ParallelNestedLoopApplyExec) Next(ctx context.Context, req *chunk.Chunk
// Close implements the Executor interface.
func (e *ParallelNestedLoopApplyExec) Close() error {
e.memTracker = nil
err := e.outerExec.Close()
if atomic.LoadUint32(&e.started) == 1 {
close(e.exit)
e.notifyWg.Wait()
e.started = 0
}
// Wait all workers to finish before Close() is called.
// Otherwise we may got data race.
err := e.outerExec.Close()

if e.runtimeStats != nil {
runtimeStats := newJoinRuntimeStats()
Expand Down

0 comments on commit 2c4be62

Please sign in to comment.