Skip to content

sync private - #108080

Merged
scanhex12 merged 4 commits into
ClickHouse:masterfrom
scanhex12:sync_ice
Jun 26, 2026
Merged

scanhex12 merged 4 commits into
ClickHouse:masterfrom
scanhex12:sync_ice

Conversation

@scanhex12

@scanhex12 scanhex12 commented Jun 21, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Version info

  • Merged into: 26.7.1.119

@clickhouse-gh

clickhouse-gh Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5c8ad7d]

Summary: ❌

job_name test_name status info comment
Stress test (amd_tsan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue
Stress test (arm_ubsan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) ERROR

AI Review

Summary

This PR syncs Iceberg metadata plumbing from private code, adds an Iceberg metadata deserialization helper, disables the compaction implementation in Cloud builds, and leaves a new assertion in getHistory. I am not approving because the remaining getHistory assertion still treats the cached opening-time format-version as stable even though existing Iceberg behavior explicitly allows external v1 to v2 upgrades between queries.

Missing context / blind spots
  • ⚠️ The PR title/body do not explain the intended contract for createWithDeserialization or prepared_iterator; in this OSS tree they have no caller, so the distributed/Cloud behavior they are meant to support cannot be validated from the visible diff.
Findings

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp:847] PersistentTableComponents::format_version is documented as the value observed when the table was opened, but getHistory now asserts that it still equals the latest metadata file's format-version. A valid external Iceberg upgrade from v1 to v2 after the table has been opened violates that assertion. This keeps the same stale-version problem for OPTIMIZE and system.iceberg_history that the reader and remove_orphan_files paths already handle by parsing the latest/current metadata. Drop the assertion, or validate only invariants that are required to stay stable across metadata refreshes.

💡 Nits

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/IcebergMetadata.cpp:451] In Cloud builds, Compaction.h now hides compactIcebergTable behind !CLICKHOUSE_CLOUD, while IcebergMetadata::optimize still references it when allow_experimental_iceberg_compaction is enabled. This is a build/compile concern rather than an inline review blocker, but the Cloud build needs the call guarded or a Cloud-safe implementation path.
Tests
  • ⚠️ Please add a focused regression test that opens a v1 Iceberg table, externally upgrades the metadata to v2, then exercises system.iceberg_history and/or OPTIMIZE TABLE with compaction enabled. Existing upgrade tests cover reads and remove_orphan_files, but not this getHistory caller.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: remove or replace the stale format-version assertion in getHistory and cover one getHistory caller after an external v1 to v2 upgrade.

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

auto metadata_object
= getMetadataJSONObject(metadata_file_path, object_storage, persistent_components.metadata_cache, local_context, log, compression_method, persistent_components.table_uuid);
chassert(persistent_components.format_version == metadata_object->getValue<int>(f_format_version));

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.

persistent_components.format_version is still only the version observed when this metadata object was constructed. getHistory fetches the latest metadata file again, so a table opened at format-version 1 and then externally upgraded to 2 can still reach this assertion through OPTIMIZE/compaction even though the rest of the Iceberg reader already tolerates that upgrade by parsing each metadata file on its own terms. Please drop this assertion too, or validate only an invariant that must actually remain stable across metadata refreshes.

@Michicosun

Copy link
Copy Markdown
Member

great pr!

@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.60% 92.50% -0.10%
Branches 77.50% 77.40% -0.10%

Changed lines: Changed C/C++ lines covered by tests: 18/53 (33.96%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@scanhex12
scanhex12 enabled auto-merge June 26, 2026 17:25
@scanhex12 scanhex12 self-assigned this Jun 26, 2026
@scanhex12

Copy link
Copy Markdown
Member Author

Will merge it due to I got accept here #107335

@scanhex12
scanhex12 added this pull request to the merge queue Jun 26, 2026
Merged via the queue into ClickHouse:master with commit 9073562 Jun 26, 2026
319 of 328 checks passed
@scanhex12
scanhex12 deleted the sync_ice branch June 26, 2026 18:03
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 26, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Oct 22, 2026
…story

`PersistentTableComponents::format_version` is captured when the table is
opened and is documented as allowed to go stale after an external upgrade.
`getHistory` re-reads the latest metadata file and asserted that its
`format-version` still equals the cached value, so a debug or sanitizer
server aborted when another engine upgraded an attached table and then
`system.iceberg_history` or `OPTIMIZE` (which calls `getHistory`) ran.
Seen in Stress test (amd_msan) on PR ClickHouse#125542 (STID 2508-400e), where the
AST fuzzer turned a `system.iceberg_history` query into an unfiltered scan
that reached the table 05394 had just upgraded to format version 3.

ClickHouse#100407 removed this comparison from both `getState` and `getHistory`; the
ClickHouse#108080 sync brought both back and 6520200 removed only the
`getState` one. `getHistory` computes everything from the freshly read
metadata, and release builds compile `chassert` out, so there is no
release-build behavior change.

Extend the ClickHouse#86776 regression case to compare `system.iceberg_history`
before and after the v1 -> v2 upgrade; it aborts node1 on master.

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

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

3 participants