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

session: tidb_server_memory_limit inherits the value of server-memory-quota when upgrading #38628

Merged
merged 3 commits into from
Oct 27, 2022
Merged
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
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