cockroachdb / cockroachdb/cockroach
settings: unexpected result with reset after override
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
We silently [drop](https://github.com/cockroachdb/cockroach/blame/c68c559859be738efead9971f5e11f62a8c69d06/pkg/settings/int.go#L121-L123) the setting on error for SetToDefault if a cluster setting had been overriden with an invalid value. This can fail to properly reset if the value has been set to something else. As an example,
```
intSetting.Override(-12) // setting is now really -12 despite validation
intSetting.Set(100) // this is now a valid value
intSetting.Reset() // does NOT revert to -12
```
See repro in https://github.com/cockroachdb/cockroach/blob/f398b9e80070682d07ee74aa8331f33e915a2cb5/pkg/settings/settings_test.go#L803-L824.
**Expected behavior**
It should either revert to -12, which seems to be the intended behavior given we have this function for this purpose:
https://github.com/cockroachdb/cockroach/blob/c68c559859be738efead9971f5e11f62a8c69d06/pkg/settings/values.go#L222-L229. But intuitively, it feels like we should revert to the original default value before the override instead since it is a Reset.
Jira issue: CRDB-52452
Contributor guide
Assessment
This issue has not been assessed yet.