Skip to content

Run the local join of 04201_max_bytes_ratio_before_external_join_distributed without parallel replicas - #124909

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/04201-local-join-without-parallel-replicas
Oct 9, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/04201-local-join-without-parallel-replicas

Conversation

@groeneai

@groeneai groeneai commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122853

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):

...

Description

04201_max_bytes_ratio_before_external_join_distributed fails in Stateless tests (arm_binary, ParallelReplicas, s3 storage, sequential) with having stderror: the first, non-distributed join receives Code: 241 ... User memory limit exceeded ... maximum: 1.00 GiB from 127.0.0.2 (report; the job's own rerun failed 1/30).

In that job the server profile enables parallel replicas, so this query runs on the three replicas of default_parallel_replicas. Each replica builds the whole right side and, with the test's tiny spill ratio, grows to 256 grace join buckets, about 1 GiB. The two remote replicas run as default and inherit the test user's max_memory_usage_for_user = 1Gi, so they share one 1 GiB limit and one of them fails on every run. The test only goes red when that replica already owned marks.

The query now pins enable_parallel_replicas = 0, as #123784 did for 04647_spilling_hash_join_post_build_phase in the same job. The second, distributed query never uses parallel replicas and is unchanged.

Validation on the CI amd_binary build of that run, with the job's configuration on one server (is_local 1/0/0): before, 101/101 runs had a remote replica fail with Code: 241 (the test itself red 10/10 with parallel_replicas_local_plan = 0); after, 100/100 pass with no secondary queries for this join, the same ~1015 MiB peak as in the other jobs, and the spill assertion still fails when the ratio is set to 0. 50/50 in the regular configuration.

If you prefer to keep the whole test out of this job, I can use the no-parallel-replicas tag instead.


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

Version info

  • Merged into: 26.10.1.1970-master (included in 26.10 and later)

In the ParallelReplicas configuration the server profile enables parallel
replicas, so query 1 of 04201_max_bytes_ratio_before_external_join_distributed
(the "non-distributed" join) runs on the three replicas of
`default_parallel_replicas`. Every replica builds the whole right side and,
with `max_bytes_ratio_before_external_join = 0.0001`, rehashes to 256
GraceHashJoin buckets, about 1 GiB each. The two remote replicas run as
`default` and inherit the forwarded `max_memory_usage_for_user = 1Gi`, so
they share one 1 GiB user limit and one of them throws MEMORY_LIMIT_EXCEEDED
on every run. The test fails only when that replica already owned marks,
which happened in 2 of 31 runs of the failing CI job.

Pin `enable_parallel_replicas = 0` on that query, so it runs on one
executor as in every other configuration and the `query_log` assertion
keeps reading the row of the executor that joined. Query 2 never engages
parallel replicas and is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Oct 9, 2026
@groeneai

groeneai commented Oct 9, 2026

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).

# Sev Finding Verdict Evidence / action
1 ⚠️ The test does not assert that query 1 runs without secondary queries, so dropping the new pin would usually stay green DISAGREE The pin's effect was measured on the job's configuration: 2 remote replicas per run in 101/101 runs before, 0 in 100/100 after. The test checks spilling, and its local check still fails when the ratio is 0 (3/3). A topology check would test enable_parallel_replicas itself, not this test's feature; #123784 used the same pin without one.

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

Session id: cron:clickhouse-review-slot-9:20261009-123900

@groeneai

groeneai commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, of the defect: on the CI amd_binary build with the job's configuration (is_local 1/0/0), 101/101 runs of the old test fan the local join out to 2 remote replicas running as default, and at least one dies Code: 241 ... maximum: 1.00 GiB. The test-level red depends on which replica owned marks (CI 2/31); parallel_replicas_local_plan = 0 reds the old test 10/10.
b Root cause explained? The job's profile enables parallel replicas, so the "non-distributed" join runs on 3 replicas; each builds the whole right side (256 grace join buckets, ~1 GiB), and the 2 remote ones share the default user's tracker under the forwarded 1 GiB max_memory_usage_for_user. When the failing replica owned marks, the error reaches the client.
c Fix matches root cause? Yes: enable_parallel_replicas = 0 on that query removes the fan-out (0 secondary queries in 100/100 runs). No limit, bound or tag changed.
d Test intent preserved / new tests added? Yes: the local spill assertion still reads the joining executor's row and fails 3/3 when the ratio is set to 0; the distributed query and its assertion are untouched (2 spilling executors in 100/100 runs).
e Both directions demonstrated? Yes: old 101/101 remote Code: 241 and 10/10 red under parallel_replicas_local_plan = 0; new 100/100 green in the job's configuration (also 10/10 under parallel_replicas_local_plan = 0), 20/20 + 50/50 in the regular configuration.
f Fix is general across code paths? The second query (cluster() + serialized plan) was measured: it never engages parallel replicas. Same fix as #123784 for 04647_spilling_hash_join_post_build_phase in the same job.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only setting pin; the test uses no randomized settings).
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? The query under test runs on one executor in every configuration, so the query_log row the assertion reads is the one that joined; a query-level SETTINGS value overrides the profile default.

Session id: cron:clickhouse-impl-slot-41:20261009-120200

@clickhouse-gh

clickhouse-gh Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [32ee917]

Summary: ✅


AI Review

Summary

This PR makes the local half of tests/queries/0_stateless/04201_max_bytes_ratio_before_external_join_distributed.sh opt out of parallel replicas with enable_parallel_replicas = 0, which is a good fit for the test’s contract: the first query is supposed to validate local spilling from the local query_log row, while the second query still covers the serialized distributed path. I do not see a correctness, coverage, or PR-metadata problem in the current change.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 9, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 9, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 9, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 9, 2026
Merged via the queue into ClickHouse:master with commit 4a4fdf9 Oct 9, 2026
163 of 164 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 9, 2026
@clickhouse-gh clickhouse-gh Bot added comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... 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-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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