From 8ba89bda26b03f7da2bfe527214176f9019933ed Mon Sep 17 00:00:00 2001 From: Feng Liyuan Date: Tue, 6 Aug 2019 16:17:39 +0800 Subject: [PATCH 1/2] fix data race --- executor/join.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/executor/join.go b/executor/join.go index 50f444ad82e29..16b7549111723 100644 --- a/executor/join.go +++ b/executor/join.go @@ -542,8 +542,11 @@ func (e *HashJoinExec) fetchInnerAndBuildHashTable(ctx context.Context) { err := e.buildHashTableForList(innerResultCh) if err != nil { e.innerFinished <- errors.Trace(err) + close(doneCh) + } + // wait fetchInnerRows be finished. + for range innerResultCh { } - close(doneCh) } // buildHashTableForList builds hash table from `list`. From a459375995430cf4e3e6cb60e6dbaa5000b5b813 Mon Sep 17 00:00:00 2001 From: Feng Liyuan Date: Thu, 15 Aug 2019 14:53:51 +0800 Subject: [PATCH 2/2] add comment --- executor/join.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/executor/join.go b/executor/join.go index 269d754686b64..2b3eae1d5d06e 100644 --- a/executor/join.go +++ b/executor/join.go @@ -543,7 +543,9 @@ func (e *HashJoinExec) fetchInnerAndBuildHashTable(ctx context.Context) { e.innerFinished <- errors.Trace(err) close(doneCh) } - // wait fetchInnerRows be finished. + // Wait fetchInnerRows be finished. + // 1. if buildHashTableForList fails + // 2. if outerResult.NumRows() == 0, fetchOutChunks will not wait for inner. for range innerResultCh { } }