Skip to content

Commit 603e139

Browse files
lintingbinclaude
andcommitted
[AMORO-4163][ams] Fix CommitFailedException when loading legacy mixed-iceberg tables on Iceberg 1.7.x
Found while investigating the CI failure in apache#4179. Iceberg 1.7.x introduced a breaking change in HadoopTableOperations.commit(): it now uses reference equality (==) to compare the `base` argument against the cached currentMetadata. Previously, newTableOperations() called ops.current() to obtain the current metadata, but versionAndMetadata() inside commit() may refresh the internal state and return a different object instance. When the two references differ, commit() throws CommitFailedException("Cannot commit changes based on stale table metadata") even though the metadata content is identical, causing table loading to fail. Fix: replace ops.current() with ops.refresh() so that the returned TableMetadata reference is the same object stored in ops' internal cache. When commit() then calls versionAndMetadata(), it finds the version unchanged on disk and returns the same cached reference, satisfying the reference-equality check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 10d13d4 commit 603e139

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

amoro-ams/src/main/java/org/apache/amoro/server/table/internal/InternalMixedIcebergHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ private TableOperations newTableOperations(boolean changeStore) {
6969

7070
MixedHadoopTableOperations ops =
7171
new MixedHadoopTableOperations(new Path(tableLocation), io, metaStore.getConfiguration());
72-
org.apache.iceberg.TableMetadata current = ops.current();
72+
// Use refresh() instead of current() so that the returned TableMetadata reference is the
73+
// same object cached inside ops. Iceberg 1.7.x commit() starts with versionAndMetadata()
74+
// which compares the `base` argument against the cached reference using == (reference
75+
// equality). If current() and versionAndMetadata() return different object instances,
76+
// commit() throws CommitFailedException even when the metadata content is identical.
77+
org.apache.iceberg.TableMetadata current = ops.refresh();
7378
if (current == null) {
7479
return ops;
7580
}

0 commit comments

Comments
 (0)