Repository navigation
Conversation
|
Verified on dc30900 with go1.27.1: go test -tags test_dep ./common/dynamicconfig/... passes, 147 tests, 0 failures, including both new positive-duration subtests. Also checked the production key directly: with system.clusterMetadataRefreshInterval set to 0, ClusterMetadataRefreshInterval.Get() returns 0s on main (e8ee627) and 1m0s, the default, on this branch. That 0s reaches time.NewTicker at common/cluster/metadata.go:394 and panics with "non-positive interval for NewTicker". The d <= 0 rejection at common/dynamicconfig/setting_positive_duration.go:15 is what blocks it. |
|
The CLA is signed and the new tests pass, and an outside check on Go 1.27 confirmed them. Could a maintainer take a first look when there is time? Happy to change anything. |
Setting an interval dynamic config to 0 does not disable the work it configures. Depending on the setting it panics a ticker, spins a loop with no pause, or runs the work hundreds of times more often. Add positive-duration setting constructors whose converter rejects values <= 0. The collection already handles a conversion error by logging a throttled warning and using the default, so a mistaken 0 now falls back to the default instead of taking effect. Use them for clusterMetadataRefreshInterval, namespaceCacheRefreshInterval, matching.updateAckInterval, matching.getUserDataRefresh, matching.nexusEndpointsRefreshInterval, the timer and archival processor update-ack and max-poll intervals, and history.shardUpdateMinInterval.
dc30900 to
0bf4bd7
Compare
|
Rebased onto main (the only conflict was next to the new |
|
Rebased onto main with the Temporal CLA signed and checks green. A review from the dynamic config owners would be welcome, and I can change the validation approach if you prefer. |
dnr
left a comment
There was a problem hiding this comment.
This approach isn't going to scale, we need a more flexible API for defining settings with configurable validations.
…eject NaN, cover every validated key
|
Thanks, reworked along those lines. The one-off positive-duration constructors are gone: |
|
Reworked after the review into a general |
|
Rechecked |
What changed?
Added a general validation hook for dynamic config settings:
WithValidation(convert, validators...)wraps any converter so the converted value must also pass eachValidator[T], andPositiveis the first validator. It plugs into the existingNew*TypedSettingWithConverterandNew*TypedSettingWithConstrainedDefaultconstructors, so it works for every precedence and value type without new generated constructors. A rejected value behaves like an unparseable one: the collection logs a throttled warning and uses the next matching value or the default, and the YAML loader reports it as invalid.Applied
WithValidation(convertDuration, Positive[time.Duration])to nine of the ten settings listed in the issue:system.clusterMetadataRefreshInterval,system.namespaceCacheRefreshInterval,matching.updateAckInterval,matching.getUserDataRefresh,matching.nexusEndpointsRefreshInterval,history.timerProcessorUpdateAckInterval,history.archivalProcessorUpdateAckInterval,history.timerProcessorMaxPollIntervalandhistory.archivalProcessorMaxPollInterval.history.shardUpdateMinIntervalis left alone: its only readers add it to a timestamp (context_impl.go), so 0 there means "update every time" and nothing spins or panics.Why?
Setting any of these to 0 does not disable the work: it panics a ticker, spins a loop with no pause, or runs the work hundreds of times more often. Fixes #12652.
How did you test it?
New tests in
collection_test.gocover zero and negative values written as ints, durations, strings and floats on a global setting, a zero override on the task queue setting with constrained defaults, every validated key rejecting 0 throughValidate, andWithValidationwith several validators including NaN. The two collection tests fail on the base commit.go test ./common/dynamicconfig/passes.Potential risks
A deployment that currently relies on 0 for one of these nine settings will now get the default instead, with a warning in the log. All other settings are unchanged.