Skip to content

Commit

Permalink
config: remove per-table-memory-quota min value check (#3022) (#3038)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Oct 14, 2021
1 parent 25ed6dc commit 4c01bc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 5 additions & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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")
Expand Down
8 changes: 6 additions & 2 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ 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}}`
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":6}}`

conf := GetDefaultServerConfig()
conf.Addr = "192.155.22.33:8887"
Expand Down Expand Up @@ -129,5 +129,9 @@ 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
c.Assert(conf.ValidateAndAdjust(), check.ErrorMatches, ".*should be at least.*")
c.Assert(conf.ValidateAndAdjust(), check.IsNil)
c.Assert(uint64(1), check.Equals, conf.PerTableMemoryQuota)
conf.PerTableMemoryQuota = 0
c.Assert(conf.ValidateAndAdjust(), check.IsNil)
c.Assert(GetDefaultServerConfig().PerTableMemoryQuota, check.Equals, conf.PerTableMemoryQuota)
}

0 comments on commit 4c01bc6

Please sign in to comment.