From 7495b06c3bd22c419b8aa5a8f45df364c3f77011 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Mon, 11 Jul 2022 19:41:05 +0800 Subject: [PATCH 1/2] cherry pick #35820 to release-5.0 Signed-off-by: ti-srebot --- executor/index_lookup_hash_join.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/executor/index_lookup_hash_join.go b/executor/index_lookup_hash_join.go index 62fa460c39111..60eb2f17a6d74 100644 --- a/executor/index_lookup_hash_join.go +++ b/executor/index_lookup_hash_join.go @@ -582,7 +582,24 @@ func (iw *indexHashJoinInnerWorker) handleHashJoinInnerWorkerPanic(r interface{} iw.wg.Done() } +<<<<<<< HEAD func (iw *indexHashJoinInnerWorker) handleTask(ctx context.Context, task *indexHashJoinTask, joinResult *indexHashJoinResult, h hash.Hash64, resultCh chan *indexHashJoinResult) error { +======= +func (iw *indexHashJoinInnerWorker) handleTask(ctx context.Context, task *indexHashJoinTask, joinResult *indexHashJoinResult, h hash.Hash64, resultCh chan *indexHashJoinResult) (err error) { + defer func() { + iw.memTracker.Consume(-iw.memTracker.BytesConsumed()) + if task.keepOuterOrder { + if err != nil { + joinResult.err = err + select { + case <-ctx.Done(): + case resultCh <- joinResult: + } + } + close(resultCh) + } + }() +>>>>>>> 87052dc2f... executor: fix index_lookup_hash_join hang when used with limit (#35820) var joinStartTime time.Time if iw.stats != nil { start := time.Now() From b36794b5b32b480f68926e548991c82f8303ef94 Mon Sep 17 00:00:00 2001 From: guo-shaoge Date: Tue, 12 Jul 2022 17:17:20 +0800 Subject: [PATCH 2/2] fix conflict Signed-off-by: guo-shaoge --- executor/index_lookup_hash_join.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/executor/index_lookup_hash_join.go b/executor/index_lookup_hash_join.go index 60eb2f17a6d74..1ee3aa1f995a8 100644 --- a/executor/index_lookup_hash_join.go +++ b/executor/index_lookup_hash_join.go @@ -500,7 +500,10 @@ func (iw *indexHashJoinInnerWorker) run(ctx context.Context, cancelFunc context. joinResult.err = errors.New("mockIndexHashJoinInnerWorkerErr") }) if joinResult.err != nil { - resultCh <- joinResult + select { + case resultCh <- joinResult: + case <-ctx.Done(): + } return } // When task.keepOuterOrder is TRUE(resultCh != iw.resultCh), the last @@ -582,24 +585,7 @@ func (iw *indexHashJoinInnerWorker) handleHashJoinInnerWorkerPanic(r interface{} iw.wg.Done() } -<<<<<<< HEAD func (iw *indexHashJoinInnerWorker) handleTask(ctx context.Context, task *indexHashJoinTask, joinResult *indexHashJoinResult, h hash.Hash64, resultCh chan *indexHashJoinResult) error { -======= -func (iw *indexHashJoinInnerWorker) handleTask(ctx context.Context, task *indexHashJoinTask, joinResult *indexHashJoinResult, h hash.Hash64, resultCh chan *indexHashJoinResult) (err error) { - defer func() { - iw.memTracker.Consume(-iw.memTracker.BytesConsumed()) - if task.keepOuterOrder { - if err != nil { - joinResult.err = err - select { - case <-ctx.Done(): - case resultCh <- joinResult: - } - } - close(resultCh) - } - }() ->>>>>>> 87052dc2f... executor: fix index_lookup_hash_join hang when used with limit (#35820) var joinStartTime time.Time if iw.stats != nil { start := time.Now()