Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: ensure kv.bulk_io_write settings are positive #31572

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/settings/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ func RegisterNonNegativeIntSetting(key, desc string, defaultValue int64) *IntSet
})
}

// RegisterPositiveIntSetting defines a new setting with type int.
func RegisterPositiveIntSetting(key, desc string, defaultValue int64) *IntSetting {
return RegisterValidatedIntSetting(key, desc, defaultValue, func(v int64) error {
if v < 1 {
return errors.Errorf("cannot set %s to a value < 1: %d", key, v)
}
return nil
})
}

// RegisterValidatedIntSetting defines a new setting with type int with a
// validation function.
func RegisterValidatedIntSetting(
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var bulkIOWriteLimit = settings.RegisterByteSizeSetting(
)

// importRequestsLimit limits concurrent import requests.
var importRequestsLimit = settings.RegisterIntSetting(
var importRequestsLimit = settings.RegisterPositiveIntSetting(
"kv.bulk_io_write.concurrent_import_requests",
"number of import requests a store will handle concurrently before queuing",
1,
Expand All @@ -126,7 +126,7 @@ var importRequestsLimit = settings.RegisterIntSetting(
// by a guessing - it could be improved by more measured heuristics. Exported
// here since we check it in in the caller to limit generated requests as well
// to prevent excessive queuing.
var ExportRequestsLimit = settings.RegisterIntSetting(
var ExportRequestsLimit = settings.RegisterPositiveIntSetting(
"kv.bulk_io_write.concurrent_export_requests",
"number of export requests a store will handle concurrently before queuing",
5,
Expand Down