Skip to content

Commit

Permalink
executor: improve set config error message for ms (pingcap#52910)
Browse files Browse the repository at this point in the history
  • Loading branch information
rleungx authored Jul 19, 2024
1 parent 708cbfe commit da31af8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/executor/set_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ type SetConfigExec struct {
func (s *SetConfigExec) Open(context.Context) error {
if s.p.Type != "" {
s.p.Type = strings.ToLower(s.p.Type)
if s.p.Type != "tikv" && s.p.Type != "tidb" && s.p.Type != "pd" && s.p.Type != "tiflash" {
if s.p.Type != "tikv" && s.p.Type != "tidb" && s.p.Type != "pd" && s.p.Type != "tiflash" && s.p.Type != "tso" && s.p.Type != "scheduling" {
return errors.Errorf("unknown type %v", s.p.Type)
}
if s.p.Type == "tidb" {
return errors.Errorf("TiDB doesn't support to change configs online, please use SQL variables")
}
if s.p.Type == "tso" || s.p.Type == "scheduling" {
return errors.Errorf("%s doesn't support to change configs online", s.p.Type)
}
}
if s.p.Instance != "" {
s.p.Instance = strings.ToLower(s.p.Instance)
Expand Down
4 changes: 4 additions & 0 deletions pkg/executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,8 @@ func TestSetClusterConfig(t *testing.T) {
{ServerType: "tikv", Address: "127.0.0.1:5555", StatusAddr: "127.0.0.1:5555"},
{ServerType: "tikv", Address: "127.0.0.1:6666", StatusAddr: "127.0.0.1:6666"},
{ServerType: "tiflash", Address: "127.0.0.1:3933", StatusAddr: "127.0.0.1:7777"},
{ServerType: "tso", Address: "127.0.0.1:22379", StatusAddr: "127.0.0.1:22379"},
{ServerType: "scheduling", Address: "127.0.0.1:22479", StatusAddr: "127.0.0.1:22479"},
}
var serverInfoErr error
serverInfoFunc := func(sessionctx.Context) ([]infoschema.ServerInfo, error) {
Expand All @@ -1635,6 +1637,8 @@ func TestSetClusterConfig(t *testing.T) {

require.EqualError(t, tk.ExecToErr("set config xxx log.level='info'"), "unknown type xxx")
require.EqualError(t, tk.ExecToErr("set config tidb log.level='info'"), "TiDB doesn't support to change configs online, please use SQL variables")
require.EqualError(t, tk.ExecToErr("set config tso log.level='info'"), "tso doesn't support to change configs online")
require.EqualError(t, tk.ExecToErr("set config scheduling log.level='info'"), "scheduling doesn't support to change configs online")
require.EqualError(t, tk.ExecToErr("set config '127.0.0.1:1111' log.level='info'"), "TiDB doesn't support to change configs online, please use SQL variables")
require.EqualError(t, tk.ExecToErr("set config '127.a.b.c:1234' log.level='info'"), "invalid instance 127.a.b.c:1234") // name doesn't resolve.
require.EqualError(t, tk.ExecToErr("set config 'example.com:1111' log.level='info'"), "instance example.com:1111 is not found in this cluster") // name resolves.
Expand Down

0 comments on commit da31af8

Please sign in to comment.