Repository: pingcap/tidb (Go)

Issue:
upgrade to v6.0.0 fail when old cluster include stmt-summary config
## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

1. install v5.4.0 with config:
stmt-summary.enable
stmt-summary.enable-internal-query
stmt-summary.history-size
stmt-summary.max-sql-length
stmt-summary.max-stmt-count
stmt-summary.refresh-interval
2. upgrade to 6.0.0

### 2. What did you expect to see? (Required)
stmt-summary config can be ignored during upgrade

### 3. What did you see instead (Required)
upgrade fail
Error: init config failed: 172.16.5.101:4000: executor.ssh.execute_failed: Failed to execute command over SSH for 'tidb@172.16.5.101:22' {ssh_stderr: , ssh_stdout: [2022/03/23 12:48:15.840 +08:00] [FATAL] [terror.go:292] ["unexpected error"] [error="config file /home/tidb/deploy/tidb-4000/conf/tidb.toml contained invalid configuration options: enable-streaming, stmt-summary, stmt-summary.enable, stmt-summary.enable-internal-query, stmt-summary.history-size, stmt-summary.max-sql-length, stmt-summary.max-stmt-count, stmt-summary.refresh-interval; check TiDB manual to make sure this option has not been deprecated and removed from your TiDB version if the option does not appear to be a typo"]
### 4. What is your TiDB version? (Required)

v6.0.0                                               2022-03-22T19:47:19+08:00 




Discussion:
@morgo hi, why these stmt-summary configs are not ignored during upgrade



Patch:
diff --git a/config/config.go b/config/config.go
index 533b660581c46..4ffd599416aa7 100644
--- a/config/config.go
+++ b/config/config.go
@@ -778,22 +778,29 @@ func StoreGlobalConfig(config *Config) {
 }
 
 var deprecatedConfig = map[string]struct{}{
-	"pessimistic-txn.ttl":              {},
-	"pessimistic-txn.enable":           {},
-	"log.file.log-rotate":              {},
-	"log.log-slow-query":               {},
-	"txn-local-latches":                {},
-	"txn-local-latches.enabled":        {},
-	"txn-local-latches.capacity":       {},
-	"performance.max-memory":           {},
-	"max-txn-time-use":                 {},
-	"experimental.allow-auto-random":   {},
-	"enable-redact-log":                {}, // use variable tidb_redact_log instead
-	"tikv-client.copr-cache.enable":    {},
-	"alter-primary-key":                {}, // use NONCLUSTERED keyword instead
-	"enable-streaming":                 {},
-	"performance.mem-profile-interval": {},
-	"lower-case-table-names":           {},
+	"pessimistic-txn.ttl":                {},
+	"pessimistic-txn.enable":             {},
+	"log.file.log-rotate":                {},
+	"log.log-slow-query":                 {},
+	"txn-local-latches":                  {},
+	"txn-local-latches.enabled":          {},
+	"txn-local-latches.capacity":         {},
+	"performance.max-memory":             {},
+	"max-txn-time-use":                   {},
+	"experimental.allow-auto-random":     {},
+	"enable-redact-log":                  {}, // use variable tidb_redact_log instead
+	"tikv-client.copr-cache.enable":      {},
+	"alter-primary-key":                  {}, // use NONCLUSTERED keyword instead
+	"enable-streaming":                   {},
+	"performance.mem-profile-interval":   {},
+	"lower-case-table-names":             {},
+	"stmt-summary":                       {},
+	"stmt-summary.enable":                {},
+	"stmt-summary.enable-internal-query": {},
+	"stmt-summary.max-stmt-count":        {},
+	"stmt-summary.max-sql-length":        {},
+	"stmt-summary.refresh-interval":      {},
+	"stmt-summary.history-size":          {},
 }
 
 func isAllDeprecatedConfigItems(items []string) bool {


Test patch:
diff --git a/config/config_test.go b/config/config_test.go
index 913dbe088f0be..bc90a2763bfad 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -327,7 +327,14 @@ grpc-max-send-msg-size = 40960
 [log.file]
 log-rotate = true
 [performance]
-mem-profile-interval="1m"`)
+mem-profile-interval="1m"
+[stmt-summary]
+enable=false
+enable-internal-query=true
+max-stmt-count=1000
+max-sql-length=1024
+refresh-interval=100
+history-size=100`)
 	require.NoError(t, err)
 	err = conf.Load(configFile)
 	tmp := err.(*ErrConfigValidationFailed)