fix(query): make config validation for query controller less strict (#21324)

* fix(query): accept queue-size > 0 when concurrency = 0
* fix(influxd): revert defaults for query settings to avoid validation err
* test: lower the default query concurrency used by test launchers
pull/21323/head^2
Daniel Moran 2021-04-28 17:27:37 -04:00 committed by GitHub
parent 91d59d9588
commit 942f7095e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 13 deletions

View File

@ -8,6 +8,8 @@
### Bug Fixes
1. [21321](https://github.com/influxdata/influxdb/pull/21321): Ensure query config written by influxd upgrade is valid.
1. [21324](https://github.com/influxdata/influxdb/pull/21324): Revert to nonzero defaults for `query-concurrency` and `query-queue-size` to avoid validation failures for upgrading users.
1. [21324](https://github.com/influxdata/influxdb/pull/21324): Don't fail validation when `query-concurrency` is 0 and `query-queue-size` is > 0.
## v2.0.5 [2021-04-27]

View File

@ -205,11 +205,11 @@ func NewOpts(viper *viper.Viper) *InfluxdOpts {
NoTasks: false,
ConcurrencyQuota: 0,
ConcurrencyQuota: 1024,
InitialMemoryBytesQuotaPerQuery: 0,
MemoryBytesQuotaPerQuery: MaxInt,
MaxMemoryBytes: 0,
QueueSize: 0,
QueueSize: 1024,
Testing: false,
TestingAlwaysAllowSetup: false,

View File

@ -129,6 +129,8 @@ func (tl *TestLauncher) Run(tb zaptest.TestingT, ctx context.Context, setters ..
opts.HttpBindAddress = "127.0.0.1:0"
opts.LogLevel = zap.DebugLevel
opts.ReportingDisabled = true
opts.ConcurrencyQuota = 32
opts.QueueSize = 16
for _, setter := range setters {
setter(opts)

View File

@ -119,19 +119,23 @@ type Config struct {
// complete will fill in the defaults, validate the configuration, and
// return the new Config.
func (c *Config) complete() (Config, error) {
func (c *Config) complete(log *zap.Logger) (Config, error) {
config := *c
if config.InitialMemoryBytesQuotaPerQuery == 0 {
config.InitialMemoryBytesQuotaPerQuery = config.MemoryBytesQuotaPerQuery
}
if config.ConcurrencyQuota == 0 && config.QueueSize > 0 {
log.Warn("Ignoring query QueueSize > 0 when ConcurrencyQuota is 0")
config.QueueSize = 0
}
if err := config.validate(true); err != nil {
if err := config.validate(); err != nil {
return Config{}, err
}
return config, nil
}
func (c *Config) validate(isComplete bool) error {
func (c *Config) validate() error {
if c.ConcurrencyQuota < 0 {
return errors.New("ConcurrencyQuota must not be negative")
} else if c.ConcurrencyQuota == 0 {
@ -148,10 +152,10 @@ func (c *Config) validate(isComplete bool) error {
return errors.New("QueueSize must be positive when ConcurrencyQuota is limited")
}
}
if c.MemoryBytesQuotaPerQuery < 0 || (isComplete && c.MemoryBytesQuotaPerQuery == 0) {
if c.MemoryBytesQuotaPerQuery < 0 {
return errors.New("MemoryBytesQuotaPerQuery must be positive")
}
if c.InitialMemoryBytesQuotaPerQuery < 0 || (isComplete && c.InitialMemoryBytesQuotaPerQuery == 0) {
if c.InitialMemoryBytesQuotaPerQuery < 0 {
return errors.New("InitialMemoryBytesQuotaPerQuery must be positive")
}
if c.MaxMemoryBytes < 0 {
@ -165,15 +169,10 @@ func (c *Config) validate(isComplete bool) error {
return nil
}
// Validate will validate that the controller configuration is valid.
func (c *Config) Validate() error {
return c.validate(false)
}
type QueryID uint64
func New(config Config, logger *zap.Logger) (*Controller, error) {
c, err := config.complete()
c, err := config.complete(logger)
if err != nil {
return nil, errors.Wrap(err, "invalid controller config")
}