From def7f54caa67fdc0ee97446bc423597a2d605e91 Mon Sep 17 00:00:00 2001 From: Youra Cho Date: Mon, 16 May 2022 11:04:50 -0700 Subject: [PATCH 1/2] config, session: add upgrade to bootstrap --- config/config.go | 4 ++++ session/bootstrap.go | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 3d5df22e04768..c8811d136b615 100644 --- a/config/config.go +++ b/config/config.go @@ -258,6 +258,10 @@ type Config struct { // EnableBatchDML, unused since bootstrap v90 EnableBatchDML bool `toml:"enable-batch-dml" json:"enable-batch-dml"` + // MemQuotaQuery,QueryLogMaxLen,CommitterConcurrency, unused since bootstrap v91 + MemQuotaQuery int64 `toml:"mem-quota-query" json:"mem-quota-query"` + QueryLogMaxLen uint64 `toml:"query-log-max-len" json:"query-log-max-len"` + CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"` } // UpdateTempStoragePath is to update the `TempStoragePath` if port/statusPort was changed diff --git a/session/bootstrap.go b/session/bootstrap.go index 37d98a7155874..66655ac61ce70 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -617,11 +617,13 @@ const ( version89 = 89 // version90 converts enable-batch-dml to a sysvar version90 = 90 + // version91 converts mem-quota-query, query-log-max-len, committer-concurrency to a sysvar + version91 = 91 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. // please make sure this is the largest version -var currentBootstrapVersion int64 = version90 +var currentBootstrapVersion int64 = version91 var ( bootstrapVersion = []func(Session, int64){ @@ -715,6 +717,7 @@ var ( upgradeToVer88, upgradeToVer89, upgradeToVer90, + upgradeToVer91, } ) @@ -1848,6 +1851,18 @@ func upgradeToVer90(s Session, ver int64) { importConfigOption(s, "enable-batch-dml", variable.TiDBEnableBatchDML, valStr) } +func upgradeToVer91(s Session, ver int64) { + if ver >= version91 { + return + } + valStr := fmt.Sprint(config.GetGlobalConfig().MemQuotaQuery) + importConfigOption(s, "mem-quota-query", variable.TiDBMemQuotaQuery, valStr) + valStr = fmt.Sprint((config.GetGlobalConfig().QueryLogMaxLen), 10) + importConfigOption(s, "query-log-max-len", variable.TiDBQueryLogMaxLen, valStr) + valStr = fmt.Sprint(config.GetGlobalConfig().CommitterConcurrency) + importConfigOption(s, "committer-concurrency", variable.TiDBCommitterConcurrency, 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= %?`, From cc4326a694815d7a0ab806dd4579aa0ff7b9c1e0 Mon Sep 17 00:00:00 2001 From: Youra Cho Date: Wed, 18 May 2022 11:27:18 -0700 Subject: [PATCH 2/2] Combine all upgrades into Ver90 --- config/config.go | 24 ++++++++++++++++-------- session/bootstrap.go | 23 +++++++++-------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/config/config.go b/config/config.go index 66fca3b3daec2..f9a65ccf1c2bc 100644 --- a/config/config.go +++ b/config/config.go @@ -162,7 +162,6 @@ type Config struct { TokenLimit uint `toml:"token-limit" json:"token-limit"` OOMUseTmpStorage bool `toml:"oom-use-tmp-storage" json:"oom-use-tmp-storage"` TempStoragePath string `toml:"tmp-storage-path" json:"tmp-storage-path"` - OOMAction string `toml:"oom-action" json:"oom-action"` // TempStorageQuota describe the temporary storage Quota during query exector when OOMUseTmpStorage is enabled // If the quota exceed the capacity of the TempStoragePath, the tidb-server would exit with fatal error TempStorageQuota int64 `toml:"tmp-storage-quota" json:"tmp-storage-quota"` // Bytes @@ -258,12 +257,10 @@ type Config struct { // The following items are deprecated. We need to keep them here temporarily // to support the upgrade process. They can be removed in future. - // EnableBatchDML, unused since bootstrap v90 - EnableBatchDML bool `toml:"enable-batch-dml" json:"enable-batch-dml"` - // MemQuotaQuery,QueryLogMaxLen,CommitterConcurrency, unused since bootstrap v91 - MemQuotaQuery int64 `toml:"mem-quota-query" json:"mem-quota-query"` - QueryLogMaxLen uint64 `toml:"query-log-max-len" json:"query-log-max-len"` - CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"` + // EnableBatchDML, MemQuotaQuery, OOMAction unused since bootstrap v90 + EnableBatchDML bool `toml:"enable-batch-dml" json:"enable-batch-dml"` + MemQuotaQuery int64 `toml:"mem-quota-query" json:"mem-quota-query"` + OOMAction string `toml:"oom-action" json:"oom-action"` } // UpdateTempStoragePath is to update the `TempStoragePath` if port/statusPort was changed @@ -433,6 +430,12 @@ type Log struct { SlowThreshold uint64 `toml:"slow-threshold" json:"slow-threshold"` ExpensiveThreshold uint `toml:"expensive-threshold" json:"expensive-threshold"` RecordPlanInSlowLog uint32 `toml:"record-plan-in-slow-log" json:"record-plan-in-slow-log"` + + // The following items are deprecated. We need to keep them here temporarily + // to support the upgrade process. They can be removed in future. + + // QueryLogMaxLen, unused since bootstrap v90 + QueryLogMaxLen uint64 `toml:"query-log-max-len" json:"query-log-max-len"` } // Instance is the section of instance scope system variables. @@ -608,7 +611,6 @@ type Performance struct { TCPKeepAlive bool `toml:"tcp-keep-alive" json:"tcp-keep-alive"` TCPNoDelay bool `toml:"tcp-no-delay" json:"tcp-no-delay"` CrossJoin bool `toml:"cross-join" json:"cross-join"` - RunAutoAnalyze bool `toml:"run-auto-analyze" json:"run-auto-analyze"` DistinctAggPushDown bool `toml:"distinct-agg-push-down" json:"distinct-agg-push-down"` // Whether enable projection push down for coprocessors (both tikv & tiflash), default false. ProjectionPushDown bool `toml:"projection-push-down" json:"projection-push-down"` @@ -622,6 +624,12 @@ type Performance struct { StatsLoadConcurrency uint `toml:"stats-load-concurrency" json:"stats-load-concurrency"` StatsLoadQueueSize uint `toml:"stats-load-queue-size" json:"stats-load-queue-size"` EnableStatsCacheMemQuota bool `toml:"enable-stats-cache-mem-quota" json:"enable-stats-cache-mem-quota"` + // The following items are deprecated. We need to keep them here temporarily + // to support the upgrade process. They can be removed in future. + + // CommitterConcurrency, RunAutoAnalyze unused since bootstrap v90 + CommitterConcurrency int `toml:"committer-concurrency" json:"committer-concurrency"` + RunAutoAnalyze bool `toml:"run-auto-analyze" json:"run-auto-analyze"` } // PlanCache is the PlanCache section of the config. diff --git a/session/bootstrap.go b/session/bootstrap.go index 66655ac61ce70..e6251f6e680d6 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -615,15 +615,13 @@ const ( version88 = 88 // version89 adds the tables mysql.advisory_locks version89 = 89 - // version90 converts enable-batch-dml to a sysvar + // version90 converts enable-batch-dml, mem-quota-query, query-log-max-len, committer-concurrency, run-auto-analyze, and oom-action to a sysvar version90 = 90 - // version91 converts mem-quota-query, query-log-max-len, committer-concurrency to a sysvar - version91 = 91 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. // please make sure this is the largest version -var currentBootstrapVersion int64 = version91 +var currentBootstrapVersion int64 = version90 var ( bootstrapVersion = []func(Session, int64){ @@ -717,7 +715,6 @@ var ( upgradeToVer88, upgradeToVer89, upgradeToVer90, - upgradeToVer91, } ) @@ -1849,18 +1846,16 @@ func upgradeToVer90(s Session, ver int64) { } valStr := variable.BoolToOnOff(config.GetGlobalConfig().EnableBatchDML) importConfigOption(s, "enable-batch-dml", variable.TiDBEnableBatchDML, valStr) -} - -func upgradeToVer91(s Session, ver int64) { - if ver >= version91 { - return - } - valStr := fmt.Sprint(config.GetGlobalConfig().MemQuotaQuery) + valStr = fmt.Sprint(config.GetGlobalConfig().MemQuotaQuery) importConfigOption(s, "mem-quota-query", variable.TiDBMemQuotaQuery, valStr) - valStr = fmt.Sprint((config.GetGlobalConfig().QueryLogMaxLen), 10) + valStr = fmt.Sprint((config.GetGlobalConfig().Log.QueryLogMaxLen), 10) importConfigOption(s, "query-log-max-len", variable.TiDBQueryLogMaxLen, valStr) - valStr = fmt.Sprint(config.GetGlobalConfig().CommitterConcurrency) + valStr = fmt.Sprint(config.GetGlobalConfig().Performance.CommitterConcurrency) importConfigOption(s, "committer-concurrency", variable.TiDBCommitterConcurrency, valStr) + valStr = variable.BoolToOnOff(config.GetGlobalConfig().Performance.RunAutoAnalyze) + importConfigOption(s, "run-auto-analyze", variable.TiDBEnableAutoAnalyze, valStr) + valStr = config.GetGlobalConfig().OOMAction + importConfigOption(s, "oom-action", variable.TiDBMemOOMAction, valStr) } func writeOOMAction(s Session) {