Skip to content

Bound the metadata-log of Iceberg tables on write - #128702

Merged
scanhex12 merged 9 commits into
masterfrom
iceberg-metadata-log-limit
Nov 23, 2026
Merged

scanhex12 merged 9 commits into
masterfrom
iceberg-metadata-log-limit

Conversation

@scanhex12

@scanhex12 scanhex12 commented Nov 2, 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):

Introduce a setting that can limit metadata-log field. It will prevent increasing size of the metadata file


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

Version info

  • Merged into: 26.12.1.317-master (included in 26.12 and later)

Every commit into an Iceberg table appended an entry to `metadata-log` and nothing
ever removed one, so long-lived tables accumulated tens of thousands of entries and
multi-megabyte `metadata.json` files that every query has to read and parse.

A write now keeps at most `write.metadata.previous-versions-max` entries, like the
Java implementation, and drops the oldest ones first. When the table does not set
the property, the new setting `iceberg_metadata_previous_versions_max` (default 100,
the default of the property) is used.

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

clickhouse-gh Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [77cc9e1]

Summary: ❌

job_name test_name status info comment
Stress test (arm_release) FAIL
Child process was terminated by signal 11 (STID: None) FAIL cidb

AI Review

Summary

The PR bounds the Iceberg metadata-log on writes using iceberg_metadata_previous_versions_max, with a table-property override and compatibility history. Review of head 77cc9e1566739c1b33e3b47a5ab13afe011f8666 leaves one previously dismissed metadata-history concern. No new inline findings were posted, and existing threads were left unchanged.

Missing context / blind spots
  • ⚠️ No local ClickHouse binary or build directory is available, so tests were not executed locally. The current head still has pending or running CI checks; completed unit and focused stateless results would close the execution gap.
Findings
⚠️ Majors
  • MetadataGenerator.cpp:126–143: The bounded history can omit the immediately previous metadata file. [dismissed by author -- https://github.com/Bound the metadata-log of Iceberg tables on write #128702#discussion_r4445137142] The callers still append the destination file, whereas the Iceberg specification requires the previous metadata file. The new reference explicitly expects v9 to contain [v9] at a limit of one, leaving no previous version protected. This also affects interoperability: if an external writer produced v8 with log [v6,v7], a ClickHouse write of v9 with write.metadata.previous-versions-max = 1 retains [v7,v9], omitting v8. collectMetadataRootFiles consequently leaves v8 eligible for remove_orphan_files after its age threshold. The documented inclusion of the current file does not address the missing source version. Append the source metadata path and its timestamp before trimming, and align the setting/property documentation and expectations with that history.
Tests
  • ⚠️ The regression currently asserts the self-reference in 05483_iceberg_metadata_log_limit.reference:4. Assert the source metadata filename instead, including one write starting from an external-style log that excludes its current file. This distinguishes correct previous-file retention from merely bounding the array length.
  • ⚠️ The property-copying fix in Compaction.cpp:1149 has no focused regression. An existing full-compaction test should use conflicting table/query limits and verify the property and effective limit after compaction and another insert.
Final Verdict

Status: ⚠️ Request changes

Correct the previous-file history, or explicitly link an issue tracking the pre-existing defect, and add the focused retention coverage described above.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Nov 2, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Nov 2, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 77cc9e156 with master 83b7bee32 (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

10 object files changed (+40.26 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Iceberg/Mutations.cpp.o 703.50 KiB 735.09 KiB +31.59 KiB (+4.49%)

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

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

Job report

@alesapin alesapin self-assigned this Nov 4, 2026
alesapin and others added 2 commits November 18, 2026 15:00
…g-limit

# Conflicts:
#	src/Storages/ObjectStorage/DataLakes/Iceberg/Compaction.cpp
#	src/Storages/ObjectStorage/DataLakes/Iceberg/MetadataGenerator.cpp
- Keep `iceberg_metadata_previous_versions_max` previous metadata files in
  `metadata-log` in addition to the entry of the file being written, so a
  limit of one still references the previous file.
- Trim the log in place when a single entry is over the limit instead of
  rebuilding the array on every commit.
- Append to and bound the log in `ALTER` schema changes and
  `expire_snapshots`, which previously bypassed it.
- Carry the table properties, including `write.metadata.previous-versions-max`,
  through the metadata rebuilt by full compaction.
- Document that the setting has no effect on catalogs that write the
  metadata files themselves, such as a REST catalog.

#128702

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 19, 2026
scanhex12 and others added 4 commits November 20, 2026 15:15
…ms` of `ALTER`

- With an older `compatibility` the setting `iceberg_metadata_previous_versions_max`
  is `18446744073709551615`, and adding one for the entry being written wrapped
  the limit to zero, so every write removed the whole `metadata-log`. Compare the
  number of previous versions against the limit instead.
- Schema changes appended a `metadata-log` entry with the current time but kept
  the old `last-updated-ms`, which Iceberg Java rejects with `Invalid update
  timestamp`. Advance `last-updated-ms` to the commit timestamp.

#128702

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-log` entries

The setting is now the maximum number of entries that a write keeps in the
`metadata-log`, including the entry of the metadata file it writes, so a
value of N leaves exactly N entries. Before, it was the number of previous
versions, and the log kept one entry more.

The table property `write.metadata.previous-versions-max` keeps the meaning
of the Java implementation: the number of previous metadata files, at least
one, so the log keeps one entry more than its value.

#128702

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scanhex12
scanhex12 enabled auto-merge November 23, 2026 13:15
@scanhex12
scanhex12 added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit 3fd53e9 Nov 23, 2026
193 of 195 checks passed
@scanhex12
scanhex12 deleted the iceberg-metadata-log-limit branch November 23, 2026 20:06
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-iceberg Apache Iceberg tables: reading and writing Iceberg metadata (snapshots, manifests, schema evoluti... pr-improvement Pull request with some product improvements 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