Skip to content

Fix distributed task iterator not initialized exception with parallel replicas - #100146

Merged
alexey-milovidov merged 57 commits into
masterfrom
fix-distributed-task-iterator-not-initialized
Jun 4, 2026
Merged

alexey-milovidov merged 57 commits into
masterfrom
fix-distributed-task-iterator-not-initialized

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 19, 2026 •

Copy link
Copy Markdown
Member

Non-cluster table functions (url, s3, azure, etc.) incorrectly enabled distributed_processing when used in queries sent to shards via parallel replicas. The check collaborate_with_initiator && hasClusterFunctionReadTaskCallback() was too broad: collaborate_with_initiator is true for both cluster functions and parallel replicas, while hasClusterFunctionReadTaskCallback is always true (set by TCPHandler for all queries). This caused the shard-side storage to send ReadTaskRequest packets to the initiator, which had no task_iterator.

Only cluster table functions (urlCluster, s3Cluster, etc.) should enable distributed processing on shards — they handle this in their own getStorage method. Non-cluster variants should always set distributed_processing = false.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=533b0535373cf1e44484335cb5c589a07412b30c&name_0=MasterCI&name_1=BuzzHouse%20%28amd_ubsan%29&name_1=BuzzHouse%20%28amd_ubsan%29

Closes #91736

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix "Distributed task iterator is not initialized" exception when using url, s3, or similar table functions in queries with parallel replicas enabled.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Note

Medium Risk
Adjusts how parallel replicas rewrite/execute url/object-storage table functions and when shards enable distributed task iteration; regressions could affect query distribution behavior across replicas but scope is limited to cluster/table-function execution paths.

Overview
Fixes the "Distributed task iterator is not initialized" failure by ensuring non-cluster table functions (e.g. url, s3) never enable distributed_processing when executed on parallel replicas; only *Cluster variants are allowed to use task iterators.

Adds shard-side rewriting in StorageURLCluster/StorageObjectStorageCluster to rename auto-converted functions to their *Cluster variants (and prepend the cluster name) only if the Cluster variant exists, and tightens parallel-replica eligibility in TableFunctionObjectStorage accordingly.

Keeps DataLake tables enabling distributed_processing when collaborating with an initiator-created StorageObjectStorageCluster, adds IStorageCluster::getClusterName() for rewrite support, updates the test runner SIGTERM cleanup behavior, and introduces a regression test covering url/s3 and a no-Cluster-variant case (paimonLocal).

Reviewed by Cursor Bugbot for commit 760ea8d. Bugbot is set up for automated code reviews on this repo. Configure here.

Version info

  • Merged into: 26.6.1.373

…lel replicas with table functions

Non-cluster table functions (`url`, `s3`, `azure`, etc.) incorrectly enabled
`distributed_processing` when used in queries sent to shards via parallel
replicas. The check `collaborate_with_initiator && hasClusterFunctionReadTaskCallback()`
was too broad: `collaborate_with_initiator` is true for both cluster functions and
parallel replicas, while `hasClusterFunctionReadTaskCallback` is always true
(set by `TCPHandler` for all queries). This caused the shard-side storage to
send `ReadTaskRequest` packets to the initiator, which had no `task_iterator`.

Only cluster table functions (`urlCluster`, `s3Cluster`, etc.) should enable
distributed processing on shards — they handle this in their own `getStorage`
method. Non-cluster variants should always set `distributed_processing = false`.

Closes #91736

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=533b0535373cf1e44484335cb5c589a07412b30c&name_0=MasterCI&name_1=BuzzHouse%20%28amd_ubsan%29&name_1=BuzzHouse%20%28amd_ubsan%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5a958f8]

Summary: ✅


AI Review

Summary

This PR fixes the Distributed task iterator is not initialized exception by forcing plain url/object-storage table functions to avoid distributed_processing on secondary queries, while current-version initiators rewrite auto-distributed reads to the matching *Cluster table function. The homogeneous current-version path looks plausible and the current Praktika PR report has no failed checks, but the patch still leaves rolling-upgrade correctness regressions and silently drops existing distribution for object-storage aliases without *Cluster variants.

Findings

❌ Blockers

  • [src/TableFunctions/TableFunctionURL.cpp:155] [dismissed by author -- https://github.com/Fix distributed task iterator not initialized exception with parallel replicas #100146#discussion_r3176506144] Rolling upgrades must preserve task-based splitting when an older initiator talks to a newer secondary. The new url to urlCluster rewrite exists only on new initiators; the PR diff shows the old StorageURLCluster::updateQueryToSendIfNeeded did not rename plain url. In an old-initiator/new-secondary rollout, the secondary can still receive plain url with a task iterator extension, but this line now forces distributed_processing = false, so every replica can scan the full URL/glob set and duplicate rows. Suggested fix: keep a revision-gated compatibility path for plain url secondary reads when collaborate_with_initiator and hasClusterFunctionReadTaskCallback are present, or otherwise protocol-gate the new behavior until all initiators are known to send urlCluster.

  • [src/TableFunctions/TableFunctionObjectStorage.cpp:305] [dismissed by author -- https://github.com/Fix distributed task iterator not initialized exception with parallel replicas #100146#discussion_r3171399219] The same rolling-upgrade invariant is broken for plain object-storage functions. The old StorageObjectStorageCluster::updateQueryToSendIfNeeded path only injected structure/format; it did not rename s3/azureBlobStorage/hdfs to *Cluster, while old initiators still supplied a task iterator. A newer secondary now hard-codes distributed_processing = false for those plain functions, so it ignores the initiator's task splitting and each replica can read the full object set. Suggested fix: preserve a compatibility fallback for secondary plain object-storage reads when a cluster-function read-task callback is present, ideally revision-gated.

⚠️ Majors

  • [src/TableFunctions/TableFunctionObjectStorage.cpp:255] [dismissed by author -- https://github.com/Fix distributed task iterator not initialized exception with parallel replicas #100146#discussion_r3173196106] parallel_replicas_for_cluster_engines now requires a registered name + "Cluster" table function, which disables the existing distributed path for object-storage aliases such as gcs, cosn, and oss. Before this PR, those functions could create StorageObjectStorageCluster, keep the plain function name in the worker query, and consume the task iterator through TableFunctionObjectStorage. Now they silently fall back to initiator-only execution even when parallel replicas are requested. Suggested fix: either keep the previous plain-function distributed path for these aliases or register compatible gcsCluster/cosnCluster/ossCluster variants.
Tests
  • ⚠️ Add the smallest mixed-version regression or protocol-level test proving old initiator plus new secondary preserves task splitting for plain url and object-storage functions. Current tests cover only same-version behavior.
  • ⚠️ Add coverage for an object-storage alias without a *Cluster variant, for example gcs, cosn, or oss, with parallel_replicas_for_cluster_engines = 1, so the intended fallback/distribution behavior is explicit.
Final Verdict

Status: ❌ Block

Minimum required actions: preserve rolling-upgrade correctness for plain url and object-storage secondary reads, and avoid silently dropping parallel-replica distribution for object-storage aliases that currently lack *Cluster table functions.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 19, 2026
@alexey-milovidov
alexey-milovidov marked this pull request as draft March 20, 2026 09:20
alexey-milovidov and others added 2 commits March 20, 2026 11:19
… fix

The previous commit correctly set `distributed_processing=false` for
non-cluster table functions (`s3`, `url`, `azure`, etc.) to prevent
the "Distributed task iterator is not initialized" exception when these
functions appear in queries distributed via parallel replicas.

However, this also broke the auto-cluster feature
(`parallel_replicas_for_cluster_engines=true`), where the initiator
auto-converts `s3()` to `StorageObjectStorageCluster` but sends the
query to shards with the original `s3()` table function name. On the
shard, `TableFunctionObjectStorage::executeImpl` was called with
`distributed_processing=false`, causing each shard to read ALL data
independently instead of getting task assignments from the initiator.

Fix: in `updateQueryToSendIfNeeded`, rename the table function from its
non-cluster variant (e.g. `s3`) to the cluster variant (e.g.
`s3Cluster`) and prepend the cluster name argument. This ensures shards
use `TableFunctionObjectStorageCluster::executeImpl`, which already has
the correct `distributed_processing` logic based on
`collaborate_with_initiator`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Comment thread src/Storages/StorageURLCluster.cpp Resolved
Unlike table functions (`s3`, `url`, etc.) which can be rewritten to their
Cluster variants (`s3Cluster`, `urlCluster`) in `updateQueryToSendIfNeeded`,
DataLake tables are queried as `SELECT * FROM catalog.table` and cannot be
renamed. The shard-side `DatabaseDataLake::tryGetTableImpl` must set
`distributed_processing=true` when the initiator created a
`StorageObjectStorageCluster` with a task iterator.

Restore the `collaborate_with_initiator && can_use_parallel_replicas` check
for DataLake, which is safe because `can_use_parallel_replicas` requires
`parallel_replicas_for_cluster_engines` — guaranteeing the initiator set up
the cluster task iterator.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov and others added 9 commits March 28, 2026 19:52
…uster_engines`

Some table functions like `paimonLocal` and `deltaLakeLocal` do not have
registered Cluster variants (`paimonLocalCluster`, `deltaLakeLocalCluster`).
When `parallel_replicas_for_cluster_engines` is enabled, the code in
`StorageObjectStorageCluster::updateQueryToSendIfNeeded` unconditionally
appended "Cluster" to the table function name, causing "Unknown table function"
exceptions on worker nodes.

Now check whether the Cluster variant is actually registered in
`TableFunctionFactory` before renaming.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Test that non-cluster table functions (`url`, `s3`) work correctly when
`parallel_replicas_for_cluster_engines` is enabled and do not throw
"Distributed task iterator is not initialized".

Addresses review feedback requesting regression tests for the rewrite
path in `StorageURLCluster::updateQueryToSendIfNeeded` and
`StorageObjectStorageCluster::updateQueryToSendIfNeeded`.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The regression test was using `test_cluster_two_shards` which has 2 shards
with 1 replica each. Parallel replicas require multiple replicas within a
single shard to actually trigger the code path. Changed to
`test_cluster_one_shard_three_replicas_localhost` which has 3 replicas.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Table functions like `paimonLocal` and `deltaLakeLocal` do not have
registered Cluster variants (`paimonLocalCluster`, `deltaLakeLocalCluster`).
When `parallel_replicas_for_cluster_engines` is enabled, the initiator
was creating a `StorageObjectStorageCluster` that distributed the query
to all replicas, but since the Cluster variant doesn't exist, the query
on each replica just reads all data — producing N copies of the result.

Now check whether the Cluster variant is registered in
`TableFunctionFactory` before enabling parallel replicas. If no Cluster
variant exists, fall through to creating a regular (non-distributed)
storage.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…inary

The previous test only used `parallel_replicas_for_cluster_engines = true`
which works on the old binary because the initiator creates a cluster storage
with a task iterator. The bugfix validation correctly reported "test passed on
old binary".

Add a new test case that queries a MergeTree table with parallel replicas and
`url()` in a subquery. On the old binary, the replica sets
`distributed_processing = true` for `url()` (because
`collaborate_with_initiator` is true for parallel replicas), causing the
replica to send `ReadTaskRequest` packets to the initiator which has no
`task_iterator` — triggering the "Distributed task iterator is not initialized"
exception.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged master into the branch; new CI will re-run.

Pre-merge CI failures triaged (all unrelated to this PR):

Three bot review threads (TableFunctionObjectStorage.cpp:255, TableFunctionObjectStorage.cpp:305, TableFunctionURL.cpp:155) were re-posting the same concerns; replied with the reasoning and resolved them. The short version: the "mixed-version rollout" scenarios the bot describes never actually had a working task iterator on the old initiator — the bug being fixed here is exactly that the old code asked for task iteration in cases where the initiator never provided one.

@groeneai

Copy link
Copy Markdown
Collaborator

@groeneai, investigate the failure: 04229_trivial_group_by_limit_profile_events ...

Confirmed and fixed in #104996.

Root cause: OptimizeTrivialGroupByLimitPass runs in the analyzer on the initiator and lowers max_rows_to_group_by via query->getMutableContext()->setSetting(...). That mutation lives on the initiator's query context; it's not propagated to remote replicas, so once CI's automatic_parallel_replicas_mode = 2 randomization is sampled (which sets enable_parallel_replicas = 1 + parallel_replicas_for_non_replicated_merge_tree = 1 + cluster_for_parallel_replicas = 'parallel_replicas'), the aggregators on the remotes never apply the cap and ProfileEvents::OverflowAny stays at zero. The test then sees 04229_on 0 instead of 04229_on 1.

CIDB scope (30d): failed across PRs #104473 (source), #100146, #101033, #104694, #104966 — all unrelated.

Local repro: 3-replica default_parallel_replicas cluster on loopback, runner-style session settings. Original test: 0/5 passes. Fixed test (pins enable_parallel_replicas = 0 at query-level SETTINGS): 20/20 passes.

PR #104996 is test-only — no no-* tag, no widened assertions, just a query-level enable_parallel_replicas = 0 pin in both SETTINGS clauses so the optimization is exercised on the local-coordinator path it was designed for. If you also want the pass itself to skip under parallel replicas (so the behavior is documented in code rather than just at the test level), happy to send that as a follow-up.

Session: cron:clickhouse-ci-task-worker:20260515-044500

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failure: https://github.com/ClickHouse/clickhouse-private/actions/runs/25935635285/job/76243324509 and provide a fix in a separate PR. If the fix is already in progress, link it here.

The sync PR (clickhouse-private#53056) has no merge conflicts (mergeable = MERGEABLE). The CH Inc sync check is failing because all test_e2e_catalogs/test.py::test_*[onelake] tests fail in the private Integration tests E2E job (test_namespace_prefix, test_drop_and_recreate, test_select_count, test_select_limit, test_projection_pushdown, test_where_filter, test_where_non_partition_column, test_aggregations, test_group_by, test_order_by, test_nullable_handling, test_primitive_types, test_primitive_values, test_complex_types, test_complex_values, test_join_catalog_and_local, …). The PR only touches url/s3/azure table functions and parallel replicas — no onelake/iceberg code is modified. The same onelake E2E failures are also occurring on other unrelated sync PRs (e.g. #57975, #57934, #54262), confirming this is broken on private master.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — confirmed: the test_e2e_catalogs/test.py::test_*[onelake] failures on private CI run 25935635285/job/76243324509 are environmental on the private side and not caused by this PR.

Triage:

Item Status
PR #100146 scope url/s3/azure table functions + parallel replicas — no onelake/iceberg/RestCatalog code touched
Canonical OneLake bug Issue #103674 — RestCatalog::getTables did not paginate, hides tables in large namespaces (OneLake/BigLake/Iceberg REST). CLOSED.
Canonical fix PR #104531 (Fix RestCatalog::getTables and getNamespaces pagination) — MERGED 2026-05-14T19:03:01Z by @fm4v (commit d6c14609)
Your own cross-PR evidence Same [onelake] failures hitting unrelated sync PRs #57975, #57934, #54262 → confirms not PR-caused, broken on private master
Public CIDB test_e2e_catalogs not present (private-only suite) — public-side has nothing to verify against

Already tracked on our side under two umbrella tasks consolidating CH Inc sync [onelake] sightings across multiple unrelated sync PRs:

Action on PR #100146: None on our side. The fix is already on public master via #104531 (merged 2026-05-14, ~2 days before the failing private run). Once the private fork picks up that commit (or a private-side equivalent if the private branch hasn't synced master yet), these [onelake] cases should clear. The PR itself is safe to merge from a [onelake]-attribution standpoint — there is no causal link between the parallel-replicas / url/s3/azure change and the OneLake catalog test setup.

If the private sync of d6c14609 is somehow blocked or the failures persist after a re-sync, please ping and we'll investigate further on the private side.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — confirmed: this is the chronic 01710_projection_additional_filters issue tracked by #104219, a regression introduced by PR #102921 (merged 2026-05-04). It fails daily on master and many unrelated PRs on Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) with pattern expected 3, got 13 (= 10 unfiltered + 3 filtered, replica-sum). Unrelated to this PR.

Fix already in flight: #104296 by @azat ("Fix trivial count optimization with additional_table_filters with parallel replicas and analyzer"). State: OPEN / MERGEABLE / BLOCKED, awaiting review.

No separate fix from us; monitoring #104296 via CIDB.

alexey-milovidov pushed a commit that referenced this pull request May 17, 2026
…replicas

`OptimizeTrivialGroupByLimitPass` runs in the analyzer on the initiator
and lowers `max_rows_to_group_by` on the query's local context. That
mutation is not propagated to remote replicas, so once CI's
`automatic_parallel_replicas_mode=2` randomization is sampled the
aggregator on the remotes never applies the cap and `OverflowAny` stays
at zero. The test then sees `04229_on   0` instead of
`04229_on   1` and fails 3/3 reruns (every PR run hits the same diff).

Pin `enable_parallel_replicas = 0` at the query level in both `SETTINGS`
clauses so the optimization is exercised on the local-coordinator path
it is designed for. Query-level `SETTINGS` takes priority over the
runner's session-level injection, so the pin is robust against
randomization. No `no-*` tag is added (per
`.claude/CLAUDE.md` guidance) and no other randomization is disabled —
`max_threads = 1` was already pinned, the rest stays randomized.

Locally reproduced with a 3-replica `default_parallel_replicas` cluster
on loopback: 5/5 fails without the pin (`04229_on   0`), 20/20 passes
with the pin under the same parallel-replicas session settings.

Cross-PR scope (CIDB, 30d): seen on PRs #104473, #100146, #101033,
#104694, #104966 — all unrelated to the test or its source PR.

Reported by @alexey-milovidov on
#100146.
alexey-milovidov and others added 5 commits May 21, 2026 08:35
…k-iterator-not-initialized

# Conflicts:
#	ci/jobs/scripts/functional_tests_results.py
When the parent watchdog enters the `stop_testing` cleanup block (hung
check failed, server died, etc.) and calls `p.terminate()` on workers,
each worker's `except KeyboardInterrupt` handler in `run_tests_array`
calls `stop_tests()`, which broadcasts SIGTERM to the whole process
group via `cleanup_child_processes`. That SIGTERM races against the
parent's join loop: the parent's `signal_handler` raises `Terminated`
mid-cleanup, propagates out of `do_run_tests` before `raise StopTesting`
is reached, and `clickhouse-test` exits with `128 + 15 = 143` instead of
the contracted `STOP_TESTING_EXIT_CODE = 2`.

`functional_tests_results.py` then sees `runner_exit_code != 2` and
classifies the run as "test runner terminated unexpectedly"
(`Result.Status.ERROR`) - skipping the branch that synthesizes the
`Server died` FAIL leaf. Bugfix validation inverts FAIL <-> OK status
per leaf, so without a FAIL leaf it concludes "Failed to reproduce the
bug" even when the master baseline binary has clearly crashed (a
`core.QueryPipelineEx.*` core dump is in the artifacts).

Mask SIGTERM around the cleanup block so the parent always reaches
`raise StopTesting`, restoring the previous handler before unwinding.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/100146/70de0c6620ea2915179ee33e2b0c07d6e93542ab/bugfix_validation_functional_tests/

PR: #100146

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…k-iterator-not-initialized

# Conflicts:
#	tests/clickhouse-test
@clickhouse-gh

clickhouse-gh Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.50% 84.40% -0.10%
Functions 92.40% 92.40% +0.00%
Branches 77.00% 77.00% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 62/65 (95.38%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov self-assigned this Jun 4, 2026
@alexey-milovidov
alexey-milovidov merged commit e0ad473 into master Jun 4, 2026
165 of 167 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-distributed-task-iterator-not-initialized branch June 4, 2026 07:04
@clickhouse-gh

clickhouse-gh Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

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

This change only adjusts distributed_processing handling for url/s3/DataLake table functions under parallel replicas, plus a test-harness signal fix and a new regression test. The standard ClickBench query path over a local table is not touched, so the flagged improvements on Q4 (-15%), Q15 (-13.8%), and Q28 (-6.3%) cannot plausibly come from this PR. They are consistent across unrelated queries, which indicates measurement variance rather than a real speedup, so all three were downgraded to not-sure. No genuine performance regression or improvement is attributable to this change.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
⚠️ 4 not_sure 265 225 -15.1% <0.0001 PR only touches s3/url/DataLake parallel-replica plumbing; Q4 reads a local table. Off-path, run-to-run variance.
⚠️ 15 not_sure 240 207 -13.8% <0.0001 Diff is confined to cluster table-function distribution; Q15's local scan path is untouched. Treat as variance.
⚠️ 28 not_sure 7076 6629 -6.3% <0.0001 -6.3% on a local aggregation Q the PR can't reach (only url/s3/datalake plumbing changed). Off-path.

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: 40204ee3-6af5-44fa-9fed-982bae29ad36
  • MIRAI run: 505eb0d0-2c57-4716-8223-071d7a7b6c2a
  • PR check IDs:
    • clickbench_365129_1780559757
    • clickbench_365135_1780559757
    • tpch_adapted_1_official_365149_1780559757
    • tpch_adapted_1_official_365155_1780559757
    • tpch_adapted_1_official_365162_1780559757

@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 4, 2026
@clickgapai

clickgapai commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

TL;DR

Fix distributed task iterator not initialized exception with parallel replicas

ClickGap verified: reproduced it with the script below on 26.5; tested 4 version(s) — 3 affected, 1 clean (see Affects); confirmed it predates the oldest available release (pre-existing).

Reproduction

SET enable_analyzer = 1;
SET enable_parallel_replicas = 1, automatic_parallel_replicas_mode = 0;
SET max_parallel_replicas = 3;
SET cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost';
SET parallel_replicas_for_cluster_engines = 0;
SET parallel_replicas_for_non_replicated_merge_tree = 1;
SET parallel_replicas_local_plan = 0;
SELECT count() FROM r100146.t
WHERE x IN (SELECT toUInt32(x) FROM url('http://127.0.0.1:${HTTP}/?query=SELECT+1', 'TSV', 'x UInt8'));

Bisect

  • Present since at least v25.12.11.4 — reproduces on every release line tested down to there; the introducer predates the oldest release with a downloadable binary, so a single commit isn't pinnable from release binaries (not a recent regression).

Affects

  • ✓ Fix is on master — this PR's change fixes the bug on master. Branches below still have the bug and need the backport.
  • Reproduces on: 26.5, 26.4, 26.3
  • Does NOT reproduce on: master
  • Could not test (binary unavailable): 25.8
  • Backport needed: 26.5, 26.4, 26.3

Suggested next step

The fix has landed on master; the affected release branches above still need the backport.

Component: comp-parallel-replicas
Severity: P2


ClickGap · Finding: phase_d_pr100146

Triage metadata

  • Primary component: comp-parallel-replicas
  • Secondary components: comp-object-storage, comp-testing
  • Component owners (comp-parallel-replicas): @devcrafter @nickitat

pull Bot pushed a commit to muzammilar/ClickBench that referenced this pull request Sep 17, 2026
Since ClickHouse 26.6 (PR ClickHouse/ClickHouse#100146), an
`INSERT ... SELECT * FROM url(...)` with parallel replicas and the default
`parallel_distributed_insert_select = 2` forwards the unrenamed `url(...)`
INSERT to every replica; a plain `url()` on a replica ignores the task
iterator and reads all 100 files, so a service with N replicas ends up with
N copies of the dataset. The Cloud fast channel crossed that version on
2026-09-12: since then the 2- and 3-replica results have inflated data
sizes, query times, and load times.

Spell the source as `urlCluster('default', ...)`, which distributes the
files across replicas on every version, and refuse to run the queries
unless the table holds exactly 99,997,497 rows, so collect-results.sh
skips a bad load instead of publishing it.

Remove the affected multi-replica results (2026-09-12 to 2026-09-16); the
dashboard falls back to the last correct run from 2026-09-11.

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

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

Logical error: Distributed task iterator is not initialized (STID: 4662-4342)

5 participants