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 985b733e7d [core] Add retry for reading snapshot when encountering 
MismatchedInputException (#6678)
985b733e7d is described below

commit 985b733e7dc489e814a534a9394f5e0fff15dbb3
Author: yuzelin <[email protected]>
AuthorDate: Wed Nov 26 14:46:39 2025 +0800

    [core] Add retry for reading snapshot when encountering 
MismatchedInputException (#6678)
---
 .../org/apache/paimon/utils/SnapshotManager.java   | 27 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java 
b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
index 05337bda59..dd4016adbe 100644
--- a/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
+++ b/paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java
@@ -24,6 +24,7 @@ import org.apache.paimon.fs.Path;
 import org.apache.paimon.table.Instant;
 
 import 
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache;
+import 
org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.exc.MismatchedInputException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -770,12 +771,26 @@ public class SnapshotManager implements Serializable {
     }
 
     public static Snapshot tryFromPath(FileIO fileIO, Path path) throws 
FileNotFoundException {
-        try {
-            return Snapshot.fromJson(fileIO.readFileUtf8(path));
-        } catch (FileNotFoundException e) {
-            throw e;
-        } catch (IOException e) {
-            throw new RuntimeException("Fails to read snapshot from path " + 
path, e);
+        int retryNumber = 0;
+        MismatchedInputException exception = null;
+        while (retryNumber++ < 10) {
+            try {
+                return Snapshot.fromJson(fileIO.readFileUtf8(path));
+            } catch (MismatchedInputException e) {
+                // retry
+                exception = e;
+                try {
+                    Thread.sleep(1_000);
+                } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
+                    throw new RuntimeException(ie);
+                }
+            } catch (FileNotFoundException e) {
+                throw e;
+            } catch (IOException e) {
+                throw new RuntimeException("Fails to read snapshot from path " 
+ path, e);
+            }
         }
+        throw new UncheckedIOException(exception);
     }
 }

Reply via email to