Skip to content

Remove the stale format_version assertion from IcebergMetadata::getHistory - #126801

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/iceberg-history-format-version-chassert
Oct 22, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/iceberg-history-format-version-chassert

Conversation

@groeneai

@groeneai groeneai commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #86776
Related: #100407

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Description

A debug or sanitizer server aborts on Logical error: 'persistent_components.format_version == metadata_object->getValue<int>(f_format_version)' when it reads the history of an Iceberg table whose format version another engine upgraded while the table stayed attached: system.iceberg_history, or OPTIMIZE with allow_experimental_iceberg_compaction, which calls getHistory first. Seen in Stress test (amd_msan), where the AST fuzzer rewrote the filter of a system.iceberg_history query so that it no longer pruned databases, and the scan reached the table 05394_iceberg_v3_upgrade_insert_assigns_row_ids had just upgraded to v3.

Cause. PersistentTableComponents::format_version is the value seen when the table was opened, and PersistentTableComponents.h documents that it may go stale after an external upgrade. getHistory re-reads the latest metadata file and asserted that its format-version still equals the cached value. #100407 removed this comparison from getState and getHistory; the #108080 sync brought both back, and only the getState one was removed again.

Change. Delete the assertion. getHistory computes its result from the freshly read metadata and uses the cached value nowhere else. Release builds compile chassert out, so they are unaffected. With the fix, OPTIMIZE on a table upgraded to v3 fails with Compaction is supported only for format_version 2 instead of aborting.

Test. test_format_version_upgrade_v1_to_v2 (#86776) now also compares system.iceberg_history before and after the v1 -> v2 upgrade. On master node1 aborts on the post-upgrade read; with the fix it passes. #99981 also deletes this line as one hunk of a larger change.


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

Version info

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

…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]>
@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 finding).

# Sev Finding Verdict Evidence / action
1 💡 PR description called the fuzzed system.iceberg_history query an "unfiltered scan"; it kept a filter that no longer pruned databases AGREE, fixed in the description wording only, no code change

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

Session id: cron:clickhouse-review-slot-8:20261019-204900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Attached IcebergLocal table, external v2 -> v3 metadata bump, then SELECT count() FROM system.iceberg_history: the master debug server aborts with the 2508-400e line (2/2); OPTIMIZE with compaction enabled aborts the same way.
b Root cause explained? getHistory asserted that the fresh metadata's format-version equals the open-time cached value, which PersistentTableComponents.h documents may go stale after an external upgrade.
c Fix matches root cause? Yes. getHistory builds its result from the fresh metadata only; the getState twin already received the same change.
d Test intent preserved / new tests added? Extended test_format_version_upgrade_v1_to_v2 (#86776) to compare system.iceberg_history before and after the upgrade.
e Both directions demonstrated? Yes. Master: node1 aborts on the post-upgrade history read, test FAILS. Fix: PASSES; module 5/5, edited case 5/5 across 5 cluster starts.
f Fix is general across code paths? No other cached-vs-fresh format_version assertion in DataLakes/ or System/; both getHistory callers (system.iceberg_history, OPTIMIZE) checked.
g Fix generalizes across inputs (params/datatypes/wrappers)? v1 -> v2 (test), v2 -> v3 (probe), filtered and unfiltered history reads, OPTIMIZE. Independent of column types and settings.
h Backward compatible? (maintainer-approved exception only) Yes. Release builds compile chassert out; no setting or format change.
i Invariants and contracts preserved? PersistentTableComponents stays immutable; 11 stateless Iceberg history/compaction tests (05394 included) pass with the fix.

Session id: cron:clickhouse-impl-slot-41:20261019-200200

@clickhouse-gh

clickhouse-gh Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [00ed4b3]

Summary: ✅


AI Review

Summary

PR #126801 removes the stale format_version assertion from IcebergMetadata::getHistory, allowing history reads after an external Iceberg format upgrade in debug and sanitizer builds. The existing upgrade test now checks that history remains unchanged across the upgrade. No actionable findings in head 00ed4b3dea2213658a2eed6e4862120f8943650e.

Missing context / blind spots
  • ⚠️ Integration tests were not rerun locally because this checkout has no compiled server or configured build. Debug and MSan builds were still running at review time, so CI had no result for the expanded integration case. The author's validation record reports failure before the fix and repeated passes afterward; those runs were not independently reproduced during this review.
Final Verdict

Status: ✅ Approve. No code changes requested.

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

Copy link
Copy Markdown
Collaborator Author

cc @scanhex12 @SmitaRKulkarni, could you review this and add the can be tested label so CI runs? It deletes the chassert in IcebergMetadata::getHistory that compared the open-time cached format_version with the freshly read metadata, which aborts debug and sanitizer builds after an external format upgrade of an attached table; the getState twin was already removed in 6520200.

@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 19, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 21, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 22, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 22, 2026
Merged via the queue into ClickHouse:master with commit 1010688 Oct 22, 2026
527 of 529 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 22, 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-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