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

jinsongzhou 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 761d5978a [Improvement] Retry to truncate tables 3 times in unit test 
(#3712)
761d5978a is described below

commit 761d5978a58ad7bd5457a0832a1cc144adb5e0bd
Author: ZhouJinsong <[email protected]>
AuthorDate: Tue Aug 5 19:20:51 2025 +0800

    [Improvement] Retry to truncate tables 3 times in unit test (#3712)
    
    Retry to truncate table in unit test
---
 .../org/apache/amoro/server/table/DerbyPersistence.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/amoro-ams/src/test/java/org/apache/amoro/server/table/DerbyPersistence.java 
b/amoro-ams/src/test/java/org/apache/amoro/server/table/DerbyPersistence.java
index 817984d58..e17b46fcc 100644
--- 
a/amoro-ams/src/test/java/org/apache/amoro/server/table/DerbyPersistence.java
+++ 
b/amoro-ams/src/test/java/org/apache/amoro/server/table/DerbyPersistence.java
@@ -42,6 +42,8 @@ public class DerbyPersistence extends ExternalResource {
 
   private static final TemporaryFolder SINGLETON_FOLDER;
 
+  private static final int TRUNCATE_RETRY_NUM = 3;
+
   static {
     try {
       SINGLETON_FOLDER = new TemporaryFolder();
@@ -86,7 +88,20 @@ public class DerbyPersistence extends ExternalResource {
             }
           }
           for (String table : tableList) {
-            statement.execute("TRUNCATE TABLE " + table);
+            int retry = TRUNCATE_RETRY_NUM;
+            while (true) {
+              try {
+                statement.execute("TRUNCATE TABLE " + table);
+                break;
+              } catch (SQLException e) {
+                if (retry > 0) {
+                  LOG.warn("Failed to truncate {}, retry later.", table, e);
+                  retry--;
+                } else {
+                  throw e;
+                }
+              }
+            }
           }
         }
       }

Reply via email to