Repository navigation
Fix allow_feature_tier for MergeTree settings - #113156
Algunenano merged 30 commits into
Conversation
The tier lookup in `SettingsConstraints::getChecker` used `Settings::getTier`, so a `merge_tree_`-prefixed name (which refers to `MergeTreeSettings`) was reported as an unknown setting whenever `allow_feature_tier` was not 0. It is now resolved through `resolveSetting`. `MergeTreeSettingsImpl::sanityCheck` also applied the tier check to values set by the server itself, through `compatibility` or the `merge_tree` config section, which made every `CREATE TABLE` fail once the tier disallowed one of them. Those are now tracked and skipped, while changes coming from a query are still checked.
|
Workflow [PR], commit [5536701] Summary: ✅
AI ReviewSummaryThis PR centralizes Findings❌ Blockers
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit 5536701.
Changed lines: Changed C/C++ lines covered: 269/280 (96.07%) · Uncovered code |
`sanityCheck` gated the tier check on `isValueChanged()` (a sticky "ever explicitly assigned" flag, not a live comparison against the compiled default) plus a `changed_by_server` exemption list. This mostly happened to work, but relying on `isValueChanged()` is fragile, and it made a genuine no-op - a query re-declaring a `MergeTree` setting to the value already in effect - trip the tier check, unlike the equivalent `Settings` path (`SettingsConstraints::getNewValueToCheck`), which exempts exactly that case. Replace `changed_by_server` with `changed_by_query`, marking a setting only when a query sets it to a value that differs from what is currently in effect. This matches `Settings`' semantics: a real change is checked regardless of what the resulting value happens to equal (so reverting an admin-forced EXPERIMENTAL/BETA setting back to its compiled default is still caught), while re-declaring the same value is a no-op. Also swaps the EXPERIMENTAL example setting used in the integration test, since `compute_exact_num_defaults_for_sparse_columns` is being moved to BETA in a separate PR.
An ALTER replays the table's full stored SETTINGS list, not just its own delta. `applyChangesFromQuery` compared each entry against a freshly-defaulted copy instead of the table's live settings, so an EXPERIMENTAL/BETA override already on the table got re-flagged as a change on every subsequent unrelated ALTER once the tier tightened. Add an optional baseline to applyChanges/applyChangesFromQuery and pass the table's live settings from MergeTreeData::changeSettings.
`ALTER TABLE ... RESET SETTING` drops the name from the post-ALTER SETTINGS list instead of setting it to the default, so it never reached applyChangesFromQuery and never tripped the feature tier check, unlike the equivalent MODIFY SETTING to the default value. Add the removed name back with its reverted value so it's checked the same way. `ALTER USER/ROLE/SETTINGS PROFILE ... DROP SETTING` had the same asymmetry: SettingsConstraints::check unconditionally skipped drop_settings. Route each dropped setting through the same check as a MODIFY to its compiled default.
drop_settings can name a custom (user-defined) setting, which has no compiled default and isn't builtin, so Settings::get threw UNKNOWN_SETTING for it. Skip those the same way they were skipped before this check existed.
…erge-tree-settings
`merge_tree_`-prefixed drop: `Settings::hasBuiltin` doesn't recognize the `merge_tree_` prefix convention, so dropping such a name from a user/role/profile skipped the tier check entirely. Use `settingIsBuiltin`/`settingGetDefaultValue` (resolveSetting-aware) instead. `DROP ALL SETTINGS` (and old-style `SETTINGS ...` full replacement, which drops by omission) bypassed the tier check the same way explicit `DROP SETTING` did before the previous fix, since neither ever appeared in `drop_settings`. Add `SettingsProfileElements::findRevertedSettingNames`, and have each of the three ALTER interpreters (User/Role/SettingsProfile) fetch the target's current settings and feed every name the change reverts into `drop_settings` before the check runs. `MergeTreeData::changeSettings`'s RESET-detection compared canonical names (from `old_settings->changes()`) against raw strings in `new_changes`, so a setting kept alive under an alias looked removed and got silently reset to its default on any unrelated ALTER - a correctness bug independent of allow_feature_tier. Compare resolved names on both sides instead.
`CREATE USER/ROLE/SETTINGS PROFILE OR REPLACE` is a full replacement of an existing entity too, just like an old-style `ALTER ... SETTINGS` or `DROP ALL SETTINGS`, so it needs the same revert-name expansion; the previous fix only guarded on `query.alter`. `findRevertedSettingNames` only looked at `element.value`, missing constraint-only elements (`MIN`/`MAX` with no plain value), which `SettingsConstraints::check` checks against the tier too.
The synthetic drop-check in SettingsConstraints compared against the acting admin's own session instead of the target's value, so an admin at compiled defaults could still strip another user's genuine EXPERIMENTAL/BETA override. findRevertedSettingNames only diffed direct elements, missing settings inherited through an attached SETTINGS PROFILE and mismatching on aliases.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes19 object files changed (+74.17 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units861 translation units recompiled, 5939 s compile time in total, 861 of them have a recent master baseline. |
…erge-tree-settings
Decide what a statement changed by comparing the settings in effect before it with the settings in effect after it, instead of inspecting how the change was written. `MergeTreeSettings::sanityCheck` no longer performs the feature tier check and loses its three tier parameters, along with the `allowed_experimental = true` it was passed at server startup. The check now lives in `SettingsConstraints`, which every query-side path already reaches with the settings in effect and the changes to apply, so the call sites pass `changesFrom(settings_in_effect)`. A value the server itself set through `compatibility` or the `merge_tree` config section is therefore not a change made by the query, while `RESET SETTING`, a name respelled through an alias and a revert to the compiled default are. `SettingsConstraints::getChecker` resolved the tier with `Settings::getTier`, which does not know about the `merge_tree_` prefix used to reference `MergeTreeSettings` in a settings profile, so such a name was rejected as unknown even for a PRODUCTION setting. The tier is now resolved through `resolveSetting`, and a custom setting belongs to no tier. For access entities, `SettingsProfileElements::findChangedSettings` diffs the entity's effective settings, with inherited profiles substituted, aliases resolved and the last occurrence winning, so a change is measured against the entity being altered rather than against the session of whoever runs the statement. A full-definition `ATTACH TABLE`, granting or revoking a role that carries settings, and assigning a settings profile are checked as well. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
d44526b to
0a23d98
Compare
Resolve the conflicts of the 26.7 backport of #113156: - 26.7 has no `PRIVATE_PREVIEW` tier, so its checks are dropped. - 26.7 has no `alter_effective_settings` in `checkAlterIsPossible`, so the post-ALTER settings are rebuilt locally for the constraints check. - `tryGetTierOfBuiltin` is added to `BaseSettings` and `Settings`, which the new `settingGetTier` needs and 26.7 did not have.
Resolve the conflicts of the 26.6 backport of #113156: - 26.6 has no `PRIVATE_PREVIEW` tier, so its checks are dropped. - 26.6 has no `alter_effective_settings` in `checkAlterIsPossible`, so the post-ALTER settings are rebuilt locally for the constraints check. - `changesFrom` and `getAllAliasNames` follow the 26.6 `MergeTreeSettings` signatures, which take no `ContextPtr`. - `tryGetTierOfBuiltin` is added to `BaseSettings` and `Settings`, which the new `settingGetTier` needs and 26.6 did not have.
Cherry pick #113156 to 26.6: Fix allow_feature_tier for MergeTree settings
Cherry pick #113156 to 26.7: Fix allow_feature_tier for MergeTree settings
Resolve the conflicts of the 26.3 backport of #113156: - 26.3 has no `PRIVATE_PREVIEW` tier and no `background_pool_auto_lowered` argument on `sanityCheck`, so both are dropped. - 26.3 rebuilds the post-ALTER settings locally in `checkAlterIsPossible`, and `getNewValueToCheck` keeps its 26.3 shape (no `ignore_unchanged_settings`). - Projections do not carry `MergeTreeSettings` in 26.3, they read only `index_granularity` and `index_granularity_bytes` through `loadSettings`, so the `ProjectionsDescription` part of the change and its test do not apply. - `changesFrom`, `getAllAliasNames` and `tryGetTierOfBuiltin` are added, and the `MergeTree` setting the integration test states in the config is one that exists in 26.3.
Cherry pick #113156 to 26.3: Fix allow_feature_tier for MergeTree settings
Backport #113156 to 26.6: Fix allow_feature_tier for MergeTree settings
Backport #113156 to 26.8: Fix allow_feature_tier for MergeTree settings
Backport #113156 to 26.7: Fix allow_feature_tier for MergeTree settings
Backport #113156 to 26.3: Fix allow_feature_tier for MergeTree settings
Closes: https://github.com/ClickHouse/clickhouse-private/issues/67193
Two problems with
allow_feature_tierandMergeTreesettings, both at any non-zero value of the setting (at 0 the tier checks are never reached).SettingsConstraints::getCheckerlooked up the tier withSettings::getTier, which does not know about themerge_tree_prefix used to referenceMergeTreeSettingsin a settings profile. Any profile element or query setting using such a name was rejected withUNKNOWN_SETTING, even for aPRODUCTIONsetting:MergeTreeSettingsImpl::sanityCheckapplied the tier check to every setting whose value differs from the compiled-in default, including the values the server itself sets throughcompatibilityor themerge_treeconfig section. A singleEXPERIMENTALorBETAsetting there made everyCREATE TABLEfail, the system log tables included.Both come from deciding what a query changed by looking at the settings object alone. This decides it by comparing states instead: the settings in effect after the statement are diffed against the settings in effect before it, and only that difference is checked.
RESET SETTING, a name respelled through an alias, an override dropped by omission and a value the server itself put in effect all follow from that one rule rather than each needing its own case. A table has no dependency graph, so the comparison is exact.The tier check now lives in one place,
SettingsConstraints, for every kind of setting.MergeTreeSettings::sanityCheckloses its three tier parameters, and with them theallowed_experimental = trueit was passed at server startup; theMergeTreecall sites passchangesFrom(settings_in_effect)to the constraints check that already existed for them. A custom setting belongs to no tier, which also fixesSET custom_x = 1failing the first time a session sets it.A
MergeTreesetting reached through a settings profile also had to be made to behave as one setting under either of its names. A constraint is stored under the canonical name, so a constraint declared canonically did not apply to a statement that wrote the same setting through its alias, which letMIN,MAX,CONSTand disallowed values be bypassed by spelling the setting differently, whateverallow_feature_tieris set to. These names are also carried throughSettingsas custom settings, so a value was stored under the spelling that wrote it and without the declared type of the setting, and writing the value a setting already had was taken for a change and refused by aCONSTconstraint. Both names now resolve to the same stored value, compared in the type the setting declares, and a reset clears both. Only the tier check reaching these settings made this reachable: before it, such a statement failed as an unknown setting.The same rule cannot be applied to users, roles and settings profiles by looking at the entity a statement writes, because their settings reach a session through the whole access graph: a role changes what its dependents get without changing anything about itself, dropping an override falls back to whatever it shadowed, and dropping a role or a profile rewrites everything that referenced it. That is recorded, with the cases and a proposal, in #116126 and is not attempted here.
Related: #116126
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
allow_feature_tierrejectingmerge_tree_-prefixed settings in settings profiles as unknown, and rejectingCREATE TABLEbecause ofMergeTreesettings set by the server throughcompatibilityor themerge_treeconfig section. Also fix constraints on amerge_tree_-prefixed setting being bypassed when the setting is written through its alias, and a statement that rewrites the value such a setting already has being refused by aCONSTconstraint.Workflow [PR]
Sync PR [sync-upstream/pr/113156]
Version info
26.9.1.478(included in26.9and later)26.8.3.7,26.7.7.6,26.6.5.18,26.3.29.3