This is an automated email from the ASF dual-hosted git repository.
czy006 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new 08d49f4f3 [AMORO-4163][ams] Fix Version-N-already-exists race in
newTableOperations for legacy mixed-iceberg (#4185)
08d49f4f3 is described below
commit 08d49f4f3fa60ce3c96eb4c824b445e9f276d423
Author: Darcy <[email protected]>
AuthorDate: Thu Apr 23 17:12:15 2026 +0800
[AMORO-4163][ams] Fix Version-N-already-exists race in newTableOperations
for legacy mixed-iceberg (#4185)
When AMS saves a new legacy mixed-iceberg table to the database, a
background
table-explorer thread can concurrently pick up the same table and call
newTableOperations(), which now commits the mixed-format properties to the
Iceberg metadata (introduced by the AMORO-4163 fix). If the background
thread
wins the race and writes v2.metadata.json before the onTableCreated() path
attempts the same commit, HadoopTableOperations throws
CommitFailedException:
"Version 2 already exists", aborting the createTableMeta RPC.
Fix: catch CommitFailedException in the commit block, refresh to obtain the
latest on-disk metadata, and proceed if a concurrent writer already
committed
the correct properties. Re-throw only when the properties still differ
after
refresh, indicating a genuine commit conflict.
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
.../server/table/internal/InternalMixedIcebergHandler.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/table/internal/InternalMixedIcebergHandler.java
b/amoro-ams/src/main/java/org/apache/amoro/server/table/internal/InternalMixedIcebergHandler.java
index c53c45594..4687348b1 100644
---
a/amoro-ams/src/main/java/org/apache/amoro/server/table/internal/InternalMixedIcebergHandler.java
+++
b/amoro-ams/src/main/java/org/apache/amoro/server/table/internal/InternalMixedIcebergHandler.java
@@ -32,6 +32,7 @@ import org.apache.amoro.utils.TablePropertyUtil;
import org.apache.hadoop.fs.Path;
import org.apache.iceberg.TableOperations;
import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.exceptions.CommitFailedException;
import java.util.Map;
@@ -81,7 +82,18 @@ public class InternalMixedIcebergHandler extends
InternalIcebergHandler {
org.apache.iceberg.TableMetadata legacyCurrent =
legacyTableMetadata(current, changeStore);
if (!current.equals(legacyCurrent)) {
// add rest based mixed-format table properties
- ops.commit(current, legacyCurrent);
+ try {
+ ops.commit(current, legacyCurrent);
+ } catch (CommitFailedException e) {
+ // A concurrent caller (e.g. background table-explorer racing with
onTableCreated) may
+ // have already committed the same property update. Refresh to get
the latest metadata;
+ // if properties are now up-to-date, proceed normally. Otherwise
re-throw.
+ current = ops.refresh();
+ legacyCurrent = legacyTableMetadata(current, changeStore);
+ if (!current.equals(legacyCurrent)) {
+ throw e;
+ }
+ }
}
return ops;
}