Skip to content

Commit

Permalink
executor: release memory usage of task in indexJoin/indexHashJoin (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jun 17, 2022
1 parent 60be3f4 commit b38ace3
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 @@ -483,6 +483,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 @@ -332,6 +332,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 @@ -573,7 +577,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 looUpKeys the same length as outer Result.
Expand Down

0 comments on commit b38ace3

Please sign in to comment.