Repository navigation
Core: Drop removed schema and spec ids from TableMetadata.Builder indexes - #18678
Open
LuciferYang wants to merge 2 commits into
Open
LuciferYang wants to merge 2 commits into
LuciferYang wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18677.
TableMetadata.Builder.removeSchemasandremoveSpecsfilterschemasandspecsbut leave the removed ids inschemasByIdandspecsById.CatalogHandlers.commitapplies a whole request to one builder, so a transaction that runsexpireSnapshots().cleanExpiredMetadata(true)and then adds a column or a partition field can get a freed id and run into the stale entry. For schemas, the server commits metadata whosecurrent-schema-idis not inschemas, and the table can no longer be loaded. For specs, the commit is rejected withCannot set last added spec: no spec has been added.This removes the ids from the indexes together with the list entries.
setCurrentSchemaon a removed id now fails withCannot set current schema to unknown schema, and a new schema or spec that gets a freed id is added normally.The same bug was fixed in iceberg-cpp in apache/iceberg-cpp#1012.
New tests:
CatalogTests.testRemoveUnusedSchemaThenAddColumnInTransactionandtestRemoveUnusedSpecThenAddFieldInTransactionrun that transaction against each catalog. Without the fix both fail onTestRESTCatalog; they pass on the in-memory, JDBC and Nessie catalogs either way.TestTableMetadata.testRemoveSchemasThenReuseRemovedIdandtestRemoveSpecsThenReuseRemovedIdrun the same sequence on one builder, so the bug shows without a REST server. Without the fix,setCurrentSchema(1)afterremoveSchemas([1])succeeds, and the new spec is not added tospecs.AI Disclosure