Core: Discard changes when suppressing historical snapshots in CatalogHandlers
I maintainer di solito rispondono entro 1 giorno
@ebyhr ci sta già lavorando.
Dal 27/8/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Iniziare in core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java, in loadTable e nel relativo ramo snapshot-loading-mode=refs; confrontare la ricostruzione dei metadati con RESTSessionCatalog.loadTable. Riprodurre il fallimento tramite RESTCatalogAdapter usando uno snapshot storico con un file di statistiche, quindi verificare che GET .../tables/{table}?snapshots=refs abbia esito positivo senza la metadata-location exception.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Apache Iceberg version
1.11.0 (latest release)
Query engine
None
Please describe the bug 🐞
Behavior
In snapshot-loading-mode=refs, CatalogHandlers.loadTable fails with IllegalArgumentException: Cannot set metadata location with changes to table metadata: 1 changes when serving GET .../tables/{table}?snapshots=refs for a table that has a statistics file (or partition statistics file) attached to a historical (unreferenced) snapshot.
Cause
The REFS branch builds the response metadata like this (CatalogHandlers.java#L526-L531):
metadata =
TableMetadata.buildFrom(loadedMetadata)
.withMetadataLocation(loadedMetadata.metadataFileLocation())
.suppressHistoricalSnapshots()
.build();
suppressHistoricalSnapshots() does not record RemoveSnapshots changes, but it removes the suppressed snapshots' statistics via removeStatistics(...) / removePartitionStatistics(...), which do record MetadataUpdate.RemoveStatistics / RemovePartitionStatistics changes (TableMetadata.java, rewriteSnapshotsInternal). build() then rejects the combination of pending changes and a set metadata location.
The client-side equivalent in RESTSessionCatalog.loadTable already prevents this with by calling .discardChanges() when rebuilding metadata; CatalogHandlers performs the change-recording suppression without that measure.
To Reproduce
E.g. via RESTCatalogAdapter with snapshot-loading-mode=refs on the client:
- Create a table, commit snapshot A, attach a
StatisticsFileto A (e.g.UpdateStatistics). - Commit snapshot B so A becomes historical (only reachable via parent chain, not via refs).
loadTablewithsnapshots=refs→ 500 /IllegalArgumentException: Cannot set metadata location with changes to table metadata: 1 changes.
Encountered in practice testing Trino's REST catalog against the in-memory test server with snapshot-loading-mode=refs: Trino writes statistics on INSERT by default, so the first loadTable after a stats-bearing snapshot becomes historical reliably fails.
Suggested Fix
Add .discardChanges() to the builder chain in CatalogHandlers.loadTable (matching the client-side wrapper), e.g.
TableMetadata.buildFrom(loadedMetadata)
.withMetadataLocation(loadedMetadata.metadataFileLocation())
.suppressHistoricalSnapshots()
.discardChanges()
.build();
This would be the minimal fix, keeping the general behavior as is. Alternatively, the suppress-parameter that already prevents MetadataUpdate.RemoveSnapshots changes from being created here could be incorporated into removeStatistics() and removePartitionStatistics() to prevent change creation there at the root.
AI assistance
Found this while working on a trino patch. This root-cause analysis was AI-assisted. I'm quite confident this is an actual bug and checked this in detail before opening the issue. I'll link to the related PR at trino shortly, whose test triggers this behavior.
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
- Lingua principale
- Java
- Stelle
- 9.3k
- Fork
- 3.6k
- Merge medio
- 2g 20h
- PR unite (30g)
- 142
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/iceberg
-
Parquet TIME_MILLIS statistics are not converted to microsecondsForse già presa @chenjian2664 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Temporal transforms put pre-epoch timestamps at `.999999` into the previous unitForse già presa @gitedmond l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/iceberg#18371 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
OpenAPI: Remove deprecated TrueExpression and FalseExpressionForse già presa @zhang-arvin l’ha presa 4 giorni fa. Apertaimprovement
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/iceberg#18351 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Parquet: StringReader decodes every occurrence of a dictionary value into a new StringForse già presa @Neuw84 l’ha presa 18 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/iceberg#18259 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
RCK tests fail to bind port 8181 when run alongside the kafka-connect integration stackForse già presa @Kurtiscwright l’ha presa 20 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/iceberg
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Flight SQL JDBC parses boolean properties case-sensitively, silently disabling TLS for useEncryption=TRUEForse già presa @Arawoof06 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
apache/arrow-java#1357 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
apache/rocketmq-dashboard#6610 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MetricsHub/metricshub-community#1396 ·
I maintainer di solito rispondono entro 1 giorno
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
dependabot/dependabot-core#16547 ·
I maintainer di solito rispondono entro 1 giorno