diff --git a/executor/index_lookup_hash_join.go b/executor/index_lookup_hash_join.go index 0332e3186a2d8..3a3baa5ec74e1 100644 --- a/executor/index_lookup_hash_join.go +++ b/executor/index_lookup_hash_join.go @@ -620,7 +620,10 @@ func (iw *indexHashJoinInnerWorker) handleTask(ctx context.Context, task *indexH if task.keepOuterOrder { if err != nil { joinResult.err = err - resultCh <- joinResult + select { + case <-ctx.Done(): + case resultCh <- joinResult: + } } close(resultCh) }