This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new dedaaad925 [core] Report concurrent schema merge publication failures 
(#11310)
dedaaad925 is described below

commit dedaaad92540383046367ad3495d0a0d12a039ba
Author: YueZhang <[email protected]>
AuthorDate: Sun Nov 22 05:54:21 2026 -0500

    [core] Report concurrent schema merge publication failures (#11310)
---
 .../paimon/schema/FileSystemSchemaManager.java     |  6 ++-
 .../apache/paimon/schema/SchemaManagerTest.java    | 54 ++++++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/schema/FileSystemSchemaManager.java
 
b/paimon-core/src/main/java/org/apache/paimon/schema/FileSystemSchemaManager.java
index 744e626dce..8eb6ecec9b 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/schema/FileSystemSchemaManager.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/schema/FileSystemSchemaManager.java
@@ -53,6 +53,7 @@ import static 
org.apache.paimon.catalog.Identifier.DEFAULT_MAIN_BRANCH;
 import static org.apache.paimon.schema.ColumnDirectiveUtils.applyDirectives;
 import static org.apache.paimon.utils.FileUtils.listVersionedFiles;
 import static org.apache.paimon.utils.Preconditions.checkArgument;
+import static org.apache.paimon.utils.Preconditions.checkState;
 
 /** File system implementation of {@link SchemaManager}. */
 @ThreadSafe
@@ -262,7 +263,10 @@ public class FileSystemSchemaManager implements 
SchemaManager {
                 schemaModification.alterSchema(changes);
                 return true;
             } else {
-                return commit(update);
+                checkState(
+                        commit(update),
+                        "Failed to publish the merged schema. Please retry the 
operation.");
+                return true;
             }
         } catch (Exception e) {
             throw new RuntimeException("Failed to commit the schema.", e);
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java 
b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java
index 89e17c2e20..9b5dccc30f 100644
--- a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaManagerTest.java
@@ -896,6 +896,60 @@ public class SchemaManagerTest {
         
assertThat(latest.get().options()).doesNotContainKey("fields.f3.sequence-group");
     }
 
+    @Test
+    public void testMergeSchemaCommitConflict() throws Exception {
+        Path tableRoot = new Path(tempDir.toString(), "merge-conflict");
+        FileSystemSchemaManager otherManager =
+                new FileSystemSchemaManager(LocalFileIO.create(), tableRoot);
+        otherManager.createTable(Schema.newBuilder().column("id", 
DataTypes.INT()).build());
+        LocalFileIO fileIO =
+                new LocalFileIO() {
+                    @Override
+                    public boolean tryToWriteAtomic(Path schemaPath, String 
content)
+                            throws IOException {
+                        if (schemaPath.getName().equals("schema-1")) {
+                            try {
+                                otherManager.commitChanges(
+                                        SchemaChange.addColumn("other", 
DataTypes.INT()));
+                            } catch (Exception e) {
+                                throw new IOException(e);
+                            }
+                        }
+                        return super.tryToWriteAtomic(schemaPath, content);
+                    }
+                };
+        FileStoreTable table = FileStoreTableFactory.create(fileIO, tableRoot);
+        RowType incoming =
+                RowType.of(
+                        new DataType[] {DataTypes.INT(), DataTypes.STRING()},
+                        new String[] {"id", "requested"});
+
+        assertThatThrownBy(() -> table.store().mergeSchema(incoming, false, 
false, true))
+                .isInstanceOf(RuntimeException.class)
+                .hasMessage("Failed to commit the schema.")
+                .hasRootCauseMessage(
+                        "Failed to publish the merged schema. Please retry the 
operation.");
+        
assertThat(otherManager.latest().get().fieldNames()).containsExactly("id", 
"other");
+    }
+
+    @Test
+    public void testMergeSchemaCommitAndNoOp() throws Exception {
+        Path tableRoot = new Path(tempDir.toString(), "merge-no-op");
+        FileSystemSchemaManager localManager =
+                new FileSystemSchemaManager(LocalFileIO.create(), tableRoot);
+        localManager.createTable(Schema.newBuilder().column("id", 
DataTypes.INT()).build());
+        FileStoreTable table = 
FileStoreTableFactory.create(LocalFileIO.create(), tableRoot);
+        RowType incoming =
+                RowType.of(
+                        new DataType[] {DataTypes.INT(), DataTypes.STRING()},
+                        new String[] {"id", "requested"});
+
+        assertThat(table.store().mergeSchema(incoming, false, false, 
true)).isTrue();
+        
assertThat(localManager.latest().get().fieldNames()).containsExactly("id", 
"requested");
+        assertThat(table.store().mergeSchema(incoming, false, false, 
true)).isFalse();
+        assertThat(localManager.listAll()).hasSize(2);
+    }
+
     @Test
     public void testConcurrentCommit() throws Exception {
         retryArtificialException(

Reply via email to