Skip to content

Commit

Permalink
config: remove per-table-memory-quota min value check (#3022)
Browse files Browse the repository at this point in the history
  • Loading branch information
overvenus authored Oct 14, 2021
1 parent d6b04fe commit be1f3fe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pkg/cmd/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (s *serverSuite) TestParseCfg(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 @@ -262,7 +262,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 @@ -369,7 +369,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 @@ -186,7 +186,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 @@ -298,9 +298,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 @@ -309,14 +309,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 @@ -69,7 +69,7 @@ func TestReplicaConfigOutDated(t *testing.T) {

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":20971520,"kv-client":{"worker-concurrent":8,"worker-pool-size":0,"region-scan-limit":40}}`
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}}`

conf := GetDefaultServerConfig()
conf.Addr = "192.155.22.33:8887"
Expand Down Expand Up @@ -117,5 +117,9 @@ func TestServerConfigValidateAndAdjust(t *testing.T) {
require.Regexp(t, ".*does not contain a port", conf.ValidateAndAdjust())
conf.AdvertiseAddr = "advertise:1234"
conf.PerTableMemoryQuota = 1
require.Regexp(t, ".*should be at least.*", conf.ValidateAndAdjust())
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)
}

0 comments on commit be1f3fe

Please sign in to comment.