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

yuqi1129 pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new d1abb38ffc [DO NOT MERGE] [Cherry-pick to branch-1.3] [#12589] 
fix(iceberg-catalog): Fix JDBC CommunicationsException after idle timeout for 
MySQL backend (#12662) (#12883)
d1abb38ffc is described below

commit d1abb38ffc35b1209736ff689e594ea4b23d8368
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Sep 3 20:55:49 2026 +0800

    [DO NOT MERGE] [Cherry-pick to branch-1.3] [#12589] fix(iceberg-catalog): 
Fix JDBC CommunicationsException after idle timeout for MySQL backend (#12662) 
(#12883)
    
    **Cherry-pick Information:**
    - Original commit: 91a5966054da451a4e38886b35875b13b1451ef2
    - Target branch: `branch-1.3`
    - Status: ⚠️ **Has conflicts - manual resolution required**
    
    **Do not merge** until conflict markers are resolved and the
    `cherry-pick-conflict` label is removed.
    
    Please review and resolve the conflicts before merging.
    
    ---------
    
    Signed-off-by: zhang-arvin <[email protected]>
    Signed-off-by: yuqi <[email protected]>
    Co-authored-by: Arvin <[email protected]>
    Co-authored-by: yuqi <[email protected]>
---
 .../iceberg/common/utils/IcebergCatalogUtil.java   |  8 ++++++++
 .../common/utils/TestIcebergCatalogUtil.java       | 22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git 
a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java
 
b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java
index 0d2d5462d0..6c12e60455 100644
--- 
a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java
+++ 
b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/utils/IcebergCatalogUtil.java
@@ -121,6 +121,14 @@ public class IcebergCatalogUtil {
     // explicit config.
     properties.putIfAbsent(IcebergConstants.ICEBERG_JDBC_STRICT_MODE, "true");
 
+    // Add SQLSTATE 08S01 (Communication link failure) to retryable status 
codes so that
+    // idle connections dropped by MySQL wait_timeout are automatically 
retried instead of
+    // failing with CommunicationsException.
+    String existing = properties.putIfAbsent("retryable_status_codes", 
"08S01");
+    if (existing != null && !existing.contains("08S01")) {
+      properties.put("retryable_status_codes", existing + ",08S01");
+    }
+
     HdfsConfiguration hdfsConfiguration = new HdfsConfiguration();
     properties.forEach(hdfsConfiguration::set);
     jdbcCatalog.setConf(hdfsConfiguration);
diff --git 
a/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergCatalogUtil.java
 
b/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergCatalogUtil.java
index 0bf3745538..ade4237456 100644
--- 
a/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergCatalogUtil.java
+++ 
b/iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/utils/TestIcebergCatalogUtil.java
@@ -268,4 +268,26 @@ public class TestIcebergCatalogUtil {
     Assertions.assertEquals(
         "6789", 
properties.get(IcebergConstants.ICEBERG_REST_CLIENT_SOCKET_TIMEOUT_MS));
   }
+
+  @Test
+  void testJdbcRetryableStatusCodes() {
+    Map<String, String> properties = new HashMap<>();
+    properties.put(CatalogProperties.URI, "jdbc:sqlite::memory:");
+    properties.put(CatalogProperties.WAREHOUSE_LOCATION, "test");
+    properties.put(IcebergConstants.GRAVITINO_JDBC_DRIVER, "org.sqlite.JDBC");
+    properties.put(IcebergConstants.ICEBERG_JDBC_USER, "test");
+    properties.put(IcebergConstants.ICEBERG_JDBC_PASSWORD, "test");
+    properties.put(IcebergConstants.ICEBERG_JDBC_INITIALIZE, "true");
+
+    Catalog catalog =
+        IcebergCatalogUtil.loadCatalogBackend(
+            IcebergCatalogBackend.JDBC, new IcebergConfig(properties));
+    Assertions.assertInstanceOf(JdbcCatalogWithMetadataLocationSupport.class, 
catalog);
+
+    // Verify that calling loadCatalogBackend again does not throw
+    Catalog catalog2 =
+        IcebergCatalogUtil.loadCatalogBackend(
+            IcebergCatalogBackend.JDBC, new IcebergConfig(properties));
+    Assertions.assertInstanceOf(JdbcCatalogWithMetadataLocationSupport.class, 
catalog2);
+  }
 }

Reply via email to