Skip to content

Fix settings-history style check on PRs whose base moved - #113286

Closed
Algunenano wants to merge 3 commits into
ClickHouse:masterfrom
Algunenano:fix-settings-history-line-numbers
Closed

Algunenano wants to merge 3 commits into
ClickHouse:masterfrom
Algunenano:fix-settings-history-line-numbers

Conversation

@Algunenano

Copy link
Copy Markdown
Member

The settings_changes_history style check resolved the namespace and version of each changed entry in src/Core/SettingsChangesHistory.cpp by looking up the line number reported by the GitHub patch in the file read from the working tree. Those new-file line numbers refer to the pull request head commit, while CI checks out refs/pull/N/merge, which is the head merged with the current tip of the base branch. As soon as the base advances with its own edits above the hunk, the two numberings drift apart and an entry resolves to the wrong addSettingsChanges block.

In the observed failure two MergeTree settings (packed_skip_index_max_bytes, compute_exact_num_defaults_for_sparse_columns) resolved into the session-settings map, so the check demanded them under the session 26.8 block, where they can never appear. That file is touched by nearly every settings pull request, so the base moves under the check constantly; sync pull requests in the private repository hit it on almost every run.

The fix reads the file at the head commit, so the patch and the file come from the same revision.

Changelog category (leave one):

  • CI Fix or Improvement

`store_data.py` resolved the namespace and version of each changed
`SettingsChangesHistory.cpp` entry by looking up the line number from the
GitHub patch in the file read from the working tree. The patch's new-file
line numbers refer to the pull request head commit, but CI checks out
`refs/pull/N/merge`, which is the head merged with the current base tip.
Once the base advances with its own edits above the hunk, the two
numberings differ and an entry resolves to the wrong `addSettingsChanges`
block: in the observed failure two MergeTree settings landed in the
session-settings map, so the check demanded them in a block they can
never appear in.

Read the file at the head commit so the patch and the file come from the
same revision.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b7716ac]

Summary: ✅


AI Review

Summary

This PR aims to make the settings_changes_history style check read src/Core/SettingsChangesHistory.cpp from the same revision as the GitHub patch instead of from the synthetic merge checkout. The current implementation still does not guarantee that invariant in merge-queue or merge-ref runs, and the PR also deletes an unrelated regression suite for the LSan TestPTrace log filter, so it still needs changes before merge.

Findings

⚠️ Majors

  • [ci/jobs/scripts/workflow_hooks/store_data.py:265] The fix still does not guarantee that patch and file_lines come from the same revision. Info.sha is only the PR head for pull_request events; in merge-queue runs _Environment.from_env sets it to GITHUB_SHA, i.e. the merge-group commit, so git show {info.sha}:... reads the merged tree again rather than the PR head. Even on ordinary PR runs the default checkout is refs/pull/N/merge, and the PR head object is not guaranteed to exist locally there, so this path can still fail closed the first time SettingsChangesHistory.cpp changes. Fetch the file body from GitHub at the PR-head SHA (or another ref guaranteed to resolve to the PR head) instead of relying on the local checkout.
  • [ci/tests/test_lsan_ptrace_probe_filter.py:1] This PR does not touch tests/clickhouse-test, but it deletes the only focused regression coverage for find_benign_lsan_ptrace_probe_lines and the TestCase.process_result_impl sanitizer-log filtering path. Those branches are otherwise exercised only by rare sanitizer incidents, so removing this suite weakens an unrelated subsystem and can let future false-green regressions slip through. Keep the tests, or move them somewhere else in the same PR if there is a real harness problem to solve.
Final Verdict

⚠️ Needs changes before merge.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 4, 2026
# can never be in). Read the file at the head commit so both come from the same
# revision.
file_lines = Shell.get_output(
f"git show {info.sha}:{settings_history_file}", verbose=True

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.

This still does not guarantee that patch and file_lines come from the same revision. Info.sha is only the PR head SHA for pull_request events; in merge-queue runs _Environment.from_env sets it to GITHUB_SHA, i.e. the merge-group commit, so git show {info.sha}:... reads the merged tree again and reintroduces the original line-number drift whenever the base has moved. On top of that, the default PR workflow still checks out refs/pull/N/merge with CHECKOUT_REF=; in this checkout the PR head object is not present locally (git cat-file -e d4f8546^{commit} fails here), so this path just returns an empty string and fails closed the first time SettingsChangesHistory.cpp changes. I think this needs to fetch the file body from GitHub at the PR head SHA (or another ref guaranteed to be the PR head) instead of relying on the local checkout.

@Algunenano

Copy link
Copy Markdown
Member Author

#113227 is better

@Algunenano Algunenano closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant