Fixed iceberg alter table modify rename#1841
Conversation
|
continuation of #1794 |
Audit Review: PR #1841 — Fixed iceberg alter table modify renameAI audit note: This review comment was generated by AI (claude-4.6-opus). PR: #1841 — Iceberg ALTER TABLE schema-change via REST catalog Call GraphKey Invariants
Confirmed DefectsMedium:
|
|
|
||
| assert instance.query(f"SELECT id, value FROM {TABLE_NAME} ORDER BY id") == "1\thello\n2\tworld\n" | ||
|
|
||
| instance.query(f"INSERT INTO {TABLE_NAME} VALUES (3, 'foo');", settings=INSERT_SETTINGS) |
There was a problem hiding this comment.
It makes sense to insert value bigger than max Int32 here
Verification Report: PR #1841 — Iceberg ALTER TABLE FixPR: Altinity/ClickHouse#1841 Change: Backport of #1594 — fix Verdict
PR-caused failure (fix before merge)
This is the only failure clearly tied to the PR's iceberg ALTER work. Not PR regressions
What passedAll builds · fast test · unit tests · most stateless/integration · iceberg regression (iceberg_1 + iceberg_2, x86 + aarch64) · parquet · s3_export · most alter/s3/rbac regression suites · docker/grype. Iceberg regression green is the strongest signal that the core mutation path works in the dedicated test suite. Recommendation
CI verdict: Red for a real, PR-scoped integration gap ( |
Audit update for PR #1841
PR: Altinity/ClickHouse#1841 — Fixed iceberg alter table modify rename (backport of #1594) Previously-flagged defects, now fixedVerified against commit
Confirmed defects (still open at HEAD)High — Orphan-cleanup
|
|
|
|
I tried concurrent add, drop, rename and got |
|
|
Weird fail with glue catalog: |
|
The description is incorrect. This is not a backport, but a front-port. Also, this does not belong to changelog. Instead, we usually copy the original PR's changelog entry. If this is a PR that shall be ported to every new Antalya release, please, add |
|
@subkanthi ^^ |
|
|
with glue catalog rename only noticable when you select from table, but SHOW TABLE still shows an old name (table created from pyiceberg): |
|
@subkanthi fast test fails, build fails |
…thub.com/Altinity/ClickHouse into antalya_26_3_fix_alter_table_iceberg_new
Modify column should work, but **RENAME COLUMN |
|
|
||
| Poco::JSON::Object::Ptr buildUpdateMetadataRequestBody( | ||
| const String & namespace_name, const String & table_name, Poco::JSON::Object::Ptr new_snapshot) | ||
| { |
There was a problem hiding this comment.
existing code moved to a separate function.
|
…thub.com/Altinity/ClickHouse into antalya_26_3_fix_alter_table_iceberg_new
…gic to filter metadata by table_uuid
|
AI audit note: This review comment was generated by AI (gpt-5.3-codex / Cursor Grok 4.5). Audit update for PR #1841 (Fixed iceberg alter table modify rename): HEAD: Internal Audit TraceScope / partitions
Call graph (changed path)Transition matrix (key invariants)
Previously flagged → status at
|
| Prior defect | Status |
|---|---|
| High: orphan cleanup deletes live metadata under concurrent ALTER | Not re-confirmed for REST — new_metadata_path unused; transactional naming uses UUID; write uses exists + If-None-Match: *. Residual risk only if object storage ignores preconditions on non-UUID (vN.metadata.json) catalogs (e.g. Glue). |
Medium: old_schema_id = new_schema_id - 1 |
Still present; tautologically equal to pre-mutation current under current MetadataGenerator (+1). Downgraded to contract fragility (see Low). |
Medium: checkAlterIsPossible silent when metadata uninitialized |
Fixed — assertInitializedDL() restored; covered by test_alter_fails_when_metadata_not_initialized. |
| Low: cleanup swallows exceptions | Fixed — cleanup failure appended to thrown message; test_alter_orphan_cleanup_failure_reported. |
Low: if(current_metadata) style |
Fixed. |
Fault-category completion
| Category | Status | Outcome |
|---|---|---|
| REST request-body / equivalent-schema | Executed | New Medium confirmed (post-commit divergence) |
| Metadata selection (uuid / ignore_explicit) | Executed | Contributes to Medium above; shared-location fix itself is correct |
| Concurrent write + orphan cleanup | Executed | Prior High not re-confirmed for REST; residual Medium for non-preconditioned stores |
| Validation fail-closed | Executed | Pass |
| Exception / partial update | Executed | Pass for cleanup messaging; catalog failure still non-retrying (accepted, see #1918) |
| Lifetime / races / iterator invalidation | N/A | No new shared mutable settings mutation |
| Integer overflow | N/A | schema ids +1 only |
Confirmed defects
Medium — Next ALTER can assert the wrong current-schema-id after equivalent-schema REST commit
- Impact: After an ALTER that restores a schema already present in history (ADD then DROP back, or no-op-equivalent schema),
buildUpdateMetadataRequestBodyskipsadd-schemaand issuesset-current-schemato the older equivalent id. The REST catalog's live current-schema-id becomes that older id. ClickHouse still writes a localvN-<uuid>.metadata.jsonwherecurrent-schema-idis the locally incremented id, and does not register that path with the catalog (new_metadata_pathis unused). The nextIceberg::alterloads metadata withignore_explicit_metadata_file_path=trueand picks the max version among uuid-matching files — which can be the CH orphan at the same version as the catalog file (std::max_elementis tie-unstable). It then sendsassert-current-schema-id = orphan_current - 1, which does not match the catalog → ALTER fails (or flaps). - Anchor:
src/Databases/DataLake/RestCatalog.cpp/buildUpdateMetadataRequestBody(equivalent-schema branch fromc7abff1);src/Storages/ObjectStorage/DataLakes/Iceberg/Mutations.cpp/Iceberg::alter(ignore_explicit_metadata_file_path=true,select_by_table_uuid=true);RestCatalog::updateMetadata(parameternew_metadata_pathunused). - Trigger: On a REST catalog table, run ALTER ADD COLUMN then DROP COLUMN restoring the prior schema (covered partly by
test_alter_sequential_add_drop_shared_location, which stops without a further ALTER); then run another ALTER. - Why defect: Write path and commit path use different sources of truth for “current schema” after the equivalent-schema short-circuit; ALTER deliberately ignores catalog
metadata-location. - Fix direction (short): For catalog-backed ALTER, resolve the base metadata from
catalog->getTableMetadata/metadata-location(as the transactional insert retry path already does), or stop writing a local metadata object that can win version selection; alternatively, after equivalent-schema commit, do not leave a higher/equal-version orphan with a divergentcurrent-schema-id. - Regression test direction (short): Extend the sequential ADD/DROP test with one extra ALTER after schema restore; assert it succeeds and catalog
current-schema-idmatches the requirement used on that commit. Optionally assert CH does not select a metadata file whosecurrent-schema-iddisagrees withcatalog.load_table().metadata().current_schema_id().
Medium — Successful REST ALTER always leaves an unreferenced metadata object in storage
- Impact: Every catalog-backed ALTER writes
vN[-uuid].metadata.jsonthen commits only logical REST updates (add-schema/set-current-schema). The written object is never set as catalogmetadata-location. Failure cleans it up; success leaves it forever. Besides storage leak, these orphans feed the selection hazard above (same version as catalog-written metadata). - Anchor:
Iceberg::alterwrite +RestCatalog::updateMetadata(..., /*new_metadata_path*/ ...). - Trigger: Any successful
ALTER TABLE ... ADD/DROP/MODIFY/RENAME COLUMNon a REST Iceberg table; count.metadata.jsonobjects under the table prefix before/after (failure path already asserted intest_alter_orphan_metadata_cleanup_on_catalog_failure). - Why defect: Dual-write without linking the object-storage artifact to the catalog commit.
- Fix direction (short): Either commit
metadata-locationto the written file (Glue-style), or do not write a full metadata file for REST schema commits (apply updates only), or delete the local file after successful REST commit. - Regression test direction (short): After a successful ALTER, assert catalog
metadata_locationis the sole new metadata object (or that CH-written uuid-named files are removed/not selected).
Low — assert-current-schema-id derived as new_schema_id - 1 is an implicit contract on MetadataGenerator
- Impact: Correct today because every generator path does
current + 1, butbuildUpdateMetadataRequestBodyreceives the full metadata blob and could read the real previous id (or accept it as an argument). Any future non-+1 evolution breaks all REST ALTERs. - Anchor:
RestCatalog.cpp/const Int32 old_schema_id = new_schema_id - 1; - Trigger: Only if schema-id assignment changes or metadata is not produced by
MetadataGenerator. - Fix direction (short): Capture previous
current-schema-idbefore mutation and pass it into the commit body builder. - Regression test direction (short): gtest where schemas ids are
{0, 5}and current becomes6; requirement must be5(still true with +1) and remain correct if generator later jumps.
Coverage summary
- Scope reviewed: PR diff vs
antalya-26.3merge-base at HEADae12aae— Iceberg ALTER write/commit path, REST body builder (includingc7abff1equivalent-schema logic), uuid-filtered metadata selection (584ddd0), validation/isDatalakeCatalog, orphan cleanup failpoints, and related integration/gtest coverage. - Categories failed: post-equivalent-schema source-of-truth divergence (Medium); successful-path orphan metadata leak (Medium); brittle schema-id requirement derivation (Low).
- Categories passed: shared-location uuid filtering fix; uninitialized-metadata fail-closed; orphan cleanup error surfacing; write precondition (
exists+ If-None-Match) for collision avoidance; REST happy-path gtest for add-schema body; prior Medium/Low audit items from889ec3fera fixed. - Assumptions/limits: Static reasoning only (no runtime). Prior concurrent-delete High not re-confirmed for REST because catalog does not point at the CH-written object; residual overwrite/delete risk remains only if If-None-Match is ignored on shared
vN.metadata.jsonnames.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixes Alter table ADD/DROP/RENAME/MODIFY column for Iceberg tables.
Documentation entry for user-facing changes
Fixes Alter table ADD/DROP/RENAME/MODIFY column for Iceberg tables.
CI/CD Options
Exclude tests:
Regression jobs to run: