From acba0cd1e2b05c48dfed4f93de0bcc0e7dc13df0 Mon Sep 17 00:00:00 2001 From: xzhangxian1008 Date: Fri, 20 Dec 2024 16:02:29 +0800 Subject: [PATCH] executor: fix the data race in hash join tests (#58406) close pingcap/tidb#58286 --- pkg/executor/join/hash_join_spill_helper.go | 4 ++-- pkg/executor/join/hash_join_v2.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/executor/join/hash_join_spill_helper.go b/pkg/executor/join/hash_join_spill_helper.go index e2612f0d4e11f..7d8ec2150a1ae 100644 --- a/pkg/executor/join/hash_join_spill_helper.go +++ b/pkg/executor/join/hash_join_spill_helper.go @@ -81,7 +81,7 @@ type hashJoinSpillHelper struct { spillTriggedInBuildingStageForTest bool spillTriggeredBeforeBuildingHashTableForTest bool allPartitionsSpilledForTest bool - skipProbeInRestoreForTest bool + skipProbeInRestoreForTest atomic.Bool } func newHashJoinSpillHelper(hashJoinExec *HashJoinV2Exec, partitionNum int, probeFieldTypes []*types.FieldType) *hashJoinSpillHelper { @@ -554,7 +554,7 @@ func (h *hashJoinSpillHelper) initTmpSpillBuildSideChunks() { } func (h *hashJoinSpillHelper) isProbeSkippedInRestoreForTest() bool { - return h.skipProbeInRestoreForTest + return h.skipProbeInRestoreForTest.Load() } func (h *hashJoinSpillHelper) isRespillTriggeredForTest() bool { diff --git a/pkg/executor/join/hash_join_v2.go b/pkg/executor/join/hash_join_v2.go index ca18d0d58eb63..abb7657ae5562 100644 --- a/pkg/executor/join/hash_join_v2.go +++ b/pkg/executor/join/hash_join_v2.go @@ -933,7 +933,7 @@ func (w *ProbeWorkerV2) processOneProbeChunk(probeChunk *chunk.Chunk, joinResult func (w *ProbeWorkerV2) probeAndSendResult(joinResult *hashjoinWorkerResult) (bool, int64, *hashjoinWorkerResult) { if w.HashJoinCtx.spillHelper.areAllPartitionsSpilled() { if intest.InTest && w.HashJoinCtx.spillHelper.hashJoinExec.inRestore { - w.HashJoinCtx.spillHelper.skipProbeInRestoreForTest = true + w.HashJoinCtx.spillHelper.skipProbeInRestoreForTest.Store(true) } return true, 0, joinResult }