From ca7ff0a04eb7d71ddf5e4fb8cbc83878ddfed605 Mon Sep 17 00:00:00 2001 From: Shenghui Wu <793703860@qq.com> Date: Mon, 17 Jan 2022 23:03:44 +0800 Subject: [PATCH] executor: fix data race in the IndexNestedLoopHashJoin (#31731) close pingcap/tidb#31467 --- executor/index_lookup_hash_join.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/executor/index_lookup_hash_join.go b/executor/index_lookup_hash_join.go index 503dad70a8731..400a2b1d91638 100644 --- a/executor/index_lookup_hash_join.go +++ b/executor/index_lookup_hash_join.go @@ -498,7 +498,9 @@ func (iw *indexHashJoinInnerWorker) run(ctx context.Context, cancelFunc context. break } err := iw.handleTask(ctx, task, joinResult, h, resultCh) - if err != nil { + if err != nil && !task.keepOuterOrder { + // Only need check non-keep-outer-order case because the + // `joinResult` had been sent to the `resultCh` when err != nil. joinResult.err = err break }