diff --git a/executor/index_lookup_hash_join.go b/executor/index_lookup_hash_join.go index 75d84c2162480..0beb3e59e66b1 100644 --- a/executor/index_lookup_hash_join.go +++ b/executor/index_lookup_hash_join.go @@ -148,6 +148,7 @@ func (e *IndexNestedLoopHashJoin) Open(ctx context.Context) error { } e.memTracker = memory.NewTracker(e.id, -1) e.memTracker.AttachTo(e.ctx.GetSessionVars().StmtCtx.MemTracker) + e.cancelFunc = nil e.innerPtrBytes = make([][]byte, 0, 8) if e.runtimeStats != nil { e.stats = &indexLookUpJoinRuntimeStats{} @@ -311,7 +312,6 @@ func (e *IndexNestedLoopHashJoin) isDryUpTasks(ctx context.Context) bool { func (e *IndexNestedLoopHashJoin) Close() error { if e.cancelFunc != nil { e.cancelFunc() - e.cancelFunc = nil } if e.resultCh != nil { for range e.resultCh { diff --git a/executor/index_lookup_join.go b/executor/index_lookup_join.go index ff5d317e2bb5b..4be2f24272ae4 100644 --- a/executor/index_lookup_join.go +++ b/executor/index_lookup_join.go @@ -174,6 +174,7 @@ func (e *IndexLookUpJoin) Open(ctx context.Context) error { e.stats = &indexLookUpJoinRuntimeStats{} e.ctx.GetSessionVars().StmtCtx.RuntimeStatsColl.RegisterStats(e.id, e.stats) } + e.cancelFunc = nil e.startWorkers(ctx) return nil }