Repository navigation
Replace 02995_new_settings_history with a stateless settings-history test - #111605
Conversation
…test
The old `02995_new_settings_history` compared `system.settings` against a
committed value baseline (`02995_settings_26_6_1.tsv`) using a hard-coded
version threshold. Both had to be regenerated and bumped every release, and
the threshold drifted out of sync on a version bump, producing spurious
failures (the newly added setting looked undocumented once the reference
version advanced).
The new `03999_stateless_settings_history` derives everything from the running
binary and needs no per-release regeneration:
* New-setting check: any non-obsolete, non-alias setting absent from a frozen
name-only snapshot must have a row in `system.settings_changes`.
* Reverse check: every name in `system.settings_changes` must still exist as
a setting (catches typos and renames).
* Value-drift check: for every documented setting the current default must
equal the `new_value` recorded at its highest version; otherwise a default
was changed without recording it and `compatibility` restores a wrong value.
The frozen snapshot may only shrink (a name is removed when a setting is
dropped); new settings can never be added to it. Four pre-existing value
drifts are parked in a shrink-only ignore list to be fixed separately.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [30f217f] Summary: ✅ AI ReviewSummaryThis PR replaces Findings
Final VerdictStatus: |
| # Tags: no-random-settings, no-random-merge-tree-settings | ||
| # | ||
| # Stateless replacement for 02995_new_settings_history: | ||
| # * No per-release regeneration and no hard-coded version threshold. |
There was a problem hiding this comment.
Not having per-release generation means this fails to catch the most common issue, which is why the test was introduced as a pre-check before upgrade check: when you add the setting change in the wrong version. If I change a setting value today, but add it in 26.7 block (instead of 26.8) this will fail to detect it
There was a problem hiding this comment.
Manual monthly update in the version bump pr is painful
I think the most common issue is that the setting update was not reflected in the history at all. A more accurate per-version check is done in the Upgrade check.
If you think it's reasonable to test that the update was not added to the old version block in a fast test, I suggest adding separate check to style job. WDYT?
There was a problem hiding this comment.
#111450 in the version bump pr is painful
Believe me, it's way more painful to deal with weeks later or after the release.
I think the most common issue is that the setting update was not reflected in the history at all. A more accurate per-version check is done in the Upgrade check.
The upgrade check is not synchronized between pre-release / branching and the initial release, so you have one week of people adding new settings to the old block, then the release happen and all PRs (master, and any run) fail the Upgrade check. This is exactly why the test was introduced in the first place.
If you think it's reasonable to test that the update was not added to the old version block in a fast test, I suggest adding separate check to style job. WDYT?
That would be ok too. As long as it's done in the merge commit (we need the current merge version) I think it should be possible to do a diff check and validate it
There was a problem hiding this comment.
The upgrade check is not synchronized between pre-release / branching and the initial release, so you have one week of people adding new settings to the old block, then the release happen and all PRs fail the Upgrade check. This is exactly why the test was introduced in the first place.
Just to clarify. The "old" test properly validates only if someone regenerates the TSV file with the settings baseline directly in the version bump PR, or separately at the very moment the new branch starts. If they fail to do so, then this "one week" of settings changes goes unchecked, right?
There was a problem hiding this comment.
Just to clarify. The "old" test properly validates only if someone regenerates the TSV file with the settings baseline directly in the version bump PR, or separately at the very moment the new branch starts. If they fail to do so, then this "one week" of settings changes goes unchecked, right?
Yes, which is why regenerating the TSV is part of the release guide. Obviously if we can do it without files it'd be much better for everyone
There was a problem hiding this comment.
There was a problem hiding this comment.
We have to move the setting to the proper block.
Otherwise what could happen is something like:
- I create a service with 26.7. Set its compatibility to 26.7 to control upgrades.
- Next month I update to 26.8, which introduces new_setting_A with a major breaking change.
- I was using compatibility so I thought it was safe and under control, but as the setting was added in the wrong block, it will enable it for 26.7 too, changing the behaviour unexpectedly. If it was added correctly under 26.8 then it would not be active until I raise the compatibility value (after the update finishes and I validate nothing breaks).
There was a problem hiding this comment.
Added style test to check settings update included in the current version block in the version history.
Together with the new functional test, it ensures history is entirely consistent:
- All changes corresponds to the final Settings state
- Version history updated for correct clickhouse version
No manual settings baseline generation needed.
There was a problem hiding this comment.
The current version-block check still misses one real wrong-version edit pattern. In ci/jobs/scripts/workflow_hooks/store_data.py:60-62, an added entry is dropped whenever its value-signature also appears on a removed line. If someone moves an unchanged setting from the current block to an older block, that add/remove pair has the same signature, so changed_settings becomes empty and ci/jobs/check_style.py:617-620 exits through the "nothing to validate" path. The stateless query still passes because the setting remains documented somewhere, so the original "wrong version block" gap from this thread is still reproducible.
0828c70 to
cf81654
Compare
Addresses review feedback: the value-drift check only covered Session settings, so a MergeTree default changed in code without updating SettingsChangesHistory.cpp (making `compatibility` restore a wrong value) went undetected. Add a mergetree_expected_default CTE and a matching arm that compares each non-obsolete MergeTree setting's current default against the new_value recorded at its highest version. Float comparison is made via toFloat32 on both sides so a Float32 value rendered at Float64 precision (e.g. shared_merge_tree_merge_coordinator_factor 1.1 vs 1.100000023841858) is not a false positive; the same normalization is applied to the Session arm. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
d779e93 to
bbad353
Compare
bbad353 to
58ccdb5
Compare
Algunenano
left a comment
There was a problem hiding this comment.
In general it looks great and it should allow us to simplify managing releases 🙏
I expect we'll have to tweak it if we moved away from using SettingsChangesHistory (to avoid constant conflicts) but that's doable and we'll deal with it once it comes
e619818 to
b54ca69
Compare
…vector order) The value-drift check reduced each setting's history with argMax(new_value, vnum), which is non-deterministic when a setting appears more than once at its highest version. The compatibility mechanism applies entries in ascending version order and, within a version, in vector order, so the effective latest value is the last entry, not an arbitrary row among ties. Break ties by the entry index within the block (argMax over the tuple (version, index)) so the expected default is computed exactly as compatibility would apply it. This surfaced a previously hidden drift: check_conversion_from_numbers_to_enum appears twice in the 26.1 block (new_value 1 then 0); its effective latest value is 0 while the current default is 1. Added it to the shrink-only value-drift ignore list to be fixed separately (see the drift tracking issue). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ent version
Adds a style check (ci/jobs/check_style.py: settings_changes_history) that, when
src/Core/SettingsChangesHistory.cpp is changed, verifies every setting the change
adds or value-changes is recorded under the block for the current version
(cmake/autogenerated_versions.txt), in addition to any older block used for
backports. Pure text parsing, no C++ syntax analysis.
The list of changed settings is produced by the store_data.py workflow hook, which
fetches the file's patch via the GitHub API (CI checkouts have no .git history) and
parses it:
* A setting is treated as changed when an added entry's value-signature (name and
values, excluding the reason text) is not also present on a removed line, so a
real value change edited in place is detected while a reason-only edit is ignored.
* Each changed setting carries the namespace of the block its added line sits in
(Session vs MergeTree), so a name that exists in both histories but changed in
only one namespace is not spuriously required in the other.
Fail-close: if the file changed but the diff (or changed_files) cannot be fetched
- e.g. in the merge queue - the check fails rather than silently passing.
Together with the 03999_stateless_settings_history functional test (which checks
that the recorded value matches the final Settings state) this keeps the settings
history consistent with the release version. Both the pull_request and merge_queue
workflows run the same hook and style check, so the merge queue performs the same test.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
b54ca69 to
c43299a
Compare
|
Addressed the latest review round (pushed in
Fail-close is preserved: if the file changed but the diff can't be fetched (e.g. in the merge queue), the check fails rather than passing. |
a906aee to
c43299a
Compare
The stateless test only value-checked settings that already have a row in system.settings_changes, and treated everything in the frozen name snapshot as grandfathered. That left a large class uncovered: a long-lived setting present in the baseline but with no history row (e.g. aggregation_in_order_max_block_bytes, adaptive_write_buffer_initial_size) could have its default changed in Settings.cpp with no edit to SettingsChangesHistory.cpp, and all checks stayed green - strictly weaker than the old 02995 test, which compared against a name+default baseline. Extend the frozen baseline from (name, kind) to (name, kind, default) and add an arm: a baseline setting whose current default differs from the frozen baseline default and that has no history row must be recorded in SettingsChangesHistory.cpp. Settings that do have a history row remain covered by the value-drift arm. Current and baseline defaults both come from system.settings, so they are compared directly (auto(...) values are skipped as machine-specific). The baseline stays FROZEN - never regenerated per release: a legitimate future default change adds a history entry (documented, so not flagged), and the file is only edited to drop a removed setting. Renamed 03999_settings_history_baseline_names.tsv to 03999_settings_history_baseline.tsv since it now carries values. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
9e26759 to
1643e29
Compare
GitHub omits the per-file `.patch` for very large diffs; `jq -r` then prints the literal string "null" rather than an empty result, so the previous `not patch.strip()` guard did not fire and the change was parsed as "no settings touched" - a silent pass. Treat both "" and "null" as a fetch failure so the settings-history style check fails closed (via the missing changed-settings data) instead of green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ks on Cloud The frozen baseline stores OSS compiled defaults, but max_table_size_to_drop, max_partition_size_to_drop (Session) and min_bytes_for_wide_part (MergeTree) have different compiled defaults in Cloud and no history row, so on a Cloud build the "default changed since baseline but has no history entry" arm flagged all three even when SettingsChangesHistory.cpp was untouched (reproduced in the private-repo CI run). Restore the variant-specific exclusion the deleted 02995_new_settings_history.sh had: a cloud_divergent_settings CTE that lists those three names only when system.build_options.CLICKHOUSE_CLOUD = '1' (empty on OSS, so OSS coverage is unchanged), excluded from all value-comparison arms. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`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]>
The test compares `system.settings` / `system.merge_tree_settings` against baselines captured from a *pre-release* of 26.6, and required every setting missing from the baselines to have a `SettingsChangesHistory.cpp` entry with a version strictly greater than `26.6`. That is too strict for a setting introduced later in the 26.6 series. The `MergeTree` setting `text_index_serialization_version` was added to the 26.6 branch by the backport of ClickHouse#111803, i.e. after the v26.6.1 pre-release the baselines were generated from, so it is absent from `02995_merge_tree_settings_settings_26_6_1.tsv` while its history entry correctly says `26.6`. As a result the test failed deterministically for every pull request based on `26.7`: PLEASE ADD THE NEW MERGE_TREE_SETTING TO SettingsChangesHistory.cpp: text_index_serialization_version WAS ADDED Accept `26.6` in the version comparison: a setting that is absent from the baselines must carry a history entry of 26.6 or later. No strictness is lost - settings that were already present in the baselines never reach this predicate. On `master` the test does not exist anymore, it was replaced by `03999_stateless_settings_history` in ClickHouse#111605, so this fix is only needed on the release branch.


Related: #111450
Changelog category (leave one):
02995_new_settings_historycomparedsystem.settingsagainst a committedvalue baseline (
02995_settings_26_6_1.tsv) gated by a hard-coded versionthreshold. Both the baseline and the threshold had to be regenerated and bumped
every release, and the threshold drifts out of sync on a version bump: once the
reference version advances, a setting recorded under the previous version is no
longer counted and looks undocumented (the failure seen when the binary was
bumped to 26.8 in #111450 — undocumented in both the Upgrade check and, after
the 26.7.1 baseline refresh, in the stateless test).
The replacement
03999_stateless_settings_historyderives everything from therunning binary and needs no per-release regeneration:
frozen, name-only snapshot must have a row in
system.settings_changes.system.settings_changesmust still existas a setting (catches typos/renames; the old test never checked this).
current default must equal the
new_valuerecorded at its highest version;otherwise a default was changed without recording it and
compatibilityrestores the wrong value.
The frozen snapshot may only shrink (a name is removed when a setting is
dropped) — new settings can never be added to it. The value-drift check already
found four pre-existing drifts (
cross_to_inner_join_rewrite,extract_key_value_pairs_max_pairs_per_row,output_format_pretty_fallback_to_vertical_max_rows_per_chunk,rewrite_count_distinct_if_with_count_distinct_implementation), parked in ashrink-only ignore list to be fixed separately.
Version-block style check
The functional test guarantees that every setting change is recorded somewhere
in the history with the right value, but not under which version. A new style
check (
ci/jobs/check_style.py:settings_changes_history) closes that gap: whensrc/Core/SettingsChangesHistory.cppis changed, it verifies every setting thechange adds or value-changes is recorded under the block for the current
version (
cmake/autogenerated_versions.txt), in addition to any older blockkept for backports. It is pure text parsing (no C++ syntax analysis): the changed
setting names come from the file's patch (fetched via the GitHub API in the
store_data.pyworkflow hook, since CI checkouts have no.githistory), and theblock membership is parsed from the final file. The check fails closed — if the
file changed but its diff cannot be fetched (e.g. in the merge queue), it fails
rather than silently passing. Both the pull-request and merge-queue workflows run
the same hook and style check.
Together the two checks keep the settings history consistent with the release
version at PR time, removing the manual per-release baseline update.
Version info
26.8.1.212(included in26.8and later)