Skip to content

Add ProfileEvents to observe distributed query plan execution - #107985

Merged
shankar-iyer merged 6 commits into
ClickHouse:masterfrom
shankar-iyer:distributed_query_profile_events
Jun 29, 2026
Merged

shankar-iyer merged 6 commits into
ClickHouse:masterfrom
shankar-iyer:distributed_query_profile_events

Conversation

@shankar-iyer

@shankar-iyer shankar-iyer commented Jun 19, 2026 •

Copy link
Copy Markdown
Member

Add DistributedPlanRemoteTasks, DistributedPlanLocalExecution and DistributedPlanHostsUsed profile events to monitor distributed query execution

Changelog category :

  • Improvement

Changelog entry :

Added ProfileEvents DistributedPlanRemoteTasks, DistributedPlanLocalExecution, and DistributedPlanHostsUsed to observe make_distributed_plan execution.

Version info

  • Merged into: 26.7.1.236 (included in 26.7 and later)

Add DistributedPlanRemoteTasks, DistributedPlanLocalExecution and
DistributedPlanHostsUsed so it is visible whether a make_distributed_plan query
actually ran distributedly, and verify them in the integration test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [00493f2]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, db disk, old analyzer, 2/6) FAIL
test_quorum_inserts_parallel/test.py::test_parallel_quorum_actually_quorum FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR adds ProfileEvents for make_distributed_plan execution: remote task dispatches, local executor usage, and distinct assigned worker hosts. The current implementation now derives DistributedPlanHostsUsed from assigned task hosts rather than configured workers, but the regression coverage still would not fail for the previously reviewed bug.

Missing context / blind spots
  • ⚠️ The direct S3 PR report for commit 00493f2813cc557d298dce31b1fa20e872673ab4 reported 0 test results, so I could not use CI evidence to confirm the new integration test ran.
Tests
  • ⚠️ [tests/integration/test_distributed_plan_replicated_merge_tree/test.py:473] The DistributedPlanHostsUsed assertion still passes for the old getWorkerAddresses().size() implementation because the test uses three configured workers and three reader buckets. Please add a focused case where configured workers outnumber assigned hosts, for example with distributed_plan_default_reader_bucket_count = 1 and an exact hosts_used assertion, or a duplicate worker-host setup. That would prove the event counts assigned distinct hosts rather than configured workers.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: add the focused DistributedPlanHostsUsed regression test above.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 19, 2026

@novikd novikd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@novikd novikd self-assigned this Jun 19, 2026
Comment thread src/Common/ProfileEvents.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements and removed pr-not-for-changelog This PR should not be mentioned in the changelog labels Jun 23, 2026
@davenger

Copy link
Copy Markdown
Member

LGTM too

assert events["remote_tasks"] > 0, (
f"expected the query to run distributed, got events={events}"
)
assert events["hosts_used"] >= 2, (

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.

DistributedPlanHostsUsed is supposed to count assigned distinct hosts, but this assertion still passes for the old getWorkerAddresses().size() implementation because this test uses three configured workers and three reader buckets, so both paths report all three hosts. Please add a focused case where configured workers outnumber assigned hosts (for example this simple scan with distributed_plan_default_reader_bucket_count = 1, then assert the exact hosts_used, or a duplicate worker-host setup) so the test would fail if the metric counts configured workers instead of assigned distinct hosts.

@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.30% -0.10%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.50% -0.10%

Changed lines: Changed C/C++ lines covered by tests: 25/26 (96.15%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@shankar-iyer

Copy link
Copy Markdown
Member Author

Waiting for private-PR CI results

@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR only adds three ProfileEvents counters (DistributedPlanRemoteTasks/LocalExecution/HostsUsed) inside the make_distributed_plan executor, plus an integration test. ClickBench queries run as ordinary single-server queries and never enter that code path, so the diff cannot plausibly speed up Q4 (-17.56%), Q15 (-11.49%), or Q28 (-6.11%). All three flagged improvements are off-path and consistent with run-to-run variance, so they have been downgraded to not-sure rather than credited to the PR. No real performance impact is expected from this change.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 4 not_sure 262 216 -17.6% <0.0001 PR only adds ProfileEvents counters in the make_distributed_plan executor; ClickBench Q4 never runs that path. Run-to-ru
⚠️ 15 not_sure 235 208 -11.5% <0.0001 Diff is pure instrumentation in the distributed-plan path, untouched by a single-server Q15 scan. Off-path, treat as noi
⚠️ 28 not_sure 6982 6555 -6.1% <0.0001 Only counter increments in DistributedPlanExecutor changed; Q28 doesn't exercise it. -6% is run-to-run variance, not a P

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
  • StressHouse run: a78a0610-0975-4213-9df1-e0c3034b7398
  • MIRAI run: 419f9ca7-08e2-4b9d-8eb2-54e7a3367870
  • PR check IDs:
    • clickbench_61856_1782409405
    • clickbench_61862_1782409405
    • clickbench_61897_1782409405
    • tpch_adapted_1_official_61917_1782409406
    • tpch_adapted_1_official_61955_1782409406
    • tpch_adapted_1_official_61987_1782409406

@shankar-iyer
shankar-iyer added this pull request to the merge queue Jun 29, 2026
Merged via the queue into ClickHouse:master with commit 1b22d38 Jun 29, 2026
165 of 167 checks passed
@shankar-iyer
shankar-iyer deleted the distributed_query_profile_events branch June 29, 2026 10:19
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 29, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jun 29, 2026
Mark the suite dist_each_sequential=True. The flaky/targeted integration checks
run the parallel bucket with --dist=each, so every xdist worker brings up its own
full 18-node Keeper+S3 cluster of test.py concurrently (3 copies on the 61 GiB
AMD_MEDIUM ASan runner), which the kernel OOM-killed (job exit 137). The new flag
routes both test.py and test_concurrent.py to the looped sequential -n 1 bucket
under --dist=each (one cluster at a time, repeated >=3x, so the flakiness signal
is preserved) while leaving them parallel under --dist=loadfile in the ~140 normal
integration jobs (one file -> one worker -> one cluster, which never OOMs).

The dist_each_sequential field and force_heavy_modules_sequential routing landed
in master via ClickHouse#107985; this only adds the keeper suite to TEST_CONFIGS.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Jun 29, 2026
…Time64

The AST fuzzer hit a UBSan signed-integer-overflow on master when an
extreme DateTime64 near INT64_MIN flows into the toStartOf*Interval family
(STID 1421-42cf, Stress test (amd_asan_ubsan)).

toStartOfHourInterval (reached by toStartOfInterval with an N-hour unit,
N > 1) computes the final result as `values.date + time` in signed Int64.
findIndex clamps only the LUT index, not t itself, so for t near INT64_MIN
the raw `time = t - values.date` is hugely negative and `values.date + time`
underflows Int64 -- undefined behavior:

  runtime error: signed integer overflow: -2208988800 + -9223372034645788816
  cannot be represented in type 'long'

The sum is now computed in UInt64 (defined wraparound) and cast back to the
signed type. For every in-range input this is byte-identical to the previous
result; only inputs within a divisor of INT64_MIN -- which have no valid
datetime meaning -- now wrap deterministically instead of invoking UB.

The minute-interval and roundDown fast paths that exhibited the same bug
class were fixed independently on master by the roundDownToMultiple helper
added in PR ClickHouse#107985; this change covers the remaining hour-interval site.
It is the toStartOf*Interval analogue of the subsecond fix in PR ClickHouse#105482
(toStartOfSecond/Millisecond/Microsecond in DateTimeTransforms.h).

The regression test exercises the whole toStartOf*Interval family at the
INT64_MIN boundary so the entire family stays UBSan-clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Ergus pushed a commit to Ergus/ClickHouse that referenced this pull request Jun 29, 2026
…es" (ClickHouse#105591)

This reverts the merge of PR ClickHouse#105591 (commit d562138), reversing changes
made to 6519f67.

ClickHouse#105591 broke 02354_vector_search_rescoring on master across all build configs
with a deterministic Code 44 ILLEGAL_COLUMN ("The _distance column is an
internal virtual column of vector search and cannot be referenced directly").

Root cause is a base-skew semantic conflict between two PRs merged 65 minutes
apart, neither of which saw the other in CI:
- ClickHouse#107985 (merged 10:05 UTC) added a hard ILLEGAL_COLUMN guard in both passes
  of useVectorSearch.cpp, making _distance internal-only. It closed customer
  incident clickhouse-core-incidents#1654 and added test
  02354_vector_search_incident1654 asserting the guard.
- ClickHouse#105591 (merged 11:10 UTC) added a feature that deliberately supports
  referencing _distance directly, with test queries and reference output that
  expect it to succeed.

The guard from ClickHouse#107985 pre-empts ClickHouse#105591's new code path, so ClickHouse#105591's own
tests fail on master. Reverting ClickHouse#105591 (the later, feature PR) restores master
to green while preserving the customer-incident ClickHouse#1654 guard. The product
decision of whether _distance should be user-referenceable is left to the
vector-search owners to reconcile and re-land.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ery_profile_events

Add ProfileEvents to observe distributed query plan execution
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…es" (ClickHouse#105591)

This reverts the merge of PR ClickHouse#105591 (commit d562138), reversing changes
made to 6519f67.

ClickHouse#105591 broke 02354_vector_search_rescoring on master across all build configs
with a deterministic Code 44 ILLEGAL_COLUMN ("The _distance column is an
internal virtual column of vector search and cannot be referenced directly").

Root cause is a base-skew semantic conflict between two PRs merged 65 minutes
apart, neither of which saw the other in CI:
- ClickHouse#107985 (merged 10:05 UTC) added a hard ILLEGAL_COLUMN guard in both passes
  of useVectorSearch.cpp, making _distance internal-only. It closed customer
  incident clickhouse-core-incidents#1654 and added test
  02354_vector_search_incident1654 asserting the guard.
- ClickHouse#105591 (merged 11:10 UTC) added a feature that deliberately supports
  referencing _distance directly, with test queries and reference output that
  expect it to succeed.

The guard from ClickHouse#107985 pre-empts ClickHouse#105591's new code path, so ClickHouse#105591's own
tests fail on master. Reverting ClickHouse#105591 (the later, feature PR) restores master
to green while preserving the customer-incident ClickHouse#1654 guard. The product
decision of whether _distance should be user-referenceable is left to the
vector-search owners to reconcile and re-land.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Mark the suite dist_each_sequential=True. The flaky/targeted integration checks
run the parallel bucket with --dist=each, so every xdist worker brings up its own
full 18-node Keeper+S3 cluster of test.py concurrently (3 copies on the 61 GiB
AMD_MEDIUM ASan runner), which the kernel OOM-killed (job exit 137). The new flag
routes both test.py and test_concurrent.py to the looped sequential -n 1 bucket
under --dist=each (one cluster at a time, repeated >=3x, so the flakiness signal
is preserved) while leaving them parallel under --dist=loadfile in the ~140 normal
integration jobs (one file -> one worker -> one cluster, which never OOMs).

The dist_each_sequential field and force_heavy_modules_sequential routing landed
in master via ClickHouse#107985; this only adds the keeper suite to TEST_CONFIGS.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements 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.

4 participants