Repository navigation
Retrospectively disable max_bytes_ratio_before_external_join - #111248
antaljanosbenjamin wants to merge 38 commits into
Conversation
runPostBuildPhase is never run. CC @alexey-milovidov ### Changelog category (leave one): - Bug Fix (user-visible misbehavior in an official stable release) ### Changelog entry (a [user-readable short description](https://github.com/ClickHouse/ClickHouse/blob/master/docs/changelog_entry_guidelines.md) of the changes that goes into CHANGELOG.md): Retrospectively disable max_bytes_ratio_before_external_join, because it breaks read-in-order through joins.max_bytes_ratio_before_external_join, because it breaks read-in-order through joins.
max_bytes_ratio_before_external_join, because it breaks read-in-order through joins.max_bytes_ratio_before_external_join
|
Workflow [PR], commit [0dfc751] Summary: ❌
AI ReviewSummaryThis PR reverts the default Missing context / blind spots
Findings
Final Verdict
LLVM Coverage ReportMeasured on commit 0dfc751.
Changed lines: Changed C/C++ lines covered: 44/47 (93.62%) · Uncovered code |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 19/19 (100.00%) · Uncovered code |
…atio_before_external_join
|
📊 Cloud Performance Report ✅ AI verdict: This PR is join-focused: it defaults max_bytes_ratio_before_external_join to 0 (disabling automatic hash-join spilling because it interferes with read-in-order-through-join) and adds shard-by-pk-ranges stats aggregation and a LEFT-join limit-propagation fix. The one flagged query, ClickBench Q18, is a single-table aggregation with no join, so its +5.8% (median 1052.5 to 1114.0 ms) cannot come from this change; the delta lands inside master's current variance band [531,1241] ms and CPU time is essentially flat (+1.8%), so the deterministic envelope suppression to not_sure is correct. No join-exercising benchmark query showed a real regression. clickbenchFlagged queries (1 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
…atio_before_external_join
Build profile diff (arm_release)Commit See the job log for details. |
`max_rows_to_read` with `read_overflow_mode = 'throw'` is checked against the row estimate the reading step announces, and `buildSortingDAG` dropped the LIMIT at every join, so read-in-order through a `LEFT JOIN` announced whole parts and failed the check despite reading only a few rows. A `LEFT ALL`/`LEFT ANY` join emits at least one row per left row, so the limit may be kept (`joinKeepsLeftSideLimit`). Restores the part of #111973 that the #116286 revert removed; resurfaced by this PR's `max_bytes_ratio_before_external_join = 0`, which unwraps `SpillingHashJoin` and makes the through-join pass the default path (caught by `04516_join_order_estimation_pruned_parts` in Fast test).
…atio_before_external_join
The assertion didn't work on blob storage because the read is structured differently.
…d by PK ranges A join sharded by primary-key ranges runs on per-shard clones and the original join object stays empty, so `EXPLAIN ANALYZE` reported `unique keys 0.00 · memory 0.00 B` for it. Keep the clones in `JoinStep` and sum the quantities over them (the shards partition both inputs into disjoint key ranges). Unreachable on master because `SpillingHashJoin` is never sharded; revived by disabling `max_bytes_ratio_before_external_join`. Caught by `04904_explain_analyze_join_parallel_hash_unique_keys`.
…atio_before_external_join # Conflicts: # src/Core/SettingsChangesHistory.cpp # src/Processors/QueryPlan/JoinStep.cpp # src/Processors/QueryPlan/JoinStep.h # tests/queries/0_stateless/03786_storage_join_type_conversion.sql # tests/queries/0_stateless/04357_join_order_dp_uniqcombined.reference
…` guard The old query analysis cannot be enabled anymore: since v26.9 `SET enable_analyzer = 0` fails with `SETTING_CONSTRAINT_VIOLATION`, so the legacy `JoinStep` branch that `05153_convert_outer_join_to_inner_join_nondeterministic_old_analyzer` exercised is unreachable and the test fails on its first statement. The guard itself stays as a mirror of the `JoinStepLogical` path. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This comment was marked as low quality.
This comment was marked as low quality.
…atio_before_external_join # Conflicts: # src/Core/Settings.cpp
… history block The `settings_changes_history` style check requires the change to be recorded under the current version block, which is `26.10` after the version bump on `master`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111248&sha=10fde406f0f35e91ac195ecd43eb81f6e611ba8e&name_0=PR&name_1=Style%20check PR: #111248 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This comment was marked as low quality.
This comment was marked as low quality.
…atio_before_external_join Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # tests/queries/0_stateless/03130_convert_outer_join_to_inner_join.sql # tests/queries/0_stateless/03701_analyzer_correlated_subquery_plan_reference.sql # tests/queries/0_stateless/03773_semi_join_equivalent_sets.sql
|
🕵 Merged The I left the |
# Conflicts: # tests/queries/0_stateless/04105_limit_by_into_sort_explain.reference
…sh` is used After merging master, standalone `grace_hash` requires a non-zero spill threshold (`fc7383610ff`, "Unify the spill trigger for hash joins"). It used to get one from the `0.5` default of `max_bytes_ratio_before_external_join`, which this PR disables, so every test that runs `join_algorithm = 'grace_hash'` without setting a threshold failed with `BAD_ARGUMENTS`. Set `max_bytes_ratio_before_external_join = 0.5` (the value these tests ran with on master) in the affected stateless tests, the performance tests that run `grace_hash`, and the stress test when it selects `grace_hash`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111248&sha=f4b611bdf1a8195240ea0ddf9a2005334c48f93a&name_0=PR&name_1=Fast%20test #111248 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master and resolved the conflict in All 36 Fast test failures came from one semantic conflict with master. Since fc73836 ("Unify the spill trigger for hash joins"), standalone Needs a decision from you: with this PR, |
# Conflicts: # src/Core/Settings.cpp
…ore_external_join` - `gtest_join_spill_trigger_plan_setting`: the cases are written against a non-zero ratio out of the box, so `makeJoinSettings` now sets `max_bytes_ratio_before_external_join = 0.5` as its baseline. - `01721_join_implicit_cast_long`: the `auto` branch resets the ratio to `0` again; the preceding `hash` iteration sets it to `0.5`, so the join kept spilling and hit `max_bytes_in_join` instead of switching to the merge join. - `02273_full_sort_join`: `max_bytes_before_external_join` is reset to `0` inside the `grace_hash` iteration, which left `grace_hash` without a spill threshold; pin the ratio to `0.5`. - `03514_grace_hash_join_logical_error`: tag as `long`; it takes 70-240 s under TSan on master too and fails only the run-time limit of the flaky check. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111248&sha=dc22f672b1a7f41d556e33f4ce1ac424faa34c1b&name_0=PR PR: #111248 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `max_bytes_ratio_before_external_join` back at `0` by default, a standalone `join_algorithm = 'grace_hash'` has no spill threshold and fails with `BAD_ARGUMENTS` (or is skipped in favour of the next algorithm of the list). `BuzzHouse` generated `join_algorithm` independently of the thresholds, so most of its `grace_hash` queries stopped exercising the join. Usually add a non-zero `max_bytes_before_external_join` alongside such a `join_algorithm`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master and pushed 479fa15 (review follow-up for The only red check on the previous head was This slowdown comes from the revert itself. I reproduced it locally with
With a non-zero threshold, the hash join is wrapped in the spill-capable join. That wrapper emits the non-joined rows of a I didn't pin the threshold in that perf test, because it would hide a real cost of the revert. Whether to accept this trade-off for read-in-order through joins needs a human decision. |
…he stress test `max_bytes_ratio_before_external_join` resolves to zero when the server has no memory limit, so set `max_bytes_before_external_join` as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111248&sha=479fa153fc574bc28dfedff3f2a546138815679e&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20targeted%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. I also merged |
| Has effect for every hash-based `join_algorithm`, including `grace_hash`, provided a temporary data path is configured. | ||
| )", 0, \ | ||
| {"26.5", 0., 0.5, "New setting: ratio of available memory used as the spill threshold for hash joins. Enabled by default at `0.5`, mirroring `max_bytes_ratio_before_external_group_by` and `max_bytes_ratio_before_external_sort`. Combined with the absolute `max_bytes_before_external_join` (the smaller of the two applies)."}) \ | ||
| {"26.10", 0., 0., "Retrospectively disable automatic spilling, because it interferes with read-in-order-through-join optimization."}, \ |
There was a problem hiding this comment.
Changing the structured setting metadata here leaves the checked-in generated docs inconsistent with the runtime default: docs/reference/settings/session-settings/max-bytes.mdx:57 still says max_bytes_ratio_before_external_join defaults to 0.5, the SettingsInfoBlock / VersionHistory at docs/reference/settings/session-settings/max-bytes.mdx:172 and docs/reference/settings/session-settings/max-bytes.mdx:174 still expose 0.5, and the session-settings explorer snippets still list 0.5 as well. Because this PR changes the user-visible contract of the setting, it needs the matching autogenerated-docs update; otherwise the docs/UI ship a different default than the server.
|
Acknowledged. I see no fix in progress for this yet. I'm investigating the |
|
The fix is in #124368 (test-only). The test created its tables with |
The test created its tables with an explicit index_granularity of 10 and inserted 3M rows with min_insert_block_size_rows = 0, so every random max_block_size block (down to 8000 rows) became its own compact part with one compressed block per column per 10-row granule: ~600k compressed blocks written, decoded and re-encoded again by the background merges, and ~600k marks loaded by the SELECTs. Under TSan, with the random ZSTD server codec (a fresh context per block), a run took up to 296 s in the s3 parallel lane and failed the 180 s limit of the targeted check on PR ClickHouse#111248. Use the default granularity 8192 and clamp max_block_size to at least 65409. The asserted sum(_sample_factor) does not depend on granularity or part layout (exact row count for the relative sample size, exact intHash64 filter): measured identical (2997580 over 199910 rows) for granularity 10 and 8192 and block sizes 8188, 65409 and 100000. TSan, 18 concurrent runs on 32 CPUs: p50 51 s -> 8.3 s (ZSTD(1)), 32 s -> 7.1 s (LZ4), 51 s -> 9.6 s (S3 on MinIO). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Closed because Spilling Join now supports read in order: #124873 @antaljanosbenjamin @alexey-milovidov Could we disable |
Revert #104285
Apart from breaking read-in-order through joins it might also have other issues, e.g.
runPostBuildPhaseis never run. CC @alexey-milovidovChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Retrospectively disable
max_bytes_ratio_before_external_join, because it breaks read-in-order through joins.Workflow [PR]
Sync PR [sync-upstream/pr/111248]