Repository navigation
Fix nested cluster table function task iterator via a setting (prototype, alternative to #107107) - #107572
Fix nested cluster table function task iterator via a setting (prototype, alternative to #107107)#107572groeneai wants to merge 1 commit into
Conversation
…ype) Alternative to the ClientInfo-flag approach in PR ClickHouse#107107. Fixes the LOGICAL_ERROR "Distributed task iterator is not initialized" when a *Cluster table function (urlCluster/s3Cluster/fileCluster/object-storage/DataLake) is nested inside a plain Distributed / parallel-replicas broadcast such as clusterAllReplicas(..., s3Cluster(...)). Found by the BuzzHouse fuzzer (issue ClickHouse#91736). Instead of adding a new positional ClientInfo field gated on a protocol bump, introduce an internal Bool setting cluster_function_distributed_read (default true). The initiator clears it on the inner secondary query of a broadcast in ClusterProxy::updateSettingsAndClientInfoForCluster and updateContextForParallelReplicas, where no cluster-function read-task iterator was installed. The worker gate Context::canUseClusterFunctionDistributedRead() returns the setting (after the read-task-callback check), so a nested *Cluster function degrades to a local read. A top-level *Cluster function and INSERT INTO distributed SELECT FROM *Cluster build their own secondary-query context that does not clear the setting, so they keep reading each task once. This keeps the persisted async Distributed insert header layout unchanged (the flag approach appended a field inside the embedded ClientInfo, which an older binary draining the queue would misread), and a non-IMPORTANT setting unknown to an older worker is tolerated (warn and skip) rather than corrupting the header. Related: ClickHouse#91736 Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [5efa64f] Summary: ✅
AI ReviewSummaryThis PR fixes nested Missing context / blind spots
Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 49/55 (89.09%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code |
|
CI finished on The red marks are all chronic infra, not caused by this prototype:
This is a draft prototype; the approach decision between #107107 and this PR sits with the #107107 reviewers. |
|
Superseded by #107107, which implements the agreed approach: throw BAD_ARGUMENTS for nested cluster functions, no new setting. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
LOGICAL_ERROR"Distributed task iterator is not initialized" when a cluster table function (urlCluster,s3Cluster,fileCluster, object-storage and DataLake*Clustervariants) is nested inside an outer distribution such asclusterAllReplicas(..., s3Cluster(...))or a parallel-replicas read.Description
Draft / prototype. Do not merge. This is an alternative implementation of #107107, opened for side-by-side comparison per a review request on that PR. It should be reviewed against #107107, and only one of the two will be kept.
Same bug as #107107 (BuzzHouse fuzzer, issue #91736): a
*Clustertable function nested inside a plainDistributed/ parallel-replicas broadcast (e.g.clusterAllReplicas('cluster', s3Cluster(...))) aborts the server withDistributed task iterator is not initialized. The outer broadcast ships the innerSELECT ... FROM *Cluster(...)to its replicas as a secondary query; on a replica the*Clusterfunction seesquery_kind == SECONDARY_QUERYand enabled distributed (task-based) reading, sending aReadTaskRequestback to an initiator that installed no cluster-function task iterator for it.Difference from #107107. #107107 adds a new positional
ClientInfo::is_cluster_function_distributed_readfield gated on a protocol-revision bump. This branch instead uses an internalBoolsetting:cluster_function_distributed_read(defaulttrue).ClusterProxy::updateSettingsAndClientInfoForCluster(coversDistributed/remote/clusterAllReplicas) andupdateContextForParallelReplicas(covers parallel-replicas-from-MergeTree).Context::canUseClusterFunctionDistributedRead()returns the setting (after the existing read-task-callback check). A nested*Clusterfunction therefore degrades to a local read.*Clusterfunction (IStorageCluster::read) andINSERT INTO distributed SELECT FROM *Clusterbuild their own secondary-query context that does not clear the setting, so they keep reading each task exactly once.Why this is also worth considering. It leaves the persisted async
Distributedinsert-header layout untouched (the field approach appended a field inside the embeddedClientInfo, which an older binary draining the queue would misread), and a non-IMPORTANTsetting unknown to an older worker is tolerated (warn and skip) rather than corrupting the header. No protocol bump is needed.Verified locally (debug build) in both directions, on a single server with the test clusters repointed to one loopback so the nested query runs as a real secondary query:
clusterAllReplicas('...', urlCluster(...))aborts with the exactDistributed task iterator is not initializedfatal error.urlCluster/fileCluster/s3Clustercases complete, the server stays alive, top-levelurlClusterstill distributes, andINSERT INTO distributed SELECT FROM urlCluster(...) SETTINGS parallel_distributed_insert_select = 2reads each globbed task exactly once (3 rows, the01099_parallel_distributed_insert_selectshape, not regressed).The regression tests are the same as #107107 (
03850_nested_cluster_table_function_task_iteratorand thetest_database_icebergnested case).