Skip to content

Fix Iceberg DELETE and UPDATE on catalog tables with parallel replicas - #126097

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/iceberg-cluster-mutations-local-read
Oct 15, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/iceberg-cluster-mutations-local-read

Conversation

@groeneai

@groeneai groeneai commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #122161

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):

Fixed ALTER TABLE ... DELETE, ALTER TABLE ... UPDATE and DELETE FROM on Iceberg tables of a DataLakeCatalog database failing with UNKNOWN_IDENTIFIER when parallel replicas are enabled. Closes #122161.

Description

On 26.9 (measured on 26.9.16.11), ALTER TABLE ... DELETE, ALTER TABLE ... UPDATE and DELETE FROM on an Iceberg table of a DataLakeCatalog database fail with UNKNOWN_IDENTIFIER (unknown identifier _row_id) whenever parallel replicas are enabled, while the same statements succeed without them. The table is not modified.

Root cause: with parallel replicas the database returns a StorageObjectStorageCluster, and its mutate (added in #119214) passed itself as the mutation's read source. MutationsInterpreter reads with a SELECT that has no FROM, and IStorageCluster::read re-analyzes that query to build the per-replica query, so the virtual columns cannot be resolved.

Change: the mutation now reads through a local StorageObjectStorage of the same table, built with the arguments DatabaseDataLake uses without parallel replicas. The metadata refresh and snapshot still come from the cluster storage. The mutation read runs on the initiator, as it does without parallel replicas.

ALTER TABLE ... DROP PARTITION is not implemented by the cluster variant and still returns NOT_IMPLEMENTED with parallel replicas; this PR does not change it.

Validation: the new integration test test_cluster_mutations fails on master and on 26.9.16.11 with the error from the issue and passes with the fix (10/10 repeated); the test_database_iceberg module and test_writes_parallel_replicas_no_catalog pass.


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

Version info

  • Merged into: 26.11.1.12-master (included in 26.11 and later)

groeneai and others added 2 commits October 15, 2026 18:27
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]>
Condense the read-source comment in StorageObjectStorageCluster::mutate to one line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

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 my own cold review (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 ALTER TABLE ... DROP PARTITION is still NOT_IMPLEMENTED with parallel replicas: the cluster variant does not override alterPartition AGREE, not blocking separate from the read-source defect fixed here; disclosed in the description, no code change

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

Session id: cron:clickhouse-review-slot-8:20261015-182900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. test_database_iceberg/test.py::test_cluster_mutations fails every run on master (e0d54e88) and on the official 26.9.16.11 binary at the ALTER TABLE ... DELETE with Code: 47 ... Unknown expression identifier _row_id.
b Root cause explained? With parallel replicas DatabaseDataLake returns a StorageObjectStorageCluster, whose mutate passed itself as the read source. MutationsInterpreter reads with a FROM-less SELECT; IStorageCluster::read re-analyzes it to build the per-replica query and cannot resolve the virtual columns.
c Fix matches root cause? Yes. The mutation reads through a local StorageObjectStorage of the same table; refresh and metadata snapshot stay with the cluster storage. No guard, no setting.
d Test intent preserved / new tests added? New integration test covering ALTER DELETE, DELETE FROM and ALTER UPDATE, checked on both replicas with and without parallel replicas on the read.
e Both directions demonstrated? Fails without the fix, passes with it (10/10 repeated). A scratch probe showed each of the three statements fails on its own without the fix, so none of the test's steps is vacuous.
f Fix is general across code paths? Only StorageObjectStorageCluster overrides mutate among IStorageCluster subclasses; both Iceberg MutationsInterpreter passes (delete and UPDATE rewrite) take the passed storage; StorageObjectStorage::mutate already reads locally.
g Fix generalizes across inputs (params/datatypes/wrappers)? The defect is the choice of read source, independent of column types. All three mutation statements are covered, including the UPDATE second pass.
h Backward compatible? (maintainer-approved exception only) Yes. No setting or format change; the only behavior change is error to success for these statements.
i Invariants and contracts preserved? The read storage is transient, never started, never refreshed and never writes; the mutation runs against the metadata the interpreter validated. The mutation read stays on the initiator, as without parallel replicas.

Session id: cron:clickhouse-impl-slot-6:20261015-175300

@clickhouse-gh

clickhouse-gh Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [823920d]

Summary: ✅


AI Review

Summary

PR #126097 fixes Iceberg catalog mutations with parallel replicas by reading through a temporary local StorageObjectStorage, while retaining the cluster storage's refreshed mutation metadata. The regression test covers ALTER TABLE ... DELETE, DELETE FROM, and ALTER TABLE ... UPDATE, with results checked from both replicas. No actionable findings at 823920dab3bd1a4cfe2209db38ce32c9cbd2f5d4.

Missing context / blind spots
  • ⚠️ Integration tests were not run locally during this review. The author reports that test_cluster_mutations fails before the fix and passes repeatedly afterward. Independent confirmation would come from a successful focused integration/bugfix-validation run; the CI report did not yet provide that result at review time.
Final Verdict

Status: ✅ Approve. No code changes requested; CI confirmation remains pending.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alesapin @scanhex12, could you review this? With parallel replicas, StorageObjectStorageCluster::mutate passed itself as the mutation read source, so the FROM-less SELECT of MutationsInterpreter went through IStorageCluster::read and failed with UNKNOWN_IDENTIFIER for _row_id; the mutation now reads through a local StorageObjectStorage of the same table.

@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 15, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 15, 2026
Merged via the queue into ClickHouse:master with commit 9b94f8a Oct 15, 2026
351 of 353 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 15, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 3, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 3, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 3, 2026
Backport #126097 to 26.10: Fix Iceberg `DELETE` and `UPDATE` on catalog tables with parallel replicas
leshikus pushed a commit that referenced this pull request Nov 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. 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-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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 v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DELETE/UPDATE under parallel replicas: mutation reads via IStorageCluster

5 participants