Skip to content

Commit

Permalink
executor: fix data race in the index_lookup_hash_join (#30619)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Dec 11, 2021
1 parent 93e2c12 commit 3dce612
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions executor/index_lookup_hash_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,17 @@ func (e *IndexNestedLoopHashJoin) startWorkers(ctx context.Context) {
innerCh := make(chan *indexHashJoinTask, concurrency)
if e.keepOuterOrder {
e.taskCh = make(chan *indexHashJoinTask, concurrency)
}
e.workerWg.Add(1)
ow := e.newOuterWorker(innerCh)
go util.WithRecovery(func() { ow.run(workerCtx) }, e.finishJoinWorkers)

if !e.keepOuterOrder {
e.resultCh = make(chan *indexHashJoinResult, concurrency)
} else {
// When `keepOuterOrder` is true, each task holds their own `resultCh`
// individually, thus we do not need a global resultCh.
e.resultCh = nil
} else {
e.resultCh = make(chan *indexHashJoinResult, concurrency)
}
e.joinChkResourceCh = make([]chan *chunk.Chunk, concurrency)
e.workerWg.Add(1)
ow := e.newOuterWorker(innerCh)
go util.WithRecovery(func() { ow.run(workerCtx) }, e.finishJoinWorkers)

for i := 0; i < concurrency; i++ {
if !e.keepOuterOrder {
e.joinChkResourceCh[i] = make(chan *chunk.Chunk, 1)
Expand Down

0 comments on commit 3dce612

Please sign in to comment.