Skip to content

Parallel replicas for object storage writes - #119214

Merged
scanhex12 merged 2 commits into
masterfrom
iceberg-parallel-replicas-write
Sep 10, 2026
Merged

scanhex12 merged 2 commits into
masterfrom
iceberg-parallel-replicas-write

Conversation

@scanhex12

@scanhex12 scanhex12 commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Support parallel replicas for object storage writes


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

Version info

  • Backported to: 26.8.3.87, 26.7.8.7, 26.6.6.12

@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c9a93c9]

Summary: ✅


AI Review

Summary

The PR makes StorageObjectStorageCluster writable and the new integration coverage proves the obvious INSERT VALUES and explicit INSERT INTO FUNCTION icebergS3Cluster(...) paths no longer throw. I found one remaining contract gap: the cluster wrapper still drops the underlying data-lake table's replication capability, so a DatabaseDataLake table wrapped by parallel_replicas_for_cluster_engines still misses the distributed INSERT ... SELECT path from *Cluster sources. Because that leaves a realistic write surface outside the advertised feature, this should be fixed before merge.

Findings

⚠️ Majors

  • [src/Storages/ObjectStorage/StorageObjectStorageCluster.h:34] StorageObjectStorageCluster still inherits IStorage::supportsReplication() == false, even though plain StorageObjectStorage reports data-lake tables as replicated. DatabaseDataLake::tryGetTableImpl now returns this wrapper when parallel_replicas_for_cluster_engines is enabled, so InterpreterInsertQuery::distributedWriteIntoReplicatedMergeTreeOrDataLakeFromClusterStorage returns early on !dst_storage->supportsReplication(). The generic parallel_distributed_insert_select = 2 fallback does not cover this shape, because it only recognizes ReadFromParallelRemoteReplicasStep while *Cluster sources build ReadFromCluster. As a result, INSERT INTO <catalog table> SELECT ... FROM icebergS3Cluster(...) still falls back to the plain single-node path instead of the distributed data-lake write path the PR is trying to add.
    Suggested fix: add supportsReplication() here with the same configuration->isDataLakeConfiguration() contract as StorageObjectStorage, then cover the *Cluster INSERT ... SELECT shape in integration tests.
Tests
  • ⚠️ The new tests cover INSERT VALUES and direct INSERT INTO FUNCTION ... only. Add a focused integration test for INSERT INTO <catalog table> SELECT ... FROM icebergS3Cluster(...) (or another *Cluster source) with parallel_distributed_insert_select enabled; that is the path still hidden by the missing supportsReplication() override.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: make StorageObjectStorageCluster report the same replication capability as the wrapped data-lake storage and add one regression test for the *Cluster INSERT ... SELECT path.

LLVM Coverage Report

Measured on commit c9a93c9.

Metric Baseline Current Δ
Lines 88.90% 89.00% +0.10%
Functions 91.80% 91.80% +0.00%
Branches 81.30% 81.30% +0.00%

Changed lines: Changed C/C++ lines covered: 45/67 (67.16%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Sep 10, 2026
Covers the `catalog == nullptr` side of
`StorageObjectStorageCluster::write`: an Iceberg table that is not
managed by a catalog, written through `icebergS3Cluster`, which used to
throw `Method write is not supported by storage IcebergS3`.

The engine table and the plain `icebergS3` table function are checked in
the same test, because with parallel replicas enabled neither is
converted to the cluster variant for an `INSERT` - the engine table is
never auto-converted, and `TableFunctionObjectStorage::executeImpl`
guards the conversion with `!is_insert_query`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 10, 2026
ContextPtr context,
bool async_insert) override;

bool isDataLake() const override { return configuration->isDataLakeConfiguration(); }

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.

StorageObjectStorage reports data-lake tables as replicated, but this wrapper still inherits IStorage::supportsReplication() == false. That changes real control flow once DatabaseDataLake::tryGetTableImpl starts returning StorageObjectStorageCluster for writes under parallel_replicas_for_cluster_engines: InterpreterInsertQuery::distributedWriteIntoReplicatedMergeTreeOrDataLakeFromClusterStorage bails out on !dst_storage->supportsReplication(), so INSERT INTO <catalog table> SELECT ... FROM icebergS3Cluster(...) never reaches the distributed data-lake write path.

The generic parallel_distributed_insert_select = 2 fallback does not rescue this shape either, because ClusterProxy::isSuitableForInsertSelectWithParallelReplicas only recognizes ReadFromParallelRemoteReplicasStep, while *Cluster reads build ReadFromCluster. Could we mirror StorageObjectStorage::supportsReplication() here for data-lake configurations and add an INSERT ... SELECT regression test?

@clickhouse-gh clickhouse-gh Bot added the comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. label Sep 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c9a93c901 with master cf7992904 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

7 object files changed (+27.51 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/StorageObjectStorageCluster.cpp.o 354.30 KiB 378.48 KiB +24.18 KiB (+6.82%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

99 translation units recompiled, 948 s compile time in total, 99 of them have a recent master baseline.

Job report

@scanhex12 scanhex12 self-assigned this Sep 10, 2026
@scanhex12
scanhex12 added this pull request to the merge queue Sep 10, 2026
Merged via the queue into master with commit 2de04db Sep 10, 2026
174 checks passed
@scanhex12
scanhex12 deleted the iceberg-parallel-replicas-write branch September 10, 2026 20:05
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 10, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 10, 2026
PedroTadim added a commit that referenced this pull request Sep 11, 2026
Backport #119214 to 26.8: Parallel replicas for object storage writes
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #119214 to 26.7: Parallel replicas for object storage writes
clickhouse-gh Bot added a commit that referenced this pull request Sep 13, 2026
Backport #119214 to 26.6: Parallel replicas for object storage writes
PedroTadim added a commit that referenced this pull request Sep 14, 2026
Cherry pick #119214 to 26.3: Parallel replicas for object storage writes
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 14, 2026
@asya-ch

asya-ch commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

[Post-merge review]

Everything looks OK except for a conflict with #114823. I opened a fix here: #120233.

kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 18, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 18, 2026
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Sep 23, 2026
…ables

Restore `StorageObjectStorageCluster::write` (from the upstream backport of
ClickHouse#119214) that was lost while resolving the port: direct inserts such as
`INSERT ... VALUES` and async inserts are written from the initiator via
`pure_storage`, instead of reaching `IStorageCluster::write`, which throws
`Method write is not supported` when a cluster name is set.

Fixes `test_database_iceberg/test.py::test_cluster_insert` and
`test_storage_iceberg_no_spark/test_writes_parallel_replicas_no_catalog.py`.

#2399 (comment)
#2399
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Oct 6, 2026
`05077_iceberg_equality_delete_nullability_mismatch`: absolute data and
metadata paths inside the table `location` are mapped under the table root
by the path resolver, so they are no longer checked against `user_files`
as raw paths. The check requires that the remainder after `location` does
not climb out of it, so a crafted path cannot escape the table root.

`test_cluster_insert`, `test_writes_parallel_replicas_no_catalog`:
`StorageObjectStorageCluster::write` always writes on the initiator, as
introduced upstream by the backport of
ClickHouse#119214 instead of throwing
`NOT_IMPLEMENTED` when a cluster is set.

CI report: #2481 (comment)
PR: #2481

Signed-off-by: Andrey Zvonov <[email protected]>
alexey-milovidov pushed a commit to comino/ClickHouse that referenced this pull request Oct 16, 2026
With parallel replicas for cluster engines, `DatabaseDataLake` returns a
`StorageObjectStorageCluster` for every statement, and its `mutate` (added in
ClickHouse#119214) passed itself as the mutation's read source. `Iceberg::writeDataFiles`
builds `MutationsInterpreter` over that storage; for a non-MergeTree source it
reads with a synthetic `SELECT <columns> WHERE <predicate>` that has no table
expression, and `IStorageCluster::read` re-analyzes that query to build the
per-replica query, so the virtual columns cannot be resolved:
`Unknown expression identifier _row_id (UNKNOWN_IDENTIFIER)` for
`ALTER TABLE ... DELETE`, `ALTER TABLE ... UPDATE` and `DELETE FROM`.

Pass a transient local `StorageObjectStorage` of the same table as the read
source instead, built with the arguments `DatabaseDataLake` uses without
parallel replicas (`is_table_function` so the constructor never creates the
table in the catalog, `lazy_init` so it does no object storage request). The
metadata refresh and the metadata snapshot stay with the cluster storage, so
the mutation runs against the state the interpreter validated, and the read
storage needs no refresh of its own. The mutation read runs on the initiator,
as it does without parallel replicas.

Closes ClickHouse#122161

Co-Authored-By: Claude Opus 5.5 <[email protected]>
nihalzp pushed a commit to nihalzp/ClickHouse that referenced this pull request Oct 16, 2026
With parallel replicas usable for cluster engines, `DatabaseDataLake`
serves catalog tables through `StorageObjectStorageCluster`. ClickHouse#119214 made
that wrapper forward the catalog write and DDL entry points to the same
configuration and catalog that `StorageObjectStorage` uses, but not
`checkAlterPartitionIsPossible` / `alterPartition`. So
`ALTER TABLE <catalog table> DROP PARTITION` (ClickHouse#122269) reached the
`IStorage` defaults and failed with
`Table engine IcebergS3 doesn't support partitioning (NOT_IMPLEMENTED)`.

Forward both exactly as `StorageObjectStorage` does. Which partition
commands and catalogs are allowed stays decided by the data lake metadata,
so the result is the same as with parallel replicas off.

Closes ClickHouse#124988

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

Labels

comp-object-storage Object storage connectivity (S3/GCS/Azure) including credentials, retries, multipart, etc. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-improvement Pull request with some product improvements pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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