Skip to content

Fix settings value drift in SettingsChangesHistory.cpp - #111841

Merged
alexey-milovidov merged 12 commits into
ClickHouse:masterfrom
adityaksolves:fix/settings-value-drift
Jul 31, 2026
Merged

alexey-milovidov merged 12 commits into
ClickHouse:masterfrom
adityaksolves:fix/settings-value-drift

Conversation

@adityaksolves

@adityaksolves adityaksolves commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #111750

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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. Because compatibility reconstructs old defaults from the recorded previous_value / new_value pairs, a default that does not match its newest recorded new_value means compatibility restores 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 is 1 in v22.6, v22.7 and every release since, so the recorded 1 -> 2 change in 22.7 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, so the entry is 0 -> 1000 instead of 0 -> 0.
  • output_format_pretty_fallback_to_vertical_max_rows_per_chunk: introduced in 25.1 with the default 10, so the entry is 0 -> 10 instead of 0 -> 100 (the value 100 was never released).
  • check_conversion_from_numbers_to_enum: two conflicting entries existed in the 26.1 block (false -> true and false -> false); they are collapsed into the one that matches the current default.
  • 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 a single 0 -> auto one. 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.cpp checks, for every session setting and every MergeTree setting, that the newest new_value recorded in SettingsChangesHistory.cpp is exactly the current default. Values are cast to the type of the setting before being compared, so equivalent spellings (true vs 1, 0 vs auto, '' 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_history still matches its reference.

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
Comment thread src/Core/SettingsChangesHistory.cpp Resolved
@alexey-milovidov alexey-milovidov self-assigned this Jul 26, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Add a corresponding style check, so that this problem never happens again.

@adityaksolves

Copy link
Copy Markdown
Contributor Author

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:

  • cross_to_inner_join_rewrite: 26.1 (commit bae12d4)
  • output_format_pretty_fallback_to_vertical_max_rows_per_chunk: 25.2 (commit 31dda7d) — but the 25.2 block is marked "Release closed, please use 25.3"
  • still tracing the other two

Separately: I noticed upgrade_runner.sh's check requires the entry's version to be strictly greater than the previous release version, or the Upgrade check fails (saw this happen on a sibling PR with a 26.7 entry that had to be moved to 26.8 for that reason). If I move output_format_pretty_fallback_to_vertical_max_rows_per_chunk back to 25.2, that check would presumably fail again since 25.2 is far behind the current release.

Which would you prefer:

  1. Keep all entries under 26.8 as the issue describes (simplest, avoids the closed-block and upgrade-check issues), or
  2. Move each to its historically accurate version, and separately handle whatever the Upgrade check needs for the ones that land in old/closed blocks?

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
@alexey-milovidov

Copy link
Copy Markdown
Member

Add a corresponding style check, so that this problem never happens again.

Added as a unit test, src/Core/tests/gtest_settings_changes_history.cpp: for every session setting and every MergeTree setting it checks that the newest new_value recorded in SettingsChangesHistory.cpp is exactly the current default of that setting. This is precisely the invariant that compatibility relies on — if it is violated, compatibility restores a value that was never a default of any release.

It is a unit test rather than a text check in check_style.py because the comparison has to be type-aware: the values are cast with castValueUtil to the type of the setting before being compared, so true vs 1, 0 vs auto for MaxThreads, '' vs {} for Map and similar equivalent spellings do not produce false positives, and aliases are resolved with resolveName (this is how the stale evaluation_time entry was found). Obsolete settings and names that no longer exist as settings are skipped.

Verified that it fails on the unfixed history — it reports exactly the five settings from #111750 (plus the evaluation_time one) — and passes after the fix.

Note that this checks the value; the complementary "a newly added setting must be recorded at all" check is the existing 02995_new_settings_history, which still passes.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [90f997f]

Summary: ✅


AI Review

Summary

This PR fixes several incorrect SettingsChangesHistory.cpp records and significantly improves the settings_changes_history CI gate by distinguishing history-only corrections from live default changes. The history fixes themselves look consistent, but the new guard still has one fail-open path that can silently break compatibility, so I do not think it is ready as-is.

Findings

❌ Blockers

  • [ci/tests/test_settings_history_diff_parser.py:90] Deleting the effective latest history row is still treated as a no-op by the parser and the style check. A PR that changes a compiled default back to an older or baseline value can remove the newest row instead of appending a current_version row, and both 03999_stateless_settings_history and check_settings_changes_history stay green even though compatibility now reconstructs the wrong default for the versions in between.
    Suggested fix: report pure removals from SettingsChangesHistory.cpp when a default-bearing source also changed, or add an equivalent check that rejects removing the latest effective row without a replacement in the current version block.
Final Verdict

Request changes: the new CI guard still misses present-day default changes implemented as pure removals of the latest history entry.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 27, 2026
Comment thread src/Core/SettingsChangesHistory.cpp Resolved
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)
@maxknv

maxknv commented Jul 27, 2026

Copy link
Copy Markdown
Member

Add a corresponding style check, so that this problem never happens again.

I'm working on a check in this PR #111605. This check is actually how this problem was surfaced.

@maxknv
maxknv marked this pull request as draft July 27, 2026 12:26
@maxknv maxknv self-assigned this Jul 27, 2026
@adityaksolves

adityaksolves commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@maxknv @alexey-milovidov — following up here since
#111605 has since merged into master (commit 1072752), which added the 03999_stateless_settings_history stateless test and the new check_style.py: settings_changes_history style check.

A couple of things I want to confirm before touching this branch further:

Given that
#111605's mechanism is what originally surfaced this issue, is gtest_settings_changes_history.cpp (the C++ unit test added here) still needed alongside it, or does it now overlap enough with the new stateless test + style check that it should be trimmed/removed? Happy to do either, just don't want to unilaterally drop coverage that's still filling a gap.
Is this PR ready to be picked back up / marked ready for review again, or is there more you'd like to change first?

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

alexey-milovidov and others added 3 commits July 28, 2026 06:56
`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]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jul 28, 2026
@alexey-milovidov
alexey-milovidov marked this pull request as ready for review July 28, 2026 07:20
@alexey-milovidov

Copy link
Copy Markdown
Member

Updated: merged master (which now contains #111605) and reconciled this PR with it.

Answering the open question about the unit test: it is removed. #111605's 03999_stateless_settings_history checks exactly the same invariant this PR's gtest_settings_changes_history.cpp checked — for every session and MergeTree setting, the newest new_value recorded in SettingsChangesHistory.cpp must equal the current default, which is what compatibility relies on — and it does it server-side, with the real setting types, plus it also covers "a new setting must be recorded at all" and dangling history names. Keeping a second C++ copy would mean maintaining two parallel skip lists for the same rule, so the merged check is the one to keep. @alexey-milovidov, the "corresponding style check" you asked for is therefore in place, just via #111605.

03999_settings_value_drift_ignore.txt is now empty. That file listed exactly the five settings fixed here, with the note that it "may only SHRINK: each name should be fixed in the history and removed" — so the five are removed and are now enforced by the test. Cross-checked each newest recorded new_value against 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, via the corrected evaluation_time entry). cross_to_inner_join_rewrite now has no history entry at all — its default was 1 in every release, so the recorded 1 -> 2 change never happened — and its default matches the frozen baseline, so that arm passes too.

One CI-side adjustment was needed (@maxknv): the new settings_changes_history style check requires every setting whose entry the diff adds to be recorded under the current version block. That is right for a default change made now, but wrong for a correction of what an older release did — recording extract_key_value_pairs_max_pairs_per_row under 26.8 would tell compatibility that its default changed again in 26.8, so every older compatibility value would restore 0, which was never a released default. parse_settings_history_changes now skips an added entry whose setting name is also removed by the same diff (an in-place correction or a relocation of an existing record); relocating an entry into the current block still passes, since the entry is then in that block anyway. New settings and reason-text-only edits are unaffected, and the behaviour is pinned by ci/tests/test_settings_history_diff_parser.py.

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 new_value, then step back to its previous_value, and so on — would indeed also catch wrong intermediate previous_values. It is not added here because the existing history has several pre-existing chain contradictions inside single version blocks (enable_lightweight_update in 25.8, allow_statistics_optimize / enable_time_time64_type in 25.12, query_plan_reuse_storage_ordering_for_window_functions in 26.1, allow_statistics in 26.3), so it belongs in a separate change on top of #111605's test together with fixing those. Happy to do that as a follow-up.

Note: the emptied ignore list could not be exercised locally — linking clickhouse was killed for memory on this machine — so 03999_stateless_settings_history is verified by CI here; the value comparison itself was cross-checked against the declarations as listed above.

@alexey-milovidov

Copy link
Copy Markdown
Member

The one red on the previous run — Stress test (amd_debug), Logical error: Inconsistent KeyCondition behavior — is unrelated to this change (it touches only SettingsChangesHistory.cpp and CI scripts). It is being fixed in #111964 and tracked by #107951.

@adityaksolves

Copy link
Copy Markdown
Contributor Author

Thanks for reconciling this with #111605, @alexey-milovidov — dropping the
duplicate unit test in favor of the stateless check makes sense, and the
CI parser fix for in-place corrections resolves the version-block friction
I'd flagged earlier.

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]>
@maxknv

maxknv commented Jul 28, 2026

Copy link
Copy Markdown
Member

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 - and + lines, so it was silently dropped. That's exactly the "default updated under the wrong version block" case the check was added to catch, and with a version bump between authoring and merge it could also slip through the merge queue.

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 (Settings.cpp, FormatFactorySettings.h, or MergeTreeSettings.cpp). A change that edits only SettingsChangesHistory.cpp — like the historical corrections in this PR — has no source-default change, so it's a correction, 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, which never happened.

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 ci/tests/test_settings_history_diff_parser.py.

@maxknv
maxknv marked this pull request as draft July 28, 2026 11:18
@maxknv
maxknv marked this pull request as ready for review July 28, 2026 11:36
Comment thread ci/jobs/check_style.py Resolved
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.
@alexey-milovidov

Copy link
Copy Markdown
Member

Merged master and addressed the AI-review blocker on the settings_changes_history gate.

The gate that tells 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: they come from constants such as DEFAULT_INSERT_BLOCK_SIZE, DEFAULT_BLOCK_SIZE and DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC in src/Core/Defines.h. Changing one of those and recording it only in an older block would have passed both this check (skipped by the narrow gate) and 03999_stateless_settings_history (which only compares the current default with the newest recorded new_value) - a live default change silently recorded 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, so it is a correction; anything else is enforced. This fails closed. The trade-off is over-strictness for a change that both edits unrelated code and corrects an old entry, and the failure message now says to split that into a history-only change. New ci/tests/test_settings_history_source_gate.py pins the behaviour, including the src/Core/Defines.h case.

The remaining red, Stress test (arm_asan_ubsan) - signed integer overflow at src/Functions/toStartOfInterval.cpp:293 under the AST fuzzer - is unrelated to this change (it touches only SettingsChangesHistory.cpp and CI scripts). It is fixed by #112045, which is not merged yet.

@maxknv
maxknv self-requested a review July 29, 2026 08:58
Comment thread ci/jobs/check_style.py Resolved
alexey-milovidov and others added 2 commits July 30, 2026 19:47
…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]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Addressed the AI-review blocker: the settings_changes_history gate now also treats build-definition files (CMakeLists.txt, *.cmake, *.h.in config templates) as default-bearing sources, since compile definitions such as CLICKHOUSE_CLOUD and ENABLE_DISTRIBUTED_CACHE select settings defaults at build time. Pinned by new cases in ci/tests/test_settings_history_source_gate.py.

The one red on the previous run — 01666_merge_tree_max_query_limit on the parallel-replicas coverage runner — is a known flake (#112426), already fixed on master by #112385; merging master into this branch pulls the fix in.

]


def test_pure_removal_is_ignored():

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.

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.

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.

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.

@clickhouse-gh

clickhouse-gh Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.60% 78.60% +0.00%

Changed lines: Changed C/C++ lines covered: 43/43 (100.00%) · Uncovered code

Full report · Diff report

@adityaksolves

Copy link
Copy Markdown
Contributor Author

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.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 31, 2026
Merged via the queue into ClickHouse:master with commit 08e98d8 Jul 31, 2026
178 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 31, 2026
pull Bot pushed a commit to Spencerx/ClickHouse that referenced this pull request Aug 2, 2026
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-not-for-changelog This PR should not be mentioned in the changelog 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.

Settings value drift: current default disagrees with newest recorded value in SettingsChangesHistory.cpp

4 participants