Repository navigation
Fix SettingsConstraints erasing explicit settings when compatibility is present - #99402
Conversation
…cit settings before compatibility applies"""" #99352
|
Workflow [PR], commit [a331351] Summary: ✅ AI ReviewSummaryThis PR re-lands the Missing context
ClickHouse Rules
Final Verdict
|
…llel replicas interaction This reproduces #99311 (comment)
d003821 to
be9d9f2
Compare
The previous fix for SettingsConstraints erasing explicit settings before compatibility applies was only in the check path (initial settings), not in clamp (forwarded settings). With parallel replicas, the coordinator kept explicit settings but replicas dropped them via the forwarded path, causing NOT_FOUND_COLUMN_IN_BLOCK due to analyzer being silently disabled by compatibility. I extracted a shared checkOrClamp helper used by both paths so they can't diverge again
…rClamp Previous change kept all settings when compativility was present. This one makes it surgical. We keep only unchanged settings, while genuinely rejected ones are still erased
|
|
||
| template <typename SettingsT> | ||
| bool getNewValueToCheck(const SettingsT & current_settings, SettingChange & change, Field & new_value, bool throw_on_failure) | ||
| bool getNewValueToCheck(const SettingsT & current_settings, SettingChange & change, Field & new_value, bool throw_on_failure, bool * value_unchanged = nullptr) |
There was a problem hiding this comment.
This function with this extra bool * parameter looks overcomplicated. I suggest simplifying it by turning into
Field getNewValueToCheck(const SettingsT & current_settings, const SettingChange & change, bool ignore_if_unchanged, bool throw_on_failure)
I mean such function could return Field{} instead of false and also check whether it's changed only if ignore_if_unchanged==true
There was a problem hiding this comment.
Please also add a comment for getNewValueToCheck, it looks like it's worth commenting.
There was a problem hiding this comment.
Great suggestion, this simplifies the logic a lot!
| SettingChange & change, | ||
| ReactionOnViolation reaction, | ||
| SettingSource source, | ||
| bool keep_if_unchanged = false) const; |
There was a problem hiding this comment.
Let's rename the parameter to ignore_unchanged_settings? Because otherwise it looks confusing that function checking settings has a parameter named keep...
| else if (!access_control->isSettingNameAllowed(setting_name)) | ||
| return false; | ||
|
|
||
| /// `getNewValueToCheck` returns false either because the value is unchanged (no-op) or because the cast failed. |
There was a problem hiding this comment.
This comment looks unnecessary
There was a problem hiding this comment.
Especially with the new logic. Removed
| /// | ||
| /// Thus, when `compatibility` is present, we keep unchanged settings so they get marked as explicitly `changed` and take precedence. | ||
| /// Genuinely rejected settings (unknown names, cast failures, constraint violations) are still erased. | ||
| bool has_compatibility = changes.tryGet("compatibility") != nullptr; |
There was a problem hiding this comment.
Please rename to has_compatibility_setting. Also the comment is too long and quite unclear at the same time.
There was a problem hiding this comment.
Done. Let me know if it is still unclear
rienath
left a comment
There was a problem hiding this comment.
I was going to send these messages once I saw that CI doesn't fail, but you already approved the PR. Thanks for the detailed review :)
| SettingChange & change, | ||
| ReactionOnViolation reaction, | ||
| SettingSource source, | ||
| bool keep_if_unchanged = false) const; |
| /// | ||
| /// Thus, when `compatibility` is present, we keep unchanged settings so they get marked as explicitly `changed` and take precedence. | ||
| /// Genuinely rejected settings (unknown names, cast failures, constraint violations) are still erased. | ||
| bool has_compatibility = changes.tryGet("compatibility") != nullptr; |
There was a problem hiding this comment.
Done. Let me know if it is still unclear
|
|
||
| template <typename SettingsT> | ||
| bool getNewValueToCheck(const SettingsT & current_settings, SettingChange & change, Field & new_value, bool throw_on_failure) | ||
| bool getNewValueToCheck(const SettingsT & current_settings, SettingChange & change, Field & new_value, bool throw_on_failure, bool * value_unchanged = nullptr) |
There was a problem hiding this comment.
Great suggestion, this simplifies the logic a lot!
| else if (!access_control->isSettingNameAllowed(setting_name)) | ||
| return false; | ||
|
|
||
| /// `getNewValueToCheck` returns false either because the value is unchanged (no-op) or because the cast failed. |
There was a problem hiding this comment.
Especially with the new logic. Removed
… in tests The '<readonly/>' constraint on 'æenable_analyzer' throws when the test framework sends '--enable_analyzer=1 --compatibility=25.1', because this stops filtering unchanged settings when 'compatibility' is present. Replace with '<min>1</min>' which still prevents the fuzzer from disabling the analyzer but does not reject a no-op set to 1.
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
…lickHouse into fix-setting-constraints-fix
This comment was marked as outdated.
This comment was marked as outdated.
When 'compatibility' is in the batch, unchanged settings are kept so they take precedence over 'compatibility' defaults. But they were still going through constraint checks, which could reject them (e.g. 'readonly=2' in readonly mode). Since the value isn't actually changing, skip the check.
|
The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158 |
|
The flaky check failure is fixed in #102148, let's update the branch. |
LLVM Coverage Report
Changed lines: 96.30% (52/54) | lost baseline coverage: 11 line(s) · Uncovered code |
|
Hi — this PR may need backporting to Affected code: SettingsConstraints::check, SettingsConstraints::clamp, SettingsConstraints::checkOrClamp — core code present in all supported branches. Why: SettingsConstraints::check/clamp and the compatibility setting both predate all supported branches (SettingsConstraints: 2019, compatibility: 2022-07). The bug affects any user combining explicit settings with compatibility in TCP or HTTP paths. The original fix #97078 was reverted (#99352) due to stress test failures; this PR re-lands it with the clamp path fixed. All supported branches are affected. If this should be backported, consider adding |
This re-lands #97078 (reverted in #99352) with a fix for the forwarded-settings path that caused stress test failures.
The original fix prevented
SettingsConstraints::checkfrom erasing explicit settings when compatibility is present in the same batch, but only on the initial settings path. With parallel replicas, the coordinator forwards settings to replicas throughSettingsConstraints::clamp, which still had the old behavior. With old compatibility applied, coordinator could keepenable_analyzer=1but replicas let compatibility override it to 0, producingNOT_FOUND_COLUMN_IN_BLOCKdue to different internal column naming with and without analyzer (example)This PR extracts a shared logic to
checkOrClampso paths can't diverge again. A regression test for the exact scenario is included.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a bug where explicit settings sent alongside
compatibilityin the same request could be silently ignored when their value matched the server default.Version info
26.4.1.885