Skip to content

Commit 308665f

Browse files
committed
*: cleanup some duration settings
This commit should be almost a no-op and it does a few cleanup things like replacing custom validation function with the helper equivalent and putting the default value on a separate line. The only non-equivalent change is introduction of non-negative validation to `kv.dist_sender.circuit_breaker.cancellation.write_grace_period` which seems reasonable. Release note: None
1 parent bcbb5bd commit 308665f

File tree

10 files changed

+23
-55
lines changed

10 files changed

+23
-55
lines changed

pkg/ccl/changefeedccl/changefeedbase/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ var UsageMetricsReportingInterval = settings.RegisterDurationSetting(
328328
"changefeed.usage.reporting_interval",
329329
"the interval at which the changefeed calculates and updates its usage metric",
330330
5*time.Minute,
331-
settings.PositiveDuration, settings.DurationInRange(2*time.Minute, 50*time.Minute),
331+
settings.DurationInRange(2*time.Minute, 50*time.Minute),
332332
)
333333

334334
// UsageMetricsReportingTimeoutPercent is the percent of

pkg/kv/kvclient/kvcoord/dist_sender_circuit_breaker.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,9 @@ var (
113113
"(these can't retry internally, so should be long enough to allow quorum/lease recovery)",
114114
10*time.Second,
115115
settings.WithPublic,
116-
settings.WithValidateDuration(func(t time.Duration) error {
117-
// This prevents probes from exiting when idle, which can lead to buildup
118-
// of probe goroutines, so cap it at 1 minute.
119-
if t > time.Minute {
120-
return errors.New("grace period can't be more than 1 minute")
121-
}
122-
return nil
123-
}),
116+
// This prevents probes from exiting when idle, which can lead to
117+
// buildup of probe goroutines, so cap it at 1 minute.
118+
settings.DurationInRange(0 /* minVal */, time.Minute),
124119
)
125120
)
126121

pkg/kv/kvserver/protectedts/settings.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ var PollInterval = settings.RegisterDurationSetting(
4444
"kv.protectedts.poll_interval",
4545
// TODO(ajwerner): better description.
4646
"the interval at which the protectedts subsystem state is polled",
47-
2*time.Minute, settings.NonNegativeDuration)
47+
2*time.Minute,
48+
settings.NonNegativeDuration)

pkg/kv/kvserver/queue.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ const (
5151
var queueGuaranteedProcessingTimeBudget = settings.RegisterDurationSetting(
5252
settings.ApplicationLevel,
5353
"kv.queue.process.guaranteed_time_budget",
54-
"the guaranteed duration before which the processing of a queue may "+
55-
"time out",
54+
"the guaranteed duration before which the processing of a queue may time out",
5655
defaultProcessTimeout,
5756
settings.WithVisibility(settings.Reserved),
5857
)

pkg/kv/kvserver/replica_command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,8 @@ var traceSnapshotThreshold = settings.RegisterDurationSetting(
32343234
"kv.trace.snapshot.enable_threshold",
32353235
"enables tracing and gathers timing information on all snapshots;"+
32363236
"snapshots with a duration longer than this threshold will have their "+
3237-
"trace logged (set to 0 to disable);", 0,
3237+
"trace logged (set to 0 to disable);",
3238+
0,
32383239
)
32393240

32403241
var externalFileSnapshotting = settings.RegisterBoolSetting(

pkg/settings/duration.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ func RegisterDurationSetting(
179179
return setting
180180
}
181181

182-
// RegisterPublicDurationSettingWithExplicitUnit defines a new
183-
// public setting with type duration which requires an explicit unit when being
184-
// set.
182+
// RegisterDurationSettingWithExplicitUnit defines a new setting with type
183+
// duration which requires an explicit unit when being set.
185184
func RegisterDurationSettingWithExplicitUnit(
186185
class Class, key InternalKey, desc string, defaultValue time.Duration, opts ...SettingOption,
187186
) *DurationSettingWithExplicitUnit {

pkg/sql/exec_util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ var traceTxnThreshold = settings.RegisterDurationSetting(
274274
"note that enabling this may have a negative performance impact; "+
275275
"this setting is coarser-grained than sql.trace.stmt.enable_threshold "+
276276
"because it applies to all statements within a transaction as well as "+
277-
"client communication (e.g. retries)", 0,
277+
"client communication (e.g. retries)",
278+
0,
278279
settings.WithPublic)
279280

280281
// TraceStmtThreshold is identical to traceTxnThreshold except it applies to

pkg/sql/tablemetadatacache/cluster_settings.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"time"
1010

1111
"github.com/cockroachdb/cockroach/pkg/settings"
12-
"github.com/cockroachdb/errors"
1312
)
1413

1514
const (
@@ -31,13 +30,8 @@ var DataValidDurationSetting = settings.RegisterDurationSetting(
3130
"obs.tablemetadata.data_valid_duration",
3231
"the duration for which the data in system.table_metadata is considered valid",
3332
defaultDataValidDuration,
34-
settings.WithValidateDuration(func(t time.Duration) error {
35-
// This prevents the update loop from running too frequently.
36-
if t < time.Minute {
37-
return errors.New("validity period can't be less than 1 minute")
38-
}
39-
return nil
40-
}),
33+
// This prevents the update loop from running too frequently.
34+
settings.DurationWithMinimum(time.Minute),
4135
settings.WithPublic)
4236

4337
var updateJobBatchSizeSetting = settings.RegisterIntSetting(

pkg/util/admission/work_queue.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -130,36 +130,24 @@ var epochLIFOEpochDuration = settings.RegisterDurationSetting(
130130
"admission.epoch_lifo.epoch_duration",
131131
"the duration of an epoch, for epoch-LIFO admission control ordering",
132132
epochLength,
133-
settings.WithValidateDuration(func(v time.Duration) error {
134-
if v < time.Millisecond {
135-
return errors.Errorf("epoch-LIFO: epoch duration is too small")
136-
}
137-
return nil
138-
}), settings.WithPublic)
133+
settings.DurationWithMinimum(time.Millisecond),
134+
settings.WithPublic)
139135

140136
var epochLIFOEpochClosingDeltaDuration = settings.RegisterDurationSetting(
141137
settings.ApplicationLevel,
142138
"admission.epoch_lifo.epoch_closing_delta_duration",
143139
"the delta duration before closing an epoch, for epoch-LIFO admission control ordering",
144140
epochClosingDelta,
145-
settings.WithValidateDuration(func(v time.Duration) error {
146-
if v < time.Millisecond {
147-
return errors.Errorf("epoch-LIFO: epoch closing delta is too small")
148-
}
149-
return nil
150-
}), settings.WithPublic)
141+
settings.DurationWithMinimum(time.Millisecond),
142+
settings.WithPublic)
151143

152144
var epochLIFOQueueDelayThresholdToSwitchToLIFO = settings.RegisterDurationSetting(
153145
settings.ApplicationLevel,
154146
"admission.epoch_lifo.queue_delay_threshold_to_switch_to_lifo",
155147
"the queue delay encountered by a (tenant,priority) for switching to epoch-LIFO ordering",
156148
maxQueueDelayToSwitchToLifo,
157-
settings.WithValidateDuration(func(v time.Duration) error {
158-
if v < time.Millisecond {
159-
return errors.Errorf("epoch-LIFO: queue delay threshold is too small")
160-
}
161-
return nil
162-
}), settings.WithPublic)
149+
settings.DurationWithMinimum(time.Millisecond),
150+
settings.WithPublic)
163151

164152
var rangeSequencerGCThreshold = settings.RegisterDurationSetting(
165153
settings.ApplicationLevel,

pkg/util/schedulerlatency/sampler.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,15 @@ var samplePeriod = settings.RegisterDurationSetting(
3333
"scheduler_latency.sample_period",
3434
"controls the duration between consecutive scheduler latency samples",
3535
100*time.Millisecond,
36-
settings.WithValidateDuration(func(period time.Duration) error {
37-
if period < time.Millisecond {
38-
return fmt.Errorf("minimum sample period is %s, got %s", time.Millisecond, period)
39-
}
40-
return nil
41-
}),
36+
settings.DurationWithMinimum(time.Millisecond),
4237
)
4338

4439
var sampleDuration = settings.RegisterDurationSetting(
4540
settings.ApplicationLevel, // used in virtual clusters
4641
"scheduler_latency.sample_duration",
4742
"controls the duration over which each scheduler latency sample is a measurement over",
4843
2500*time.Millisecond,
49-
settings.WithValidateDuration(func(duration time.Duration) error {
50-
if duration < 100*time.Millisecond {
51-
return fmt.Errorf("minimum sample duration is %s, got %s", 100*time.Millisecond, duration)
52-
}
53-
return nil
54-
}),
44+
settings.DurationWithMinimum(100*time.Millisecond),
5545
)
5646

5747
var schedulerLatency = metric.Metadata{

0 commit comments

Comments
 (0)