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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8b735924b4d HIVE-28038: Disable fallback to jdo for DeadlineException 
(#5040)(Wechar Yu, reviewed by Butao Zhang)
8b735924b4d is described below

commit 8b735924b4d3bbd1d066d7f3508314b95ee55e2d
Author: Wechar Yu <yuwq1...@gmail.com>
AuthorDate: Mon Feb 5 15:32:38 2024 +0800

    HIVE-28038: Disable fallback to jdo for DeadlineException (#5040)(Wechar 
Yu, reviewed by Butao Zhang)
---
 .../hadoop/hive/metastore/DatabaseProduct.java     | 10 ++--
 .../hadoop/hive/metastore/TestObjectStore.java     | 66 ++++++++++++----------
 2 files changed, 40 insertions(+), 36 deletions(-)

diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java
index ea3faf09113..642057bd69a 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java
@@ -28,7 +28,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Stream;
-import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.hadoop.conf.Configurable;
@@ -52,9 +51,10 @@ import com.google.common.base.Preconditions;
  * */
 public class DatabaseProduct implements Configurable {
   static final private Logger LOG = 
LoggerFactory.getLogger(DatabaseProduct.class.getName());
-  private static final Class<SQLException>[] unrecoverableSqlExceptions = new 
Class[]{
-          // TODO: collect more unrecoverable SQLExceptions
-          SQLIntegrityConstraintViolationException.class
+  private static final Class<Exception>[] unrecoverableExceptions = new 
Class[]{
+          // TODO: collect more unrecoverable Exceptions
+          SQLIntegrityConstraintViolationException.class,
+          DeadlineException.class
   };
 
   public enum DbType {DERBY, MYSQL, POSTGRES, ORACLE, SQLSERVER, CUSTOM, 
UNDEFINED};
@@ -164,7 +164,7 @@ public class DatabaseProduct implements Configurable {
   }
 
   public static boolean isRecoverableException(Throwable t) {
-    return Stream.of(unrecoverableSqlExceptions)
+    return Stream.of(unrecoverableExceptions)
                  .allMatch(ex -> ExceptionUtils.indexOfType(t, ex) < 0);
   }
 
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java
index 380863b716c..1da814dd092 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestObjectStore.java
@@ -1635,40 +1635,44 @@ public class TestObjectStore {
 
   @Test
   public void testNoJdoForUnrecoverableException() throws Exception {
-    objectStore.openTransaction();
-    AtomicBoolean runDirectSql = new AtomicBoolean(false);
-    AtomicBoolean runJdo = new AtomicBoolean(false);
-    try {
-      objectStore.new GetHelper<Object>(DEFAULT_CATALOG_NAME, DB1, TABLE1, 
true, true) {
-        @Override
-        protected String describeResult() {
-          return "test not run jdo for unrecoverable exception";
-        }
+    Exception[] unrecoverableExceptions = new Exception[] {
+        new SQLIntegrityConstraintViolationException("Unrecoverable ex"),
+        new DeadlineException("unrecoverable ex")};
+    for (Exception unrecoverableException : unrecoverableExceptions) {
+      objectStore.openTransaction();
+      AtomicBoolean runDirectSql = new AtomicBoolean(false);
+      AtomicBoolean runJdo = new AtomicBoolean(false);
+      try {
+        objectStore.new GetHelper<Object>(DEFAULT_CATALOG_NAME, DB1, TABLE1, 
true, true) {
+          @Override
+          protected String describeResult() {
+            return "test not run jdo for unrecoverable exception";
+          }
 
-        @Override
-        protected Object getSqlResult(ObjectStore.GetHelper ctx) throws 
MetaException {
-          runDirectSql.set(true);
-          SQLIntegrityConstraintViolationException ex = new 
SQLIntegrityConstraintViolationException("Unrecoverable ex");
-          MetaException me = new MetaException("Throwing unrecoverable 
exception to test not run jdo.");
-          me.initCause(ex);
-          throw me;
-        }
+          @Override
+          protected Object getSqlResult(ObjectStore.GetHelper ctx) throws 
MetaException {
+            runDirectSql.set(true);
+            MetaException me = new MetaException("Throwing unrecoverable 
exception to test not run jdo.");
+            me.initCause(unrecoverableException);
+            throw me;
+          }
 
-        @Override
-        protected Object getJdoResult(ObjectStore.GetHelper ctx) throws 
MetaException, NoSuchObjectException {
-          runJdo.set(true);
-          SQLIntegrityConstraintViolationException ex = new 
SQLIntegrityConstraintViolationException("Unrecoverable ex");
-          MetaException me = new MetaException("Throwing unrecoverable 
exception to test not run jdo.");
-          me.initCause(ex);
-          throw me;
-        }
-      }.run(false);
-    } catch (MetaException ex) {
-      // expected
+          @Override
+          protected Object getJdoResult(ObjectStore.GetHelper ctx) throws 
MetaException, NoSuchObjectException {
+            runJdo.set(true);
+            SQLIntegrityConstraintViolationException ex = new 
SQLIntegrityConstraintViolationException("Unrecoverable ex");
+            MetaException me = new MetaException("Throwing unrecoverable 
exception to test not run jdo.");
+            me.initCause(ex);
+            throw me;
+          }
+        }.run(false);
+      } catch (MetaException ex) {
+        // expected
+      }
+      objectStore.commitTransaction();
+      Assert.assertEquals(true, runDirectSql.get());
+      Assert.assertEquals(false, runJdo.get());
     }
-    objectStore.commitTransaction();
-    Assert.assertEquals(true, runDirectSql.get());
-    Assert.assertEquals(false, runJdo.get());
   }
 
   /**

Reply via email to