Skip to content

Replace 02995_new_settings_history with a stateless settings-history test - #111605

Merged
maxknv merged 7 commits into
masterfrom
stateless-settings-history-test
Jul 27, 2026
Merged

maxknv merged 7 commits into
masterfrom
stateless-settings-history-test

Conversation

@maxknv

@maxknv maxknv commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Related: #111450

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

02995_new_settings_history compared system.settings against a committed
value baseline (02995_settings_26_6_1.tsv) gated by a hard-coded version
threshold. 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_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/renames; the old test never checked this).
  • Value-drift check — for every documented Session or MergeTree 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 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 a
shrink-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: when
src/Core/SettingsChangesHistory.cpp is changed, it 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
kept 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.py workflow hook, since CI checkouts have no .git history), and the
block 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

  • Merged into: 26.8.1.212 (included in 26.8 and later)

…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]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [30f217f]

Summary: ✅


AI Review

Summary

This PR replaces 02995_new_settings_history with a frozen baseline plus a style check around SettingsChangesHistory.cpp, which is directionally better and removes the per-release TSV regeneration. The remaining problem is that the new guard is still not fail-closed in a few important cases: one wrong-version-block edit pattern is still invisible to the style hook, and both new "shrink-only" data files can still be expanded in the same PR to bypass the stateless test entirely.

Findings

⚠️ Majors

  • [ci/jobs/scripts/workflow_hooks/store_data.py:60-62; ci/jobs/check_style.py:617-620] Moving an unchanged entry from the current version block to an older block is still invisible to the new style check. parse_settings_history_changes drops any added entry whose value-signature also appears on a removed line, so a pure move produces []; check_settings_changes_history then exits through the "nothing to validate" path. I verified that with the current helper: a synthetic remove+add patch for the same signature still returns an empty change list. The functional test stays green because the setting is still documented somewhere and its highest recorded new_value did not change, so the original wrong-version-block regression is still reproducible. Suggested fix: only classify an add/remove pair as a reason-only edit when it stays in the same version block; a same-signature move across blocks still has to surface as a changed setting.
  • [dismissed by author -- https://github.com/Replace 02995_new_settings_history with a stateless settings-history test #111605#discussion_r3644835476] [tests/queries/0_stateless/03999_stateless_settings_history.sh:17-18,103-105,178-184; tests/queries/0_stateless/03999_settings_history_baseline.tsv:1] The frozen baseline is documented as shrink-only, but there is still no enforcement. A PR can add a new setting and append its name/kind/default to 03999_settings_history_baseline.tsv; the "new setting" arm stops seeing it because the name is now in baseline, and the "no history entry" arm also stops seeing it because the committed baseline default now matches the new current default. That makes the snapshot file an escape hatch for exactly the undocumented-setting bug this replacement is meant to prevent. Suggested fix: compare the baseline file with the merge-base copy and fail on added lines.
  • [dismissed by author -- https://github.com/Replace 02995_new_settings_history with a stateless settings-history test #111605#discussion_r3645273194] [tests/queries/0_stateless/03999_stateless_settings_history.sh:25-28,140,160,183,197; tests/queries/0_stateless/03999_settings_value_drift_ignore.txt:1] The new value-drift allowlist has the same bypass. It is described as shrink-only, but nothing stops a PR from hiding an unrecorded default change by appending the setting name here; every value-comparison arm checks name NOT IN (SELECT name FROM value_drift_ignore), so CI will green-light the change. Suggested fix: enforce a deletions-only contract for 03999_settings_value_drift_ignore.txt in the same place as the baseline guard.
Final Verdict

Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 23, 2026
@maxknv
maxknv requested a review from Algunenano July 23, 2026 13:28
@Algunenano Algunenano self-assigned this Jul 23, 2026
@maxknv

maxknv commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

checked on a test setting:
image

# 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Algunenano Algunenano Jul 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@maxknv maxknv Jul 23, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And one more question. Here is a PR with the setting updates that were merged after the 26.7 branch started. Here is a patch that moves it to 26.8's block and fixes Upgrade check failure.

Is it important to actually move the setting, or is it only a matter of fixing the upgrade check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. All changes corresponds to the final Settings state
  2. Version history updated for correct clickhouse version

No manual settings baseline generation needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@maxknv
maxknv force-pushed the stateless-settings-history-test branch from 0828c70 to cf81654 Compare July 23, 2026 13:58
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]>
@maxknv
maxknv force-pushed the stateless-settings-history-test branch 2 times, most recently from d779e93 to bbad353 Compare July 23, 2026 19:53
@maxknv
maxknv force-pushed the stateless-settings-history-test branch from bbad353 to 58ccdb5 Compare July 24, 2026 07:55
@maxknv

maxknv commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

style check example:
image

Comment thread ci/jobs/check_style.py Resolved

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

maxknv and others added 2 commits July 24, 2026 12:08
…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]>
@maxknv
maxknv force-pushed the stateless-settings-history-test branch from b54ca69 to c43299a Compare July 24, 2026 10:09
@maxknv

maxknv commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Addressed the latest review round (pushed in d906f23 + c43299):

  • In-place value edits recorded under the wrong version block are now caught. The hook compares each added entry's value-signature (name + values, reason text excluded) against removed lines, so a real value change edited in place is detected while a reason-only edit is ignored.
  • Namespace overlap (dead_blobs_to_delay_insert, allow_minmax_index_for_json, dead_blobs_to_throw_insert): each changed setting now carries the namespace of the block its added line sits in; the check validates only that namespace, so a one-namespace change no longer demands a bogus entry in the other.
  • Non-deterministic reduction: argMax(new_value, vnum) is replaced with an order-aware argMax(new_value, (vnum, idx)) (entries indexed via arrayEnumerate), reproducing exactly the last entry compatibility applies. This surfaced check_conversion_from_numbers_to_enum (duplicate/conflicting 26.1 entries; effective 0 vs default 1), now tracked with the other drifts in Settings value drift: current default disagrees with newest recorded value in SettingsChangesHistory.cpp #111750.

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.

@maxknv
maxknv force-pushed the stateless-settings-history-test branch from a906aee to c43299a Compare July 24, 2026 10:31
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]>
@maxknv
maxknv force-pushed the stateless-settings-history-test branch from 9e26759 to 1643e29 Compare July 24, 2026 11:59
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]>
@maxknv
maxknv added this pull request to the merge queue Jul 27, 2026
Merged via the queue into master with commit 1072752 Jul 27, 2026
524 of 528 checks passed
@maxknv
maxknv deleted the stateless-settings-history-test branch July 27, 2026 15:32
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 27, 2026
alexey-milovidov added a commit to adityaksolves/Clickhouse that referenced this pull request Jul 28, 2026
`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]>
alexey-milovidov added a commit to adityaksolves/Clickhouse that referenced this pull request Jul 28, 2026
…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]>
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 4, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants