Skip to content

Merge join-order conflict-detector settings into one enum setting - #120630

Merged
fkastrati merged 5 commits into
masterfrom
merge-join-order-conflict-detector-settings
Sep 19, 2026
Merged

fkastrati merged 5 commits into
masterfrom
merge-join-order-conflict-detector-settings

Conversation

@fkastrati

@fkastrati fkastrati commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #118413
Related: #118494
Related: #120110

query_plan_optimize_join_order_use_conflict_detector_a and query_plan_optimize_join_order_use_conflict_detector_c are replaced by a single query_plan_optimize_join_order_conflict_detector, taking a, c, or the empty string (the default, meaning no conflict detector).

This is the naming asked for in #118413:

Name it query_plan_optimize_join_order_conflict_detector with values a and c and maybe an empty string, if needed.

That issue was closed by #118494, which renamed the settings to ..._use_conflict_detector_a and _c rather than collapsing them into one setting with the requested values.

Two booleans could express a state the feature does not have - both detectors at once - which the documentation had to resolve with a precedence rule (CD-C takes precedence over CD-A when both are enabled). A single value cannot be ambiguous, so the rule is gone.

QueryGraph::use_conflict_detector_a and _c likewise become a single QueryGraph::conflict_detector of the new JoinOrderConflictDetector enum.

The old names reached 26.9 through #118494, after the branch was cut, so this is marked v26.9-must-backport: with the backport in place no released version ever carries them. The new setting therefore ships in 26.9 as well and is recorded under the 26.9 block, next to the 26.10 one that check_settings_changes_history requires for the current version block "in addition to any older block used for backports". Recording one setting identically in two adjacent blocks follows distributed_cache_client_id in 26.9 and 26.8.

The backport's cherry-pick conflicts on src/Core/SettingsChangesHistory.cpp, because 26.9 has no 26.10 block; the resolution keeps only the 26.9 record.

The documentation hits under docs/reference/settings/ are all inside AUTOGENERATED_START/AUTOGENERATED_END regions and are left to the documentation autogeneration workflow.

#120110 touches the same settings and will need to adopt the new name, with its default flip becoming query_plan_optimize_join_order_conflict_detector = 'c'.

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Replaced the experimental settings query_plan_optimize_join_order_use_conflict_detector_a and query_plan_optimize_join_order_use_conflict_detector_c with a single setting query_plan_optimize_join_order_conflict_detector, which takes a, c, or the empty string (the default).


Workflow [PR]
Sync PR [sync-upstream/pr/120630]

Version info

  • Backported to: 26.9.1.1623

`query_plan_optimize_join_order_use_conflict_detector_a` and
`query_plan_optimize_join_order_use_conflict_detector_c` are replaced by a single
`query_plan_optimize_join_order_conflict_detector`, taking `a`, `c`, or the empty
string (the default, meaning no conflict detector).

This is the naming asked for in
#118413. That issue was closed by
#118494, which renamed the settings to
`..._use_conflict_detector_a` and `_c` rather than collapsing them into one setting
with the requested values.

Two booleans could express a state the feature does not have - both detectors at
once - which the documentation had to resolve with a precedence rule ("CD-C takes
precedence over CD-A when both are enabled"). A single value cannot be ambiguous, so
the rule is gone.

`QueryGraph::use_conflict_detector_a` and `_c` likewise become a single
`QueryGraph::conflict_detector` of the new `JoinOrderConflictDetector` enum.

The settings never appeared in a release: `v26.9.1.1-new` does not contain them, so
the two `26.9` entries in `SettingsChangesHistory` are replaced by one `26.10` entry
rather than being kept as obsolete aliases.

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

clickhouse-gh Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [222fece]

Summary: ✅


AI Review

Summary

This PR replaces the two experimental join-order conflict-detector booleans with one enum setting and threads that enum through the dpsub optimizer. The rename is internally consistent inside the optimizer, but it still removes the only spellings currently accepted on the live 26.9 release line, so it has an unresolved backward-compatibility break.

Findings

❌ Blockers

  • [src/Core/Settings.cpp:9431] master stops accepting query_plan_optimize_join_order_use_conflict_detector_a and query_plan_optimize_join_order_use_conflict_detector_c, but those names are already present on the open 26.9 release line: PR #118494 merged on 2026-09-08, the current 26.9 branch is ahead of that merge, and release PR #120439 for branch 26.9 has been open since 2026-09-16. Upgrading a profile or query from that branch to a build with this patch will therefore fail with UNKNOWN_SETTING; changing SettingsChangesHistory does not provide a migration path because name resolution fails before compatibility can help.
    Suggested fix: keep the legacy booleans accepted on master and translate them to query_plan_optimize_join_order_conflict_detector while the new enum stays at its default, or land the matching 26.9 backport before anything is released from that branch.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: preserve a working migration path for the legacy query_plan_optimize_join_order_use_conflict_detector_a / query_plan_optimize_join_order_use_conflict_detector_c spellings, or otherwise prove they cannot reach a shipped 26.9 build before this merges.

LLVM Coverage Report

Measured on commit 222fece.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 80.60% 80.60% +0.00%

Changed lines: Changed C/C++ lines covered: 50/53 (94.34%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Sep 17, 2026
@fkastrati
fkastrati requested a review from groeneai September 17, 2026 15:59
@clickhouse-gh clickhouse-gh Bot added the comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... label Sep 17, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 222fecef7 with master b810ea7fc (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of f6cd2e63b; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

118 object files changed (+41.97 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Core/SettingsEnums.cpp.o 2.12 MiB 2.14 MiB +22.75 KiB (+1.05%)
src/CMakeFiles/dbms.dir/Core/Settings.cpp.o 3.53 MiB 3.55 MiB +17.53 KiB (+0.48%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

2003 translation units recompiled, 12023 s compile time in total, 2003 of them have a recent master baseline.

Job report

@groeneai groeneai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed. The mechanical side of the collapse checks out: no use_conflict_detector spelling is left in src/ or tests/ (only the AUTOGENERATED_* docs regions, as the description says), the empty string as an enum value has precedent in SettingsEnums.cpp (JoinStrictness, SetOperationMode), the new toString has the same shape as its siblings in Joins.cpp, and the five tests map 1:1 per arm (_a = 1 -> 'a', _c = 1 -> 'c') with the per-file counts unchanged: 05098 5a/5c, 05099 2a/3c, 05138 1a/4c, 05182 6a/2c, 05183 6a/2c. So no query changed which detector it exercises, no .reference needed touching, and no query had both booleans set, which means the collapse had nothing ambiguous to resolve.

One thing I would settle before the old names disappear. The "never appeared in a release" premise is measured against v26.9.1.1-new, but that tag (94a1553, 2026-08-24) predates the 26.9 branch cut. The 26.9 release branch was created on 2026-09-16 from master 6e59880 (git merge-base origin/26.9 origin/master; head d1213811, VERSION_STRING 26.9.1.1), and that base already carries the settings: git show origin/26.9:src/Core/Settings.cpp has both DECLARE(Bool, query_plan_optimize_join_order_use_conflict_detector_{a,c}, ...) lines, and git show origin/26.9:src/Core/SettingsChangesHistory.cpp still lists both records under its 26.9 block. Nothing has shipped yet, v26.9.1.1-new being the only v26.9* tag, so the premise holds at this moment, but the first release cut from that branch will carry the old names, and after that a user who sets query_plan_optimize_join_order_use_conflict_detector_c = 1 in a query or a profile gets UNKNOWN_SETTING on the upgrade to 26.10, with nothing left in the history saying where the name went.

Either resolution works for me:

  • Backport the rename to 26.9 too, so no released version ever sees the old names. The new setting then ships in 26.9 as well, so the 26.9 block should carry a record for it next to the 26.10 one: check_settings_changes_history in ci/jobs/check_style.py asks for the current version block "in addition to any older block used for backports".
  • Or leave 26.9 as it is and keep the old names as MAKE_OBSOLETE(M, Bool, ...), with the two 26.9 records staying put, since that release will have shipped them.

When I renamed allow_experimental_trino_dialect in #120007, the plain no-alias rename rested on the same measurement taken against the release branches rather than the -new tag (0 occurrences in src/Core/Settings.cpp on 26.8, 26.7 and 26.6, record in the then-unreleased 26.9 block), which is also why the record was renamed in place instead of moved to another version.

@alexey-milovidov alexey-milovidov self-assigned this Sep 18, 2026
Comment thread src/Core/Settings.cpp
DECLARE(Bool, query_plan_optimize_join_order_use_conflict_detector_c, false, R"(
Only affects the `dpsub` join order algorithm. When enabled, DPsub decides which join reorderings
are valid using the CD-C conflict detector. Takes precedence over `query_plan_optimize_join_order_use_conflict_detector_a` when both are enabled.
DECLARE(JoinOrderConflictDetector, query_plan_optimize_join_order_conflict_detector, JoinOrderConflictDetector::NONE, R"(

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.

The old names already exist on the remote 26.9 release branch, so removing both declarations here leaves no accepted spelling for users who upgrade from the first 26.9 release to 26.10: a query or profile that still sets query_plan_optimize_join_order_use_conflict_detector_a or query_plan_optimize_join_order_use_conflict_detector_c will fail with UNKNOWN_SETTING.

This needs a migration path in master, not just a renamed SettingsChangesHistory entry. The closest precedent is output_format_arrow_unsupported_types, which kept the old boolean live and translated it only while the new enum stayed at its default. Here that likely means either keeping the old names accepted and mapping them to query_plan_optimize_join_order_conflict_detector, or backporting this rename to 26.9 before its first release. MAKE_OBSOLETE would not be enough because it would silently drop the detector choice.

@fkastrati
fkastrati enabled auto-merge September 19, 2026 02:30
@fkastrati
fkastrati added this pull request to the merge queue Sep 19, 2026
Merged via the queue into master with commit 5b5e017 Sep 19, 2026
177 checks passed
@fkastrati
fkastrati deleted the merge-join-order-conflict-detector-settings branch September 19, 2026 10:45
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 19, 2026
robot-clickhouse added a commit that referenced this pull request Sep 19, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Sep 19, 2026
Cherry pick #120630 to 26.9: Merge join-order conflict-detector settings into one enum setting
robot-clickhouse added a commit that referenced this pull request Sep 19, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 19, 2026
alexey-milovidov added a commit that referenced this pull request Sep 20, 2026
…herry-pick

The cherry-pick of #120630 onto the `26.9` release branch copied the whole
`addSettingsChanges(settings_changes_history, "26.10", ...)` block from
`master`. That block does not belong on a release branch, and three of its
entries name settings that do not exist in `26.9` at all:
`iceberg_tolerate_conflicting_manifest_schemas`, `prefer_optimize_projection`
and `output_format_arrow_unsupported_types`.

As a result every use of the `compatibility` setting failed with
`Code: 115. DB::Exception: Unknown setting
'iceberg_tolerate_conflicting_manifest_schemas'. (UNKNOWN_SETTING)`, which is
what all 96 CI failures come down to: stateless tests that set
`compatibility`, the `SettingsCompatibility` and `NetworkCompressionSettings`
unit tests, the stress test (it exercises the settings named in the job's
`settings_history_changed_settings`), and every integration test whose server
config pins `compatibility` — those servers exited with code 115 at startup.

The remaining entries of that block (`max_bytes_before_external_distinct`,
`max_bytes_ratio_before_external_distinct`,
`query_plan_optimize_join_order_conflict_detector`,
`use_text_index_postings_cache`) were duplicates of rows already present in
the `26.9` block, so nothing is lost by dropping it. The backport now differs
from `26.9` only by replacing
`query_plan_optimize_join_order_use_conflict_detector_a`/`_c` with
`query_plan_optimize_join_order_conflict_detector`, which is exactly what
#120630 did on `master`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
clickhouse-gh Bot added a commit that referenced this pull request Sep 20, 2026
Backport #120630 to 26.9: Merge join-order conflict-detector settings into one enum setting
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 26, 2026
ClickHouse#120630 replaced the boolean `query_plan_optimize_join_order_use_conflict_detector_c`
with the enum `query_plan_optimize_join_order_conflict_detector`, so after the master
merge the degenerate-predicate arm failed with UNKNOWN_SETTING. The value 'c' selects
the same CD-C path the old `= 1` did (`joinEnum.h` seeding block, `joinOrderDPSub.cpp`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-experimental Experimental Feature pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.9-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants