Skip to content

Commit

Permalink
session: tidb_server_memory_limit inherits the value of server-memory…
Browse files Browse the repository at this point in the history
…-quota when upgrading (pingcap#38628)

ref pingcap#37816
  • Loading branch information
wshwsh12 authored Oct 27, 2022
1 parent 1cf6e77 commit fb6a131
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -740,6 +742,7 @@ var (
upgradeToVer93,
upgradeToVer94,
upgradeToVer95,
upgradeToVer96,
}
)

Expand Down Expand Up @@ -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= %?`,
Expand Down

0 comments on commit fb6a131

Please sign in to comment.