diff --git a/session/txn.go b/session/txn.go index 7486525bdc182..20990f26010d9 100644 --- a/session/txn.go +++ b/session/txn.go @@ -545,17 +545,10 @@ func (s *session) HasDirtyContent(tid int64) bool { // StmtCommit implements the sessionctx.Context interface. func (s *session) StmtCommit(memTracker *memory.Tracker) error { defer func() { - // If StmtCommit is called in batch mode, we need to clear the txn size - // in memTracker to avoid double-counting. If it's not batch mode, this - // work has no effect because that no more data will be appended into - // s.txn. - if memTracker != nil { - memTracker.Consume(int64(-s.txn.Size())) - } s.txn.cleanup() }() + st := &s.txn - txnSize := st.Transaction.Size() if _, err := st.Flush(); err != nil { return err @@ -571,9 +564,6 @@ func (s *session) StmtCommit(memTracker *memory.Tracker) error { st.doNotCommit = err return err } - if memTracker != nil { - memTracker.Consume(int64(st.Transaction.Size() - txnSize)) - } // Need to flush binlog. for tableID, delta := range st.mutations {