Skip to content

Commit

Permalink
executor: fix data race in hash join v2 spill (#57519)
Browse files Browse the repository at this point in the history
ref #57450
  • Loading branch information
windtalker authored Nov 20, 2024
1 parent 5450000 commit 5116115
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pkg/executor/join/hash_join_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,6 @@ func (b *BuildWorkerV2) splitPartitionAndAppendToRowTableForRestore(inDisk *chun
}
}()

partitionNumber := b.HashJoinCtx.partitionNumber
hashJoinCtx := b.HashJoinCtx

b.builder = createRowTableBuilder(b.BuildKeyColIdx, hashJoinCtx.BuildKeyTypes, partitionNumber, b.HasNullableKey, hashJoinCtx.BuildFilter != nil, hashJoinCtx.needScanRowTableAfterProbeDone)

hasErr := false
chunkNum := inDisk.NumChunks()
for i := 0; i < chunkNum; i++ {
Expand Down Expand Up @@ -544,10 +539,6 @@ func (b *BuildWorkerV2) splitPartitionAndAppendToRowTable(typeCtx types.Context,
setMaxValue(&b.HashJoinCtx.stats.maxPartitionData, cost)
}
}()
partitionNumber := b.HashJoinCtx.partitionNumber
hashJoinCtx := b.HashJoinCtx

b.builder = createRowTableBuilder(b.BuildKeyColIdx, hashJoinCtx.BuildKeyTypes, partitionNumber, b.HasNullableKey, hashJoinCtx.BuildFilter != nil, hashJoinCtx.needScanRowTableAfterProbeDone)

hasErr := false
for chk := range srcChkCh {
Expand Down Expand Up @@ -1263,6 +1254,11 @@ func (e *HashJoinV2Exec) fetchAndBuildHashTableImpl(ctx context.Context) {

// doneCh is used by the consumer(splitAndAppendToRowTable) to info the producer(fetchBuildSideRows) that the consumer meet error and stop consume data
doneCh := make(chan struct{}, e.Concurrency)
// init builder, todo maybe the builder can be reused during the whole life cycle of the executor
hashJoinCtx := e.HashJoinCtxV2
for _, worker := range e.BuildWorkers {
worker.builder = createRowTableBuilder(worker.BuildKeyColIdx, hashJoinCtx.BuildKeyTypes, hashJoinCtx.partitionNumber, worker.HasNullableKey, hashJoinCtx.BuildFilter != nil, hashJoinCtx.needScanRowTableAfterProbeDone)
}
srcChkCh, waitForController := e.fetchBuildSideRows(ctx, fetcherAndWorkerSyncer, wg, errCh, doneCh)
e.splitAndAppendToRowTable(srcChkCh, waitForController, fetcherAndWorkerSyncer, wg, errCh, doneCh)
success := waitJobDone(wg, errCh)
Expand Down

0 comments on commit 5116115

Please sign in to comment.