From fb6a13169ebc08e9987fe431430fb7f45d50e85f Mon Sep 17 00:00:00 2001 From: Shenghui Wu <793703860@qq.com> Date: Thu, 27 Oct 2022 15:23:57 +0800 Subject: [PATCH] session: tidb_server_memory_limit inherits the value of server-memory-quota when upgrading (#38628) ref pingcap/tidb#37816 --- session/bootstrap.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/session/bootstrap.go b/session/bootstrap.go index cfebc0d005704..fcd1aa001847f 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -635,6 +635,8 @@ const ( version94 = 94 // version95 add a column `User_attributes` to `mysql.user` version95 = 95 + // version96 converts server-memory-quota to a sysvar + version96 = 96 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. @@ -740,6 +742,7 @@ var ( upgradeToVer93, upgradeToVer94, upgradeToVer95, + upgradeToVer96, } ) @@ -1942,6 +1945,14 @@ func upgradeToVer95(s Session, ver int64) { doReentrantDDL(s, "ALTER TABLE mysql.user ADD COLUMN IF NOT EXISTS `User_attributes` JSON") } +func upgradeToVer96(s Session, ver int64) { + if ver >= version96 { + return + } + valStr := strconv.Itoa(int(config.GetGlobalConfig().Performance.ServerMemoryQuota)) + importConfigOption(s, "performance.server-memory-quota", variable.TiDBServerMemoryLimit, valStr) +} + func writeOOMAction(s Session) { comment := "oom-action is `log` by default in v3.0.x, `cancel` by default in v4.0.11+" mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, %?) ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`,