diff --git a/cmd/server_test.go b/cmd/server_test.go index 4c604af620c..34c6444dbf3 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -168,7 +168,7 @@ func (s *serverSuite) TestLoadAndVerifyServerConfig(c *check.C) { KeyPath: "cc", CertAllowedCN: []string{"dd", "ee"}, }, - PerTableMemoryQuota: 20 * 1024 * 1024, // 20M + PerTableMemoryQuota: 10 * 1024 * 1024, // 10M KVClient: &config.KVClientConfig{ WorkerConcurrent: 8, WorkerPoolSize: 0, @@ -241,7 +241,7 @@ sort-dir = "/tmp/just_a_test" SortDir: config.DefaultSortDir, }, Security: &config.SecurityConfig{}, - PerTableMemoryQuota: 20 * 1024 * 1024, // 20M + PerTableMemoryQuota: 10 * 1024 * 1024, // 10M KVClient: &config.KVClientConfig{ WorkerConcurrent: 8, WorkerPoolSize: 0, @@ -309,7 +309,7 @@ cert-allowed-cn = ["dd","ee"] KeyPath: "cc", CertAllowedCN: []string{"dd", "ee"}, }, - PerTableMemoryQuota: 20 * 1024 * 1024, // 20M + PerTableMemoryQuota: 10 * 1024 * 1024, // 10M KVClient: &config.KVClientConfig{ WorkerConcurrent: 8, WorkerPoolSize: 0, diff --git a/pkg/config/config.go b/pkg/config/config.go index 17b39523b74..e98847475f8 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -189,7 +189,7 @@ var defaultServerConfig = &ServerConfig{ SortDir: DefaultSortDir, }, Security: &SecurityConfig{}, - PerTableMemoryQuota: 20 * 1024 * 1024, // 20MB + PerTableMemoryQuota: 10 * 1024 * 1024, // 10MB KVClient: &KVClientConfig{ WorkerConcurrent: 8, WorkerPoolSize: 0, // 0 will use NumCPU() * 2 @@ -301,9 +301,9 @@ func (c *ServerConfig) ValidateAndAdjust() error { } } - conf := GetDefaultServerConfig() + defaultCfg := GetDefaultServerConfig() if c.Sorter == nil { - c.Sorter = conf.Sorter + c.Sorter = defaultCfg.Sorter } c.Sorter.SortDir = DefaultSortDir err := c.Sorter.ValidateAndAdjust() @@ -312,14 +312,11 @@ func (c *ServerConfig) ValidateAndAdjust() error { } if c.PerTableMemoryQuota == 0 { - c.PerTableMemoryQuota = conf.PerTableMemoryQuota - } - if c.PerTableMemoryQuota < 6*1024*1024 { - return cerror.ErrInvalidServerOption.GenWithStackByArgs("per-table-memory-quota should be at least 6MB") + c.PerTableMemoryQuota = defaultCfg.PerTableMemoryQuota } if c.KVClient == nil { - c.KVClient = conf.KVClient + c.KVClient = defaultCfg.KVClient } if c.KVClient.WorkerConcurrent <= 0 { return cerror.ErrInvalidServerOption.GenWithStackByArgs("region-scan-limit should be at least 1") diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 1e8aefe5d7a..42974acff1d 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -75,6 +75,7 @@ func (s *replicaConfigSuite) TestOutDated(c *check.C) { c.Assert(conf2, check.DeepEquals, conf) } +<<<<<<< HEAD type serverConfigSuite struct{} var _ = check.Suite(&serverConfigSuite{}) @@ -82,6 +83,11 @@ var _ = check.Suite(&serverConfigSuite{}) func (s *serverConfigSuite) TestMarshal(c *check.C) { defer testleak.AfterTest(c)() rawConfig := `{"addr":"192.155.22.33:8887","advertise-addr":"","log-file":"","log-level":"info","log":{"file":{"max-size":300,"max-days":0,"max-backups":0}},"data-dir":"","gc-ttl":86400,"tz":"System","capture-session-ttl":10,"owner-flush-interval":200000000,"processor-flush-interval":100000000,"sorter":{"num-concurrent-worker":4,"chunk-size-limit":999,"max-memory-percentage":30,"max-memory-consumption":17179869184,"num-workerpool-goroutine":16,"sort-dir":"/tmp/sorter"},"security":{"ca-path":"","cert-path":"","key-path":"","cert-allowed-cn":null},"per-table-memory-quota":20971520,"kv-client":{"worker-concurrent":8,"worker-pool-size":0,"region-scan-limit":6}}` +======= +func TestServerConfigMarshal(t *testing.T) { + t.Parallel() + rawConfig := `{"addr":"192.155.22.33:8887","advertise-addr":"","log-file":"","log-level":"info","log":{"file":{"max-size":300,"max-days":0,"max-backups":0}},"data-dir":"","gc-ttl":86400,"tz":"System","capture-session-ttl":10,"owner-flush-interval":200000000,"processor-flush-interval":100000000,"sorter":{"num-concurrent-worker":4,"chunk-size-limit":999,"max-memory-percentage":30,"max-memory-consumption":17179869184,"num-workerpool-goroutine":16,"sort-dir":"/tmp/sorter"},"security":{"ca-path":"","cert-path":"","key-path":"","cert-allowed-cn":null},"per-table-memory-quota":10485760,"kv-client":{"worker-concurrent":8,"worker-pool-size":0,"region-scan-limit":40}}` +>>>>>>> be1f3fe4c (config: remove per-table-memory-quota min value check (#3022)) conf := GetDefaultServerConfig() conf.Addr = "192.155.22.33:8887" @@ -129,5 +135,13 @@ func (s *serverConfigSuite) TestValidateAndAdjust(c *check.C) { c.Assert(conf.ValidateAndAdjust(), check.ErrorMatches, ".*does not contain a port") conf.AdvertiseAddr = "advertise:1234" conf.PerTableMemoryQuota = 1 +<<<<<<< HEAD c.Assert(conf.ValidateAndAdjust(), check.ErrorMatches, ".*should be at least.*") +======= + require.Nil(t, conf.ValidateAndAdjust()) + require.EqualValues(t, 1, conf.PerTableMemoryQuota) + conf.PerTableMemoryQuota = 0 + require.Nil(t, conf.ValidateAndAdjust()) + require.EqualValues(t, GetDefaultServerConfig().PerTableMemoryQuota, conf.PerTableMemoryQuota) +>>>>>>> be1f3fe4c (config: remove per-table-memory-quota min value check (#3022)) }