Skip to content

Settings history style check: surface removed records - #112782

Merged
alexey-milovidov merged 4 commits into
masterfrom
settings-history-removal-escape-hatch
Aug 2, 2026
Merged

alexey-milovidov merged 4 commits into
masterfrom
settings-history-removal-escape-hatch

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #111841 (merged), which left one 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 both guards stayed green — 03999_stateless_settings_history only compares the current default with the newest recorded new_value. The consequence is that compatibility hands out the wrong value for the release that actually shipped the other default.

The diff parser now reports removed records too, with the namespace taken from the enclosing addSettingsChanges block just as for added lines. Records moved between blocks and reason-only edits are still ignored, because 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 (16 tests pass, ruff check clean).

Related: #111841
Related: #111605

Changelog category (leave one):

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

Version info

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

Follow-up to #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`.
@clickhouse-gh

clickhouse-gh Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1f691e0]

Summary: ✅


AI Review

Summary

This PR extends the settings-history style check so removals, moves, and addSettingsChanges header edits are surfaced to check_settings_changes_history. That closes several earlier escape hatches, but one important deletion case is still missed: removing the first block of a history can still make the parser report no changed settings at all, so I would not approve it yet.

Findings

❌ Blockers

  • [ci/jobs/scripts/workflow_hooks/store_data.py:179] Deleting the first addSettingsChanges block still bypasses the parser. The new headers_removed fallback resolves a removed block by looking at lineno - 1 in the post-image, but for the leading block there is no preceding header to recover the block identity from. A concrete repro is deleting the leading 26.8 block from SettingsChangesHistory.cpp: parse_settings_history_changes returns [], so check_settings_changes_history treats the PR as "nothing to validate" even if src/Core/Settings.cpp changed in the same diff. That reopens the exact compatibility-attribution hole this change is meant to close, now at whole-block granularity. Suggested fix: track removed blocks from the old-side diff state instead of mapping them onto the previous block in the post-image, and add a regression test that deletes the first block.
Final Verdict

Changes required.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 31, 2026
`parse_settings_history_changes` suppressed any added or removed entry whose
value-signature appeared on the other side of the diff, which covered both
reason-only edits and records *moved* between blocks. That left the escape hatch
open in "move instead of delete" form: re-adding an unchanged record under an
older version block keeps the newest recorded value intact, so
`03999_stateless_settings_history` still passes, while `compatibility` starts
attributing the default flip to the release of the older block.

The suppression key now includes the enclosing block - namespace and version -
resolved for both sides of the diff, so only a reason-only edit of an entry that
stays in its block is ignored; a move to another version or namespace block is
reported once and `check_settings_changes_history` then requires the setting
under the current version block. A removed line is resolved from the new-file
line *before* the diff position, so dropping the last entry of a block is not
attributed to the block that follows.

New cases in `ci/tests/test_settings_history_diff_parser.py` (move to an older
block, move between namespaces, reorder inside one block) and an end-to-end case
in `ci/tests/test_settings_history_source_gate.py`.
…nges` header changed

A block header edit reassigns every record underneath it to another release or
namespace without touching a single entry line, so the entry-level scan in
`parse_settings_history_changes` returned `[]` and `check_settings_changes_history`
treated the change as "nothing to validate" - the same `compatibility`
misattribution hole, at block granularity.

The parser now records added and removed `addSettingsChanges` header lines and
reports every entry of the affected block. A header rewritten in place is covered
by the added header at that position; a header that is only removed merges its
records into the block above, which is reported instead.
# only costs an extra name in a message that is already failing for the removed rows.
if lineno in headers_added:
continue
header_index = _settings_history_block_header_index(file_lines, lineno - 1)

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 first addSettingsChanges block still comes back as [] here, so the escape hatch remains open for the current-version block. With a patch that removes the leading 26.8 block, both headers_removed and removed-entry resolution walk to lineno - 1; in the post-image there is no preceding header, so _settings_history_block_header_index returns None and parse_settings_history_changes reports nothing. check_settings_changes_history then treats a PR that deletes the whole current block and changes src/Core/Settings.cpp as "nothing to validate".

This needs to resolve a removed block against the removed header / removed entries themselves (old-side diff state), not only against the preceding block in the post-image. Please add a regression test for deleting the first block.

@alexey-milovidov alexey-milovidov left a comment

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.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Aug 2, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 2, 2026
Merged via the queue into master with commit 64bad90 Aug 2, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the settings-history-removal-escape-hatch branch August 2, 2026 16:35
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 2, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 3, 2026
`store_data.py` conflicted with the merged ClickHouse#112782, which extended
`parse_settings_history_changes` to also report value-edits, removals, moves between
`addSettingsChanges` blocks and block-header edits.

Union resolution, verified by AST rather than by reading: the two sides add disjoint
top-level symbols at the same anchor (`fetch_settings_history_patch`,
`settings_history_fetch_error_message`, `store_settings_history_changes`,
`SETTINGS_HISTORY_FILE` here; `_settings_history_block_at`,
`_settings_history_block_entries`, `_settings_history_block_header_index`,
`_SETTINGS_HISTORY_BLOCK_END_RE` there), zero name collisions, and
`parse_settings_history_changes` keeps master's signature and body byte-identical, so
the parser rewrite is taken whole and the fetch/diagnostic machinery is preserved whole.

The second hunk is this branch's extraction of the inline fetch into
`store_settings_history_changes` against master's comment update in `__main__`. Kept the
extracted form and adopted master's semantic wording; master's `settings_history_file`
local and its `Best-effort` tail are dead under the fail-close design this branch
introduces, so they are dropped rather than merged.

Verified against the merged tree: this branch's 24 tests pass unchanged, as do all 49
tests across the three settings-history modules, including master's own
`test_settings_history_source_gate.py` cells for removals, moves and header edits. Full
`ci/tests` run shows no new failure - the 7 remaining are a subset of the 20 a pristine
`origin/master` `ci/` tree produces on this host, and none of the 3 failing modules
reaches a changed file through its transitive import closure. No `contrib` gitlink drift.
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.

2 participants