fix(metadata): drop removed schema ids from the builder's schema index #1012
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 309 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.343
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1012"
general
weight: 0.35
LuciferYang
What
TableMetadataBuilder::Impl::RemoveSchemasremoved schemas frommetadata_.schemasbut left them inschemas_by_id_, so later calls on the same builder still resolved the removed ids.Transactionapplies all of its updates to one builder, so this was reachable through the public API. Take a table whose current schema is 0 and whose schema 1 is unused, for example because a column was added and then dropped. In one transaction,ExpireSnapshotswithCleanExpiredMetadata(true)removes schema 1, andUpdateSchema::AddColumnthen produces a new schema that gets the freed id 1.AddSchemafinds id 1 in the stale index and does not add the new schema toschemas, andSetCurrentSchema(1)picks up the removed schema instead. Without this fix the commit succeeds and writescurrent-schema-id: 1with only schema 0 inschemas, and the nextLoadTablefails withCannot find schema with current-schema-id=1.The same stale entry let
SetCurrentSchemaaccept a removed id directly, so a catalog commit carrying[remove-schemas, set-current-schema]for that id wrote the same kind of file.Closes #1011.
How
Erase the removed ids from
schemas_by_id_alongside the existing filter ofmetadata_.schemas.This is stricter than Java. Java's
Builder.removeSchemasleavesschemasByIdstale, sosetCurrentSchemaon a removed id still succeeds there, andbuild()returns metadata whosecurrent-schema-idis not inschemas. In C++ the same sequence makesBuild()fail withCannot set current schema to unknown schema.Testing
ExpireUnusedSchemaThenAddColumnintransaction_test.ccruns the transaction above againstInMemoryCatalog. Without the fixCommit()succeeds and reloading the table fails withCannot find schema with current-schema-id=1. With the fix the reloaded current schema is 1 and has the added column.RemoveSchemasDropsIndexEntryintable_metadata_builder_test.cc: afterRemoveSchemas({1}),SetCurrentSchema(1)makesBuild()fail withCannot set current schema to unknown schema: 1. Without the fixBuild()returns metadata with the dangling id.AddSchemaAfterRemoveNotConfusedByStaleIndexintable_metadata_builder_test.cc: re-adding the removed schema puts it back inschemas. Without the fix the stale index entry makesAddSchemaskip it andschemasstays at one entry.RemovePartitionSpecshas the same gap withspecs_by_id_; I'll send that separately.