-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.
Description
Enhancement
In #33769 two of the issues need to make changes to session/bootstrap.go so that they change the oom-action and run-auto-analyze settings for when bootstrapping in the test suite.
This made it very clear that this code is currently not very clean, and could be improved:
Lines 1967 to 2011 in d2ada35
| // Init global system variables table. | |
| values := make([]string, 0, len(variable.GetSysVars())) | |
| for k, v := range variable.GetSysVars() { | |
| // Only global variables should be inserted. | |
| if v.HasGlobalScope() { | |
| vVal := v.Value | |
| if v.Name == variable.TiDBTxnMode && config.GetGlobalConfig().Store == "tikv" { | |
| vVal = "pessimistic" | |
| } | |
| if v.Name == variable.TiDBRowFormatVersion { | |
| vVal = strconv.Itoa(variable.DefTiDBRowFormatV2) | |
| } | |
| if v.Name == variable.TiDBPartitionPruneMode { | |
| vVal = variable.DefTiDBPartitionPruneMode | |
| if flag.Lookup("test.v") != nil || flag.Lookup("check.v") != nil || config.CheckTableBeforeDrop { | |
| // enable Dynamic Prune by default in test case. | |
| vVal = string(variable.Dynamic) | |
| } | |
| } | |
| if v.Name == variable.TiDBEnableChangeMultiSchema { | |
| vVal = variable.Off | |
| if flag.Lookup("test.v") != nil || flag.Lookup("check.v") != nil { | |
| // enable change multi schema in test case for compatibility with old cases. | |
| vVal = variable.On | |
| } | |
| } | |
| if v.Name == variable.TiDBEnableAsyncCommit && config.GetGlobalConfig().Store == "tikv" { | |
| vVal = variable.On | |
| } | |
| if v.Name == variable.TiDBEnable1PC && config.GetGlobalConfig().Store == "tikv" { | |
| vVal = variable.On | |
| } | |
| if v.Name == variable.TiDBEnableMutationChecker { | |
| vVal = variable.On | |
| } | |
| if v.Name == variable.TiDBTxnAssertionLevel { | |
| vVal = variable.AssertionFastStr | |
| } | |
| value := fmt.Sprintf(`("%s", "%s")`, strings.ToLower(k), vVal) | |
| values = append(values, value) | |
| } | |
| } | |
| sql := fmt.Sprintf("INSERT HIGH_PRIORITY INTO %s.%s VALUES %s;", mysql.SystemDB, mysql.GlobalVariablesTable, | |
| strings.Join(values, ", ")) | |
| mustExecute(s, sql) |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type/enhancementThe issue or PR belongs to an enhancement.The issue or PR belongs to an enhancement.