Skip to content

Keep the post-build phase check of 04647_spilling_hash_join_post_build_phase off parallel replicas - #123784

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-04647-post-build-phase-off-parallel-replicas
Oct 4, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:fix-04647-post-build-phase-off-parallel-replicas

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 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

04647_spilling_hash_join_post_build_phase fails in the new Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) job from #122853: the second line prints 0 0 instead of 1 0, i.e. JoinBuildPostProcessingMicroseconds is 0 on the initiator's query_log row (#117005 report, #123740 report).

The randomized join-order statistics can put t_post_build_left, the read that parallel replicas split, on the build side. Its marks are one coordinator segment owned by a remote replica, so when the local replica asks after that replica has announced, it gets 0 marks and builds an empty hash table. The build and its post-build phase then run only in the remote replicas' secondary queries, whose ProfileEvents are not added to the initiator's query_log row. In both failing jobs the initiator's row has JoinBuildTableRowCount = 0 while a secondary query built the rows.

The measured join now pins enable_parallel_replicas = 0, as other join tests that assert join ProfileEvents do. What the test covers, SpillingHashJoin running the post-build phase of the wrapped join, does not depend on how the read is split between replicas.

Validation (CI amd_binary build of the base commit, three-replica local cluster): with the slowdown_parallel_replicas_local_plan_read failpoint the old test fails 9/20, in exactly the runs where the local replica got 0 marks, and the new one passes 20/20. With parallel_replicas_local_plan = 0 the old test fails 20/20 and the new one passes 20/20. The new test also passes 50/50 under randomized settings in the regular configuration and 50/50 in the job's configuration.

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

🤖 Generated with Claude Code


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

Version info

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

The test asserts JoinBuildPostProcessingMicroseconds > 0 on the initiator's
query_log row. Under parallel replicas the join-order randomization can put
t_post_build_left, the coordinated read, on the build side. Its marks form
one coordinator segment owned by a remote replica, so when the local
replica's first read request arrives after that replica announces, the local
replica gets 0 marks and builds an empty hash table. The whole build and its
post-build phase then run in the remote replicas' secondary queries, whose
ProfileEvents are forwarded to the client only and are not added to the
initiator's query_log row, so the check reads 0.

Seen in "Stateless tests (arm_binary, ParallelReplicas, s3 storage,
parallel)" on PRs ClickHouse#117005 and ClickHouse#123740 with the output "0 0" instead of "1 0".

Pin enable_parallel_replicas = 0 on the measured join only, as other join
tests asserting join ProfileEvents already do. The test's subject,
SpillingHashJoin running the post-build phase of the wrapped join, does not
depend on how the read is split between replicas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 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; 0 findings) plus a separate cold review of the diff (0 blocker/major findings).

# Sev Finding Verdict Evidence / action
- - No findings - none

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

Session id: cron:clickhouse-review-slot-8:20261003-231100

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With parallel_replicas_local_plan = 0 the old test fails 20/20 (0 0). With the CI seed and the slowdown_parallel_replicas_local_plan_read failpoint it fails 9/20, exactly in the runs where the local replica got 0 marks.
b Root cause explained? The randomized join order puts the coordinated read on the build side; when a remote replica takes its only segment, the initiator builds an empty table and the post-build phase runs only in secondary queries, whose ProfileEvents are not added to the initiator's query_log row.
c Fix matches root cause? Yes. The measured join pins enable_parallel_replicas = 0, so it runs on the server whose row is read. No bound widened, no blanket tag.
d Test intent preserved / new tests added? Yes. It still asserts the post-build phase ran and nothing spilled; the server log shows SpillingHashJoin promoting HashJoin and the fixed hash map conversion. Test-only change.
e Both directions demonstrated? Yes. 20/20 FAIL to 20/20 PASS (local plan off), 9/20 FAIL to 20/20 PASS (failpoint), 5/25 FAIL to 50/50 PASS in the job's configuration.
f Fix is general across code paths? N/A (test-only, no engine defect). Other join tests asserting join ProfileEvents already pin the setting or carry the tag.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). Covers both parallel_replicas_local_plan values, the server-side profile and the automatic mode.
h Backward compatible? (maintainer-approved exception only) N/A. No setting, default or format change.
i Invariants and contracts preserved? N/A for engine invariants. The asserted counters are produced on the server whose query_log row is read.

Session id: cron:clickhouse-impl-slot-6:20261003-224900

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [91a0596]

Summary: ✅


AI Review

Summary

This PR makes 04647_spilling_hash_join_post_build_phase.sql opt the measured join out of parallel replicas so the system.query_log row it inspects always belongs to the server that actually runs the build-side post-build phase. For a CI Fix or Improvement, that matches the stated contract and I do not see an unresolved correctness or coverage regression in the current diff.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 3, 2026
@groeneai
groeneai requested a review from nickitat October 3, 2026 23:41
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 4, 2026
@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 0d1bc7f

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 (amd_fuzzers) / Build ClickHouse not from this PR, which changes only 04647_spilling_hash_join_post_build_phase.sql: the clickhouse_fuzzer link fails with relocation R_X86_64_PC32 out of range in __sanitizer::StackDepot*; the same job failed on 172 PRs and 40 master runs in the last 24h, and master is green again from 80f00c857b36 #123738 (external, merged 01:14Z). This run was dispatched at 23:39Z, before it merged, so I merged master @ 91a05968f212a163901f3a387c99eab260b3d072
Mergeable Check, PR rollups, red only because of the row above #123738 (external, merged)

All 160 checks completed, Finish Workflow is green and CH Inc sync passed. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261004-023151

@alexey-milovidov alexey-milovidov self-assigned this Oct 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 4, 2026
Merged via the queue into ClickHouse:master with commit ebd9fe2 Oct 4, 2026
149 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 4, 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-master PR origin: master/nightly CI monitoring finding 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