diff --git a/config/config.go b/config/config.go index 1ba2c7fbd1595..ac7b63584c019 100644 --- a/config/config.go +++ b/config/config.go @@ -49,7 +49,8 @@ const ( // DefTxnEntrySizeLimit is the default value of TxnEntrySizeLimit. DefTxnEntrySizeLimit = 6 * 1024 * 1024 // DefTxnTotalSizeLimit is the default value of TxnTxnTotalSizeLimit. - DefTxnTotalSizeLimit = 100 * 1024 * 1024 + DefTxnTotalSizeLimit = 100 * 1024 * 1024 + SuperLargeTxnSize uint64 = 100 * 1024 * 1024 * 1024 * 1024 // 100T, we expect a txn can never be this large // DefMaxIndexLength is the maximum index length(in bytes). This value is consistent with MySQL. DefMaxIndexLength = 3072 // DefMaxOfMaxIndexLength is the maximum index length(in bytes) for TiDB v3.0.7 and previous version. diff --git a/session/session.go b/session/session.go index 3dd2f6a09bd68..93139522830f4 100644 --- a/session/session.go +++ b/session/session.go @@ -3684,6 +3684,11 @@ func (s *session) GetStmtStats() *stmtstats.StatementStats { // SetMemoryFootprintChangeHook sets the hook that is called when the memdb changes its size. // Call this after s.txn becomes valid, since TxnInfo is initialized when the txn becomes valid. func (s *session) SetMemoryFootprintChangeHook() { + if config.GetGlobalConfig().Performance.TxnTotalSizeLimit != config.DefTxnTotalSizeLimit { + // if the user manually specifies the config, don't involve the new memory tracker mechanism, let the old config + // work as before. + return + } hook := func(mem uint64) { if s.sessionVars.MemDBFootprint == nil { tracker := memory.NewTracker(memory.LabelForMemDB, -1) diff --git a/tidb-server/main.go b/tidb-server/main.go index 9b1e58b736844..5895cac6b099f 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -628,7 +628,12 @@ func setGlobalVars() { } plannercore.AllowCartesianProduct.Store(cfg.Performance.CrossJoin) privileges.SkipWithGrant = cfg.Security.SkipGrantTable - kv.TxnTotalSizeLimit = cfg.Performance.TxnTotalSizeLimit + if cfg.Performance.TxnTotalSizeLimit == config.DefTxnTotalSizeLimit { + // practically deprecate the config, let the new session memory tracker take charge of it. + kv.TxnTotalSizeLimit = config.SuperLargeTxnSize + } else { + kv.TxnTotalSizeLimit = cfg.Performance.TxnTotalSizeLimit + } if cfg.Performance.TxnEntrySizeLimit > 120*1024*1024 { log.Fatal("cannot set txn entry size limit larger than 120M") }