You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/10/14 05:05:17 UTC

[I] bug: TableMetadataBuilder::RemoveSchemas leaves removed ids in the schema index [iceberg-cpp]

LuciferYang opened a new issue, #1011:
URL: https://github.com/apache/iceberg-cpp/issues/1011

   ## Summary
   
   `TableMetadataBuilder::Impl::RemoveSchemas` filters `metadata_.schemas` but never touches `schemas_by_id_`. Within the same builder the removed ids stay resolvable, so `Build()` can produce metadata whose `current-schema-id` points at a schema that is no longer in `schemas`.
   
   ## Root cause
   
   `SetCurrentSchema` checks the id against `schemas_by_id_`, and the current-schema check in `Build()` uses the same index. Both still find the removed schema, so:
   
   1. `RemoveSchemas({1})` followed by `SetCurrentSchema(1)` succeeds, and `Build()` returns metadata with `current-schema-id: 1` while `schemas` no longer contains schema 1.
   2. `RemoveSchemas({1})` followed by `AddSchema` of the same schema finds it through the stale index and skips re-adding it to `schemas`.
   
   ## Impact
   
   `InMemoryCatalog::CommitTable` and `SqlCatalog::CommitTable` apply the caller's update list on one builder, then `Build()` and write the result. A commit carrying `[remove-schemas, set-current-schema]` for the same id is enough to write that metadata file, and reading it back fails with `Cannot find schema with current-schema-id=...`, so the table can no longer be loaded.
   
   Java's `Builder.removeSchemas` does not update `schemasById` either, so this is stricter than Java's builder.
   
   ## Proposed fix
   
   Erase the removed ids from `schemas_by_id_` alongside the existing filter of `metadata_.schemas`.
   
   ## Out of scope
   
   `RemovePartitionSpecs` has the same gap with `specs_by_id_`. Follow-up.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] bug: TableMetadataBuilder::RemoveSchemas leaves removed ids in the schema index [iceberg-cpp]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac closed issue #1011: bug: TableMetadataBuilder::RemoveSchemas leaves removed ids in the schema index
URL: https://github.com/apache/iceberg-cpp/issues/1011


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org