Repository navigation
Fix settings value drift in SettingsChangesHistory.cpp - #111841
Conversation
Add missing entries for 5 settings whose current default in Settings.cpp had drifted from the newest value recorded in SettingsChangesHistory.cpp, and collapse the duplicate conflicting entry for check_conversion_from_numbers_to_enum in the 26.1 block. Fixes ClickHouse#111750
|
Add a corresponding style check, so that this problem never happens again. |
|
Wanted to flag a conflict before moving these before I make a change here: The issue (#111750) explicitly says to add the entries "under the current version block" — which is why I originally put all 4 under 26.8. I traced the actual commit that changed each default, and the real versions are:
Separately: I noticed Which would you prefer:
Happy to do either, just want to confirm before I start moving things around. |
…d a check Address review: instead of backfilling corrective entries under the current `26.8` block, correct the wrong entries in the version blocks where the change actually happened, verified against the released tags: - `cross_to_inner_join_rewrite`: the default was `1` in every release, both before and after `22.7`, so the recorded `1` -> `2` change never happened; the entry is removed. - `rewrite_count_distinct_if_with_count_distinct_implementation`: introduced in `23.8` with the default `false`, not `true`. - `extract_key_value_pairs_max_pairs_per_row`: introduced in `24.2` with the default `1000`, not `0`. - `output_format_pretty_fallback_to_vertical_max_rows_per_chunk`: introduced in `25.1` with the default `10`, not `100`. - `promql_evaluation_time`: the `25.9` block recorded the rename of `evaluation_time` twice, and the second entry kept the pre-rename default `0` while the setting is `auto`; the two entries are collapsed into one. Also add a unit test that never lets this happen again: it checks that for every setting the newest `new_value` recorded in `SettingsChangesHistory.cpp` is exactly the current default, so that the `compatibility` setting cannot restore a value that was never a default of any release. Values are compared after casting them to the type of the setting, so `true`/`1` and other equivalent spellings do not produce false positives. Obsolete settings and settings that no longer exist are skipped. Closes: ClickHouse#111750
Added as a unit test, It is a unit test rather than a text check in Verified that it fails on the unfixed history — it reports exactly the five settings from #111750 (plus the Note that this checks the value; the complementary "a newly added setting must be recorded at all" check is the existing |
|
Workflow [PR], commit [90f997f] Summary: ✅
AI ReviewSummaryThis PR fixes several incorrect Findings❌ Blockers
Final VerdictRequest changes: the new CI guard still misses present-day default changes implemented as pure removals of the latest history entry. |
The 25.8 introduction entry for evaluation_time was recorded as 0 -> 0, but v25.8.1.5101-lts actually shipped with the auto default. This meant compatibility = '25.8' restored 0 instead of auto. Fixed by: - Recording the 25.8 evaluation_time entry as 0 -> auto (the actual drift) - Keeping the 25.9 promql_evaluation_time entry as a pure rename (auto -> auto)
I'm working on a check in this PR #111605. This check is actually how this problem was surfaced. |
|
@maxknv @alexey-milovidov — following up here since A couple of things I want to confirm before touching this branch further: Given that (Correction to my earlier comment: I'd mentioned a pending cleanup step involving a 03999_settings_value_drift_ignore.txt file — I've since verified that file doesn't exist in the repo, so that step doesn't apply. No action needed there.) Let me know and I'll proceed accordingly. |
`ClickHouse#111605` merged into `master` after this branch was opened. It adds the stateless test `03999_stateless_settings_history`, which checks exactly the invariant the unit test added here checked - that the newest `new_value` recorded in `SettingsChangesHistory.cpp` for every session and `MergeTree` setting equals the current default, which is what `compatibility` relies on - plus a `settings_changes_history` style check. Keeping a second C++ copy of the same invariant would mean maintaining two parallel skip lists, so `src/Core/tests/gtest_settings_changes_history.cpp` is removed in favour of the merged check. That test carries `03999_settings_value_drift_ignore.txt`, a list of settings whose current default already disagreed with the history and which "may only SHRINK: each name should be fixed in the history and removed". It lists exactly the five settings fixed by this change, so the list becomes empty and those five are now enforced. Verified for each of them that the newest recorded `new_value` equals the current default: `check_conversion_from_numbers_to_enum` `true` (26.1), `rewrite_count_distinct_if_with_count_distinct_implementation` `false` (23.8), `extract_key_value_pairs_max_pairs_per_row` `1000` (24.2), `output_format_pretty_fallback_to_vertical_max_rows_per_chunk` `10` (25.1), `promql_evaluation_time` `auto` (25.9); `cross_to_inner_join_rewrite` has no history entry at all now (its default was `1` in every release, the recorded `1` -> `2` change never happened) and its default matches the frozen baseline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…y` check The `settings_changes_history` style check added by `ClickHouse#111605` requires every setting whose entry this change adds to `src/Core/SettingsChangesHistory.cpp` to be recorded under the current version block. That rule is right for a default change made now, but wrong for a correction of what an older release actually did, which is what this change does: recording, say, `extract_key_value_pairs_max_pairs_per_row` under `26.8` would tell `compatibility` that its default changed again in `26.8`, and every older `compatibility` value would restore `0`, which was never a released default. So `parse_settings_history_changes` in `ci/jobs/scripts/workflow_hooks/store_data.py` now skips an added entry whose setting name is also removed by the same diff - an in-place correction or a relocation of an already recorded entry. Relocating an entry into the current version block still passes, because the entry is then in that block anyway. Newly recorded settings and pure reason-text edits are unaffected. Covered by the new `ci/tests/test_settings_history_diff_parser.py`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Updated: merged Answering the open question about the unit test: it is removed. #111605's
One CI-side adjustment was needed (@maxknv): the new On the AI-review finding (it pointed at the now-removed unit test): a stronger check that replays the whole chain backwards — current default must equal the newest Note: the emptied ignore list could not be exercised locally — linking |
|
Thanks for reconciling this with #111605, @alexey-milovidov — dropping the Nothing further from me on this branch; LGTM. |
…gs-source change The previous relaxation skipped any added history entry whose setting name was also removed by the diff. That fails open: an in-place value edit of an existing entry - a real default change recorded in the wrong (older) block - has the name on both sides and was silently dropped, exactly the case the check exists to catch. Instead, keep the parser strict (it reports new entries and in-place value edits, ignoring only reason-only edits) and decide enforcement in the style check: require an entry under the current version block only when a settings source file (Settings.cpp, FormatFactorySettings.h or MergeTreeSettings.cpp) also changed. A change that edits only SettingsChangesHistory.cpp is a historical correction - fixing what a past release recorded, not a default change made now - and is allowed; requiring it under the current version block would tell `compatibility` the value changed again in this release. This fails closed (an unrecorded in-place default change is still caught) while allowing the history-only corrections this PR makes. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Adjusted the CI-side relaxation (pushed to this branch). The previous version skipped any added history entry whose setting name was also removed by the diff. That relaxation fails open: an in-place value edit of an existing entry — a real default change recorded in the wrong (older) block — has the same name on both Instead the parser is strict again (it reports new entries and in-place value edits, ignoring only reason-only edits), and the enforcement decision now lives in the style check: it requires an entry under the current version block only when a settings source file also changed ( Net: this fails closed (an unrecorded in-place default change is still caught) while allowing the corrections this PR makes. The one trade-off is a PR that both changes a default and corrects an unrelated old entry would over-flag the correction — rare, and safe (over-strict with a clear message) rather than a silent hole. Parser behaviour is pinned by |
Address the review: the gate that distinguishes a historical correction from a present-day default change only looked at `src/Core/Settings.cpp`, `src/Core/FormatFactorySettings.h` and `src/Storages/MergeTree/MergeTreeSettings.cpp`. Many defaults are not written there but come from constants defined elsewhere, e.g. `DEFAULT_INSERT_BLOCK_SIZE`, `DEFAULT_BLOCK_SIZE` and `DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC` in `src/Core/Defines.h`. A change to one of those constants recorded only in an older history block would pass both the style check (skipped by the narrow gate) and `03999_stateless_settings_history` (it only compares the current default with the newest recorded `new_value`), silently recording a live default change as historical. The gate now keys off any changed `src/` source file other than `SettingsChangesHistory.cpp`: a change that touches no other source cannot have changed a compiled default, and anything else is enforced. This fails closed; the price is over-strictness for a change that both edits unrelated code and corrects an old entry, and the error message now says to split such a change. New `ci/tests/test_settings_history_source_gate.py` pins the gate, including the `src/Core/Defines.h` case from the review.
|
Merged The gate that tells a historical correction from a present-day default change only looked at The gate now keys off any changed The remaining red, |
…iles
Settings defaults are also selected by compile definitions such as
`CLICKHOUSE_CLOUD` and `ENABLE_DISTRIBUTED_CACHE`, which are driven by CMake
files and config templates (CMakeLists.txt, *.cmake, src/Common/config.h.in)
rather than by a `src/*.{h,cpp,inc}` declaration file. The gate in
`check_settings_changes_history` now treats those files as default-bearing
sources too, so a PR changing a compiled default through a build definition
can no longer record it only in an old version block. Pinned by new cases in
ci/tests/test_settings_history_source_gate.py.
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Addressed the AI-review blocker: the The one red on the previous run — |
| ] | ||
|
|
||
|
|
||
| def test_pure_removal_is_ignored(): |
There was a problem hiding this comment.
Deleting the last history row is still a silent escape hatch here. parse_settings_history_changes returns [] for pure removals, and check_settings_changes_history treats changed == [] as "nothing to validate", so a PR that flips a current default back to an older or baseline value can just delete the latest row instead of adding a current_version row and both guards stay green.
For example, if a setting was recorded as 0 -> 1 in 26.7 and a 26.8 source change reverts the compiled default to 0, removing the 26.7 record makes 03999_stateless_settings_history and this style check both pass even though compatibility = '26.7' now restores the wrong value. Pure removals from a default-bearing-source change need to be surfaced as changed settings, or otherwise validated, instead of being ignored.
There was a problem hiding this comment.
This is right, and it survived the merge. Fixed in a follow-up: #112782 — parse_settings_history_changes now reports removed records as well (namespace taken from the enclosing block, as for added lines), so a deletion of the newest row must be accompanied by a current-version record whenever a default-bearing source also changed. Moves between blocks and reason-only edits stay ignored, and deleting a phantom record is still possible because that change touches only SettingsChangesHistory.cpp and the source-file gate lets it through.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 43/43 (100.00%) · Uncovered code |
|
This is a real gap, but it's a different failure mode than what this PR's gate currently targets — the gate checks "did a default-bearing source change without a corresponding entry in the current block", whereas this flags a removal of the latest row silently invalidating the invariant, even with no entry added. @alexey-milovidov @maxknv — should this be handled in this PR (extending the parser to flag removals of a setting's newest row when a default-bearing source touches that setting in the same diff), or would you prefer it tracked as a separate follow-up issue since it's a distinct bug from the value-drift corrections this PR makes? Happy to do either, just don't want to guess given how much the gate's scope has already shifted over this thread. |
Follow-up to ClickHouse#111841, which left an unresolved review finding: deleting the last history row of a setting was a silent escape hatch. `parse_settings_history_changes` returned `[]` for pure removals and `check_settings_changes_history` treats an empty list as "nothing to validate", so a change that reverts a compiled default to an older value could delete the row that recorded the original change instead of recording the revert under the current version block, and stay green. `03999_stateless_settings_history` does not catch it either: it only compares the current default with the *newest* recorded `new_value`. The result is that `compatibility` hands out the wrong value for the release that shipped the other default. The parser now reports removed records as well, with the namespace taken from the enclosing block just as for added lines. Records moved between blocks and reason-only edits are still ignored (their value-signature appears on both sides of the diff). Deleting a phantom record remains possible: such a change touches only `SettingsChangesHistory.cpp`, and the source-file gate in `check_settings_changes_history` lets it through. Pinned by new cases in `ci/tests/test_settings_history_diff_parser.py` and an end-to-end case in `ci/tests/test_settings_history_source_gate.py`.
Closes: #111750
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Several settings had a value drift between their current default and the newest value recorded for them in
SettingsChangesHistory.cpp. Becausecompatibilityreconstructs old defaults from the recordedprevious_value/new_valuepairs, a default that does not match its newest recordednew_valuemeanscompatibilityrestores a value that was never a default of any release.Each entry is corrected in the version block where the change actually happened (verified against the released tags), not backfilled under the current version block:
cross_to_inner_join_rewrite: the default is1inv22.6,v22.7and every release since, so the recorded1->2change in22.7never happened; the entry is removed.rewrite_count_distinct_if_with_count_distinct_implementation: introduced in23.8with the defaultfalse, nottrue.extract_key_value_pairs_max_pairs_per_row: introduced in24.2with the default1000, so the entry is0->1000instead of0->0.output_format_pretty_fallback_to_vertical_max_rows_per_chunk: introduced in25.1with the default10, so the entry is0->10instead of0->100(the value100was never released).check_conversion_from_numbers_to_enum: two conflicting entries existed in the26.1block (false->trueandfalse->false); they are collapsed into the one that matches the current default.promql_evaluation_time: the25.9block recorded the rename ofevaluation_timetwice, and the second entry kept the pre-rename default0while the setting isauto; the two entries are collapsed into a single0->autoone. This one was found by the new check below.Since no entry is added to an old release block - only wrong values inside them are corrected - the upgrade check is not affected.
To make sure this does not happen again, a unit test
src/Core/tests/gtest_settings_changes_history.cppchecks, for every session setting and everyMergeTreesetting, that the newestnew_valuerecorded inSettingsChangesHistory.cppis exactly the current default. Values are cast to the type of the setting before being compared, so equivalent spellings (truevs1,0vsauto,''vs{}) do not produce false positives, and aliases are resolved. Obsolete settings and names that no longer exist as settings are skipped.Verified locally: the new unit test fails on the unfixed history (reporting exactly the settings listed above) and passes after the fix;
02995_new_settings_historystill matches its reference.