Skip to content

Commit

Permalink
cherry pick pingcap#34418 to release-6.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
wshwsh12 authored and ti-srebot committed May 9, 2022
1 parent 36a9810 commit 6db90e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions executor/index_lookup_hash_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ func (iw *indexHashJoinInnerWorker) run(ctx context.Context, cancelFunc context.
}
h, resultCh := fnv.New64(), iw.resultCh
for {
// The previous task has been processed, so release the occupied memory
if task != nil {
task.memTracker.Detach()
}
select {
case <-ctx.Done():
return
Expand Down
6 changes: 5 additions & 1 deletion executor/index_lookup_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ func (e *IndexLookUpJoin) getFinishedTask(ctx context.Context) (*lookUpJoinTask,
return task, nil
}

// The previous task has been processed, so release the occupied memory
if task != nil {
task.memTracker.Detach()
}
select {
case task = <-e.resultCh:
case <-ctx.Done():
Expand Down Expand Up @@ -559,7 +563,7 @@ func (iw *innerWorker) constructLookupContent(task *lookUpJoinTask) ([]*indexJoi
return nil, err
}
if rowIdx == 0 {
iw.lookup.memTracker.Consume(types.EstimatedMemUsage(dLookUpKey, numRows))
iw.memTracker.Consume(types.EstimatedMemUsage(dLookUpKey, numRows))
}
if dHashKey == nil {
// Append null to make lookUpKeys the same length as outer Result.
Expand Down

0 comments on commit 6db90e0

Please sign in to comment.