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

lzljs3620320 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 a89330398 [core] Improve error message for concurrent snapshot 
expiration (#4215)
a89330398 is described below

commit a893303985a4123a93fc87077ec72c898e448769
Author: yunfengzhou-hub <[email protected]>
AuthorDate: Mon Sep 23 17:20:36 2024 +0800

    [core] Improve error message for concurrent snapshot expiration (#4215)
---
 paimon-core/src/main/java/org/apache/paimon/Snapshot.java | 15 +++++++++++++++
 .../java/org/apache/paimon/utils/SnapshotManagerTest.java |  4 +++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/paimon-core/src/main/java/org/apache/paimon/Snapshot.java 
b/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
index a16349ce5..3b8d2fa15 100644
--- a/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
+++ b/paimon-core/src/main/java/org/apache/paimon/Snapshot.java
@@ -29,8 +29,12 @@ import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonIgn
 import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonInclude;
 import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import javax.annotation.Nullable;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Map;
 import java.util.Objects;
@@ -61,6 +65,7 @@ import java.util.Objects;
 @Public
 @JsonIgnoreProperties(ignoreUnknown = true)
 public class Snapshot {
+    private static final Logger LOG = LoggerFactory.getLogger(Snapshot.class);
 
     public static final long FIRST_SNAPSHOT_ID = 1;
 
@@ -357,6 +362,16 @@ public class Snapshot {
     public static Snapshot fromPath(FileIO fileIO, Path path) {
         try {
             return Snapshot.fromJson(fileIO.readFileUtf8(path));
+        } catch (FileNotFoundException e) {
+            String errorMessage =
+                    String.format(
+                            "Snapshot file %s does not exist. "
+                                    + "It might have been expired by other 
jobs operating on this table. "
+                                    + "In this case, you can avoid concurrent 
modification issues by configuring "
+                                    + "write-only = true and use a dedicated 
compaction job, or configuring "
+                                    + "different expiration thresholds for 
different jobs.",
+                            path);
+            throw new RuntimeException(errorMessage, e);
         } catch (IOException e) {
             throw new RuntimeException("Fails to read snapshot from path " + 
path, e);
         }
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java 
b/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java
index 544638d4b..6b7b28263 100644
--- a/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java
@@ -369,7 +369,9 @@ public class SnapshotManagerTest {
         localFileIO.deleteQuietly(snapshotManager.snapshotPath(3));
         thread.join();
 
-        assertThat(exception.get()).hasMessageContaining("Fails to read 
snapshot from path");
+        assertThat(exception.get())
+                .hasMessageFindingMatch("Snapshot file .* does not exist")
+                .hasMessageContaining("dedicated compaction job");
     }
 
     @Test

Reply via email to