Skip to content

Disable primary-key range sharding in 05629_explain_analyze_join_side_q_error - #132149

Merged
PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:disable-pk-range-sharding-in-05629
Nov 19, 2026
Merged

PedroTadim merged 1 commit into
ClickHouse:masterfrom
groeneai:disable-pk-range-sharding-in-05629

Conversation

@groeneai

@groeneai groeneai commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131313

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Not required.

Description

The test added by #131313 expects the left side of f JOIN d ... WHERE d.v = 3 to report rows 1.00 thousand. Under some layouts from the CI's randomized MergeTree settings it reports rows 999.00, and the first two rows of the reference become 1 0. It fails deterministically with:

tests/clickhouse-test 05629_explain_analyze_join_side_q_error --settings "--max_threads 2" \
    --merge-tree-settings "--index_granularity 998 --min_bytes_for_wide_part 0"

No related open issue found.

The counter is right. With query_plan_join_shard_by_pk_ranges (on by default) both tables are split into primary-key ranges, each with its own hash table, and JoiningTransform does not read the left rows of a range whose hash table is empty (alwaysReturnsEmptySet). With granularity 998 the last range is k = 999, which has no d.v = 3 row, so 999 left rows reach the join. The query result is unchanged.

The test now sets query_plan_join_shard_by_pk_ranges = 0, next to the enable_join_runtime_filters = 0 it already has for the same reason. The EXPLAIN ANALYZE help text in ParserExplainQuery.cpp gets one sentence saying the same thing about sharded joins as it already says about runtime filters.

Validation: on the unedited test, the command above fails, and so do two 32-thread layouts (granularity 7, and 8192 with index_granularity_bytes = 1024) when all 32 threads are used. With the change they pass, as does a sweep of granularity 7, 50 and 990-998 at 2 and 32 threads (22/22 pass, 20/22 failed before), and 50/50 randomized runs.


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

Version info

  • Merged into: 26.11.1.2843-master (included in 26.11 and later)

…_q_error

With `query_plan_join_shard_by_pk_ranges` (on by default) both tables are
split into primary-key ranges, each joined with its own hash table, and
`JoiningTransform` does not read the probe rows of a range whose hash table
is empty (`HashJoin::alwaysReturnsEmptySet`). The side counters are exact, so
the left side then reports fewer rows than the table holds and the test's
`rows 1.00 thousand` assertions fail. Deterministic with
`--max_threads 2` and `--index_granularity 998 --min_bytes_for_wide_part 0`:
the last range is `k = 999`, which has no `d.v = 3` row, so 999 rows are read.

Pin the setting off next to `enable_join_runtime_filters = 0`, which is there
for the same reason. The sharded path is covered by
04891_explain_analyze_join_estimation, which forces it on.

The `EXPLAIN ANALYZE` help text gets one sentence saying that a sharded hash
join, like a runtime filter, lowers the actual rows of a side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding; 2 full passes, the second on the corrected PR description: 0 findings).

# Sev Finding Verdict Evidence / action
1 ⚠️ The draft description cited 04891_explain_analyze_join_estimation as keeping coverage of the sharded path, but its tables are one granule, so its query_plan_join_shard_by_pk_ranges = 1 case runs a single join clone AGREE for the claim, fixed in the description; DISAGREE for rewriting 04891 here The claim is removed. 04891 is not touched by this PR. At the default granularity 05629's tables are one granule too, so its join also ran as one clone; the pin removes no coverage the test was designed to have.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261116-213009

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. --settings "--max_threads 2" --merge-tree-settings "--index_granularity 998 --min_bytes_for_wide_part 0" fails rows 1 and 2 on every run of the unedited test. Granularity 7 and 8192 with index_granularity_bytes = 1024 at 32 threads fail too when all 32 threads are used (max_threads_min_free_memory_per_thread = 0 on a memory-capped server).
b Root cause explained? Yes. query_plan_join_shard_by_pk_ranges gives each primary-key range its own hash table; JoiningTransform does not read the left rows of a range whose hash table is empty, so the left side reports fewer rows than the table holds. The counter is exact.
c Fix matches root cause? Yes. The test pins that setting off, as it already pins enable_join_runtime_filters = 0 for the same reason. No tag, no assertion or data change.
d Test intent preserved / new tests added? Yes. The five assertions and the reference are unchanged.
e Both directions demonstrated? Yes. Unedited: FAIL; edited: OK. A copy of the edited test without the new line fails again with the same binary. Granularity 7, 50, 990-998 x 2/32 threads: 20/22 fail before, 22/22 pass after.
f Fix is general across code paths? N/A for code (test fix). 12 sibling EXPLAIN ANALYZE join tests: no failure of this signature in 30 days of CIDB.
g Fix generalizes across inputs (params/datatypes/wrappers)? Granularity 1 to 8192, index_granularity_bytes, wide and compact parts, 1 to 64 threads: 0 failures with the pin. 50/50 randomized runs pass.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, default or format change. One sentence added to the EXPLAIN ANALYZE help text.
i Invariants and contracts preserved? Yes. No engine code changes.

Session id: cron:clickhouse-impl-slot-7:20261116-210700

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8bd5b08]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

The PR disables query_plan_join_shard_by_pk_ranges in the join-side q-error test to prevent layout-dependent probe-row skipping, and documents that behavior in the source registration for EXPLAIN ANALYZE. The existing assertions remain intact. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 16, 2026

@clickhouse-gh clickhouse-gh Bot left a comment

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.

AI review approves this commit, see the AI Review comment.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 8bd5b08

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build profile diff infra, not from this PR (no ci/ file in the diff): all 8 readiness probes to the CI logs cluster hit Read timed out. (read timeout=3), so has_pr_data raised LogClusterNotReady: the endpoint never became ready. The same job errored on 40 PRs in the last 24 hours #129675 (mine, open)
PR praktika rollup of the row above #129675 (mine, open)

The other CIDB FAIL row on this head is Config Workflow / Pre Hooks of the run before the can be tested label. CH Inc sync is green.

Session id: cron:our-pr-ci-monitor:20261117-010021

@PedroTadim
PedroTadim added this pull request to the merge queue Nov 19, 2026
Merged via the queue into ClickHouse:master with commit eb2ca90 Nov 19, 2026
382 of 385 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 19, 2026
@clickhouse-gh clickhouse-gh Bot added comp-explain EXPLAIN and query profiling output: EXPLAIN PLAN / PIPELINE / AST / SYNTAX / ESTIMATE, pretty EXP... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-explain EXPLAIN and query profiling output: EXPLAIN PLAN / PIPELINE / AST / SYNTAX / ESTIMATE, pretty EXP... pr-ci 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.

3 participants