Skip to content

Revert "Revert "Revert "Fix SettingsConstraints erasing explicit settings before compatibility applies""" - #99352

Merged
Algunenano merged 1 commit into
masterfrom
revert-99311-revert-98515-revert-97078-fix-settings
Mar 12, 2026
Merged

Algunenano merged 1 commit into
masterfrom
revert-99311-revert-98515-revert-97078-fix-settings

Conversation

@Algunenano

@Algunenano Algunenano commented Mar 12, 2026 •

Copy link
Copy Markdown
Member

Reverts #99311

Closes #99347
Closes #98605


Note

Medium Risk
Changes how SettingsConstraints::check filters SettingsChanges by again dropping unchanged settings even when compatibility is set, which can affect which explicit settings ultimately apply. Removes the regression test that covered this edge case, increasing the chance of behavior changes going unnoticed.

Overview
Reverts the special-case in SettingsConstraints::check(SettingsChanges&) that kept settings in the batch when compatibility was present; the method now always erase_if unchanged/unchecked settings.

Deletes the stateless test (03916_check_settings_constraints_erases_with_compatibility) that asserted explicit settings are preserved when compatibility is provided in the same request.

Written by Cursor Bugbot for commit 170410e. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.3.1.627

@clickhouse-gh

clickhouse-gh Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [170410e]

Summary: ⏳

job_name test_name status info comment
Stateless tests (amd_asan, distributed plan, parallel, 1/2) failure
04004_integral_col_comparison_with_float_key_condition FAIL cidb

AI Review

Summary

This PR reverts the recent fix in SettingsConstraints::check and deletes the regression test that covered compatibility with explicit settings. As written, it reintroduces a correctness issue where explicit user settings can be silently dropped and later overridden by compatibility defaults in the same request. I requested changes.

Missing context

  • ⚠️ No CI logs or targeted regression validation were provided for this revert, so there is no evidence that the reverted behavior is now intentionally acceptable.

Findings

❌ Blockers
  • [src/Access/SettingsConstraints.cpp:217-224] Reintroduces unconditional std::erase_if on SettingsChanges, which removes explicit settings when they initially equal current values; if compatibility is present in the same batch, later compatibility defaults can override explicit user intent.
    • Suggested fix: keep the previous compatibility handling (or equivalent two-phase apply/mark-changed logic) so explicit settings survive until compatibility is processed.
  • [tests/queries/0_stateless/03916_check_settings_constraints_erases_with_compatibility.reference:1-10, tests/queries/0_stateless/03916_check_settings_constraints_erases_with_compatibility.sh:1-27] Deletes the regression test that protects this edge case.
    • Suggested fix: restore this test or add an equivalent stateless test covering both HTTP and TCP setting application with compatibility.

Tests

  • ⚠️ Re-add coverage for compatibility + explicit-setting precedence in one request batch (including ordering permutations), otherwise this regression is unguarded.

ClickHouse Rules

Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ❌ Regression test was deleted.
Experimental gate ➖
No magic constants ✅
Backward compatibility ❌ Reintroduces previously fixed precedence regression for explicit settings with compatibility.
SettingsHistory.cpp ➖
Safe rollout ⚠️ Behavior changes in settings precedence are not safely guarded by tests in this PR.
Compilation time ✅

Final Verdict

  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Preserve explicit settings when compatibility is present in the same batch (restore prior logic or equivalent).
    2. Restore/add regression tests for this scenario.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 12, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

std::erase_if(changes, [&](SettingChange & change) { return !checkImpl(current_settings, change, THROW_ON_VIOLATION, source); });
else
for (auto & change : changes)
checkImpl(current_settings, change, THROW_ON_VIOLATION, source);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Compatibility setting silently overrides explicit user settings

High Severity

This revert removes the guard that prevented compatibility from silently overriding explicit user settings. getNewValueToCheck returns false when a setting's new value matches the current value, causing std::erase_if to remove it from the changes list. When compatibility is also in the batch, it later changes defaults, and the erased explicit setting is lost. The removed code correctly skipped erasure when compatibility was present, preserving user intent.

Fix in Cursor Fix in Web

[&](SettingChange & change) -> bool
{
return !checkImpl(current_settings, change, THROW_ON_VIOLATION, source);
});

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.

Reintroducing unconditional std::erase_if here drops explicit settings whose value initially matches current settings; when compatibility is also present in the same batch, compatibility defaults are applied later and can silently override the explicit user value. Please keep the compatibility special-case (or an equivalent two-phase application) so explicit settings are preserved.

[&](SettingChange & change) -> bool
{
return !checkImpl(current_settings, change, THROW_ON_VIOLATION, source);
});

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.

Reintroducing unconditional std::erase_if here drops explicit settings whose value initially matches current settings; when compatibility is also present in the same batch, compatibility defaults are applied later and can silently override the explicit user value. Please keep the compatibility special-case (or an equivalent two-phase application) so explicit settings are preserved.

@Algunenano
Algunenano enabled auto-merge March 12, 2026 20:36
@@ -1,10 +0,0 @@
-- compatibility alone reverts to 0
0
-- explicit =1 with compatibility=24.12 (compat first in URL)

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.

Removing this regression test drops coverage for the compatibility + explicit-setting precedence behavior that this file documents. Please keep this test (or add an equivalent replacement) so this edge case stays protected.

@rienath rienath 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.

Thanks! I will take a look tomorrow why NOT_FOUND_COLUMN_IN_BLOCK that you describe here happens. My current suspicion is that we did something different in older CH version. But before this change, compatibility settings were silently ignored in stress tests. Now they aren't, we get an error

@rienath rienath self-assigned this Mar 12, 2026
@Algunenano
Algunenano added this pull request to the merge queue Mar 12, 2026
Merged via the queue into master with commit 070a3d0 Mar 12, 2026
46 of 137 checks passed
@Algunenano
Algunenano deleted the revert-99311-revert-98515-revert-97078-fix-settings branch March 12, 2026 21:39
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 12, 2026
rienath added a commit that referenced this pull request Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Test script failed

3 participants