Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: subtract the old txn size when track the mem usage (#18000) #18062

Merged
merged 1 commit into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion executor/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (e *InsertExec) exec(ctx context.Context, rows [][]types.Datum) error {
if err != nil {
return err
}
txnSize := txn.Size()
sessVars.StmtCtx.AddRecordRows(uint64(len(rows)))
// If you use the IGNORE keyword, duplicate-key error that occurs while executing the INSERT statement are ignored.
// For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in
Expand Down Expand Up @@ -92,7 +93,7 @@ func (e *InsertExec) exec(ctx context.Context, rows [][]types.Datum) error {
}
}
}
e.memTracker.Consume(int64(txn.Size()))
e.memTracker.Consume(int64(txn.Size() - txnSize))
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion executor/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (e *ReplaceExec) exec(ctx context.Context, newRows [][]types.Datum) error {
if err != nil {
return err
}
txnSize := txn.Size()

// Use BatchGet to fill cache.
// It's an optimization and could be removed without affecting correctness.
Expand All @@ -206,7 +207,7 @@ func (e *ReplaceExec) exec(ctx context.Context, newRows [][]types.Datum) error {
return err
}
}
e.memTracker.Consume(int64(txn.Size()))
e.memTracker.Consume(int64(txn.Size() - txnSize))
return nil
}

Expand Down