Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#51455
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
wshwsh12 authored and ti-chi-bot committed May 31, 2024
1 parent d9c5bf6 commit 4d8368e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 17 additions & 3 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1950,14 +1950,28 @@ func (b *executorBuilder) buildMemTable(v *plannercore.PhysicalMemTable) Executo
strings.ToLower(infoschema.TableMemoryUsage),
strings.ToLower(infoschema.TableMemoryUsageOpsHistory),
strings.ToLower(infoschema.ClusterTableMemoryUsage),
<<<<<<< HEAD:executor/builder.go
strings.ToLower(infoschema.ClusterTableMemoryUsageOpsHistory):
=======
strings.ToLower(infoschema.ClusterTableMemoryUsageOpsHistory),
strings.ToLower(infoschema.TableResourceGroups),
strings.ToLower(infoschema.TableRunawayWatches),
strings.ToLower(infoschema.TableCheckConstraints),
strings.ToLower(infoschema.TableTiDBCheckConstraints),
strings.ToLower(infoschema.TableKeywords),
strings.ToLower(infoschema.TableTiDBIndexUsage),
strings.ToLower(infoschema.ClusterTableTiDBIndexUsage):
memTracker := memory.NewTracker(v.ID(), -1)
memTracker.AttachTo(b.ctx.GetSessionVars().StmtCtx.MemTracker)
>>>>>>> 4f4f911b706 (executor: add memory tracker for memtableRetriever (#51455)):pkg/executor/builder.go
return &MemTableReaderExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ID()),
table: v.Table,
retriever: &memtableRetriever{
table: v.Table,
columns: v.Columns,
extractor: v.Extractor,
table: v.Table,
columns: v.Columns,
extractor: v.Extractor,
memTracker: memTracker,
},
}
case strings.ToLower(infoschema.TableTiDBTrx),
Expand Down
4 changes: 4 additions & 0 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type memtableRetriever struct {
retrieved bool
initialized bool
extractor plannercore.MemTablePredicateExtractor
memTracker *memory.Tracker
}

// retrieve implements the infoschemaRetriever interface
Expand Down Expand Up @@ -189,6 +190,9 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex
return nil, err
}
e.initialized = true
if e.memTracker != nil {
e.memTracker.Consume(calculateDatumsSize(e.rows))
}
}

// Adjust the amount of each return
Expand Down

0 comments on commit 4d8368e

Please sign in to comment.