Skip to content

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

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

rienath merged 1 commit into
masterfrom
revert-98515-revert-97078-fix-settings

Conversation

@rienath

@rienath rienath commented Mar 12, 2026 •

Copy link
Copy Markdown
Member

Reverts #98515 to restore #97078. Flaky CI possibly caused by this PR fixed here #98689


Note

Medium Risk
Changes how SettingsConstraints::check(SettingsChanges&) filters/retains settings when compatibility is present, which can affect which query/session settings are considered changed and ultimately applied. The impact is limited but touches core settings processing and could alter behavior for clients relying on previous ordering/override semantics.

Overview
Fixes an ordering bug where SettingsConstraints::check(SettingsChanges&) could erase “unchanged” explicit settings before a later compatibility change adjusts the baseline, allowing compatibility defaults to incorrectly override user-provided values.

Adds a stateless regression test (03916_check_settings_constraints_erases_with_compatibility) covering HTTP URL parameter ordering and TCP client flags to ensure explicit settings remain effective when compatibility=24.12 is used.

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

Version info

  • Merged into: 26.3.1.607

@clickhouse-gh

clickhouse-gh Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [dd02322]

Summary: ✅


AI Review

1) Summary

This PR reverts a prior revert and restores the SettingsConstraints::check(SettingsChanges &) behavior fix so explicit settings are not dropped when compatibility is in the same batch, then adds a focused stateless regression test for HTTP URL and TCP flag paths. I reviewed the code and tests for correctness, safety, and ClickHouse-specific constraints, and I did not find blocker or major issues in the patch.

2) Missing context (if any)

  • CI logs/results were not provided in the review input.
  • No benchmark/perf report was provided (not critical for this small logic change).

3) Findings (by severity)

No Blockers or Majors found; PR looks good.

4) Tests & Evidence

  • Coverage is good for the reported regression scenario: it validates compatibility interactions with explicit use_skip_indexes_if_final in both URL-order permutations and via TCP client flags.
  • Negative/error-handling tests are not present in this patch (e.g., malformed setting values), but the touched logic path mainly affects filtering/retention order, and current coverage is adequate for this fix.
  • Optional follow-up hardening: add one extra case with another explicit setting whose old default differs in 24.12 to prove behavior generalizes beyond one setting.

5) ClickHouse Compliance Checklist (Yes/No + short note)

  • Data deletions logged? Yes — no deletion behavior changed.
  • Serialization formats versioned? Yes — no serialization/protocol changes in this PR.
  • Experimental setting gate present? Yes — no new feature introduced.
  • Settings exposed for constants/thresholds? Yes — no new constants/threshold logic added.
  • Backward compatibility preserved? Yes — this fix restores intended explicit-setting precedence with compatibility.
  • SettingsHistory.cpp updated for new/changed settings? Yes — no setting definition changes required.
  • Existing tests untouched (only additions)? Yes — only a new stateless test pair was added.
  • Docs/user-facing notes updated? Yes — not required for this targeted internal bug fix.
  • Core-area change got extra scrutiny? Yes — settings application path reviewed carefully.

6) Performance & Safety Notes

The change replaces std::erase_if with a full pass when compatibility exists in the batch; this is a tiny per-query overhead proportional to number of provided settings and not a hot-path concern in practice. No memory-lifetime, resource-management, or concurrency risks were identified in the touched code. No benchmarks were provided; if needed, a microbenchmark can compare SET statements with many URL/client settings with/without compatibility.

7) User-Lens Review

Behavior is intuitive: explicit user-provided values now consistently win over compatibility defaults regardless of parameter order, matching user expectations. Error surfaces remain unchanged and actionable through existing setting-validation exceptions.

8) Final Verdict

  • Status: Approve

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

clickhouse-gh Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.80% 83.80% +0.00%
Functions 23.90% 23.90% +0.00%
Branches 76.30% 76.30% +0.00%

PR changed lines: PR changed-lines coverage: 100.00% (7/7)
Diff coverage report
Uncovered code

@Michicosun Michicosun self-assigned this Mar 12, 2026
@rienath
rienath added this pull request to the merge queue Mar 12, 2026
Merged via the queue into master with commit 7df52ad Mar 12, 2026
160 checks passed
@rienath
rienath deleted the revert-98515-revert-97078-fix-settings branch March 12, 2026 13:02
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 12, 2026
@Algunenano

Copy link
Copy Markdown
Member

This is now causing issues in stress tests: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=b3f4a61127a60274cb98c8f576145e85352d0383&name_0=MasterCI&name_1=Stress%20test%20%28azure%2C%20amd_msan%29&name_1=Stress%20test%20%28azure%2C%20amd_msan%29

Stress tests use 00234_disjunctive_equality_chains_optimization.sql as a way to check setting randomization works and this PR breaks it.

● Here's the root cause: before this change, when compatibility='20.12' was set along with other explicit settings (like enable_parallel_replicas=1),
   SettingsConstraints::check would erase settings that matched current values. This meant compatibility would later override them with its own      
  defaults.                                                                                                                                          
                                                                                                                                                     
  After #99311, when compatibility is present, all settings are kept (not erased), so they stay marked as changed and compatibility can't override   
  them. This changes which optimizer settings end up active on the coordinator vs replica — the coordinator keeps the explicit settings, but when the
   query is forwarded to the replica, the settings may be applied in a different order, causing the disjunctive chain optimization to produce        
  different column names.                                                                                                                            
                                                                                                                                                     
  Summary:                                                                                                                                           
  - First bad commit: 7df52ad7f9e — PR #99311                                                                                                        
  - PR: https://github.com/ClickHouse/ClickHouse/pull/99311                                                                                          
  - Root cause: The fix to preserve explicit settings when compatibility is present changes which optimizer settings are active, causing a column    
  name mismatch between parallel replicas coordinator and replica for disjunctive equality chain rewrites.                                           

@Algunenano

Copy link
Copy Markdown
Member

Revert here: #99352

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.

4 participants