From e106cdeeffd1a1a6c7479d0f18ee4e2720a1e740 Mon Sep 17 00:00:00 2001 From: mattmccline-microsoft <84488164+mattmccline-microsoft@users.noreply.github.com> Date: Sun, 25 Jul 2021 23:02:26 -0700 Subject: [PATCH] Patch #1 Interrupted Part 1 --- .../RetryingThriftCLIServiceClient.java | 7 ++++- .../hive/metastore/RetryingHMSHandler.java | 29 +++++++++---------- .../metastore/RetryingMetaStoreClient.java | 8 ++++- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java b/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java index 20e12e1036..5aa02e69bf 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/RetryingThriftCLIServiceClient.java @@ -334,7 +334,12 @@ protected InvocationResult invokeInternal(Method method, Object[] args) throws T Object methodResult = method.invoke(base, args); result = new InvocationResult(true, methodResult, null); } catch (UndeclaredThrowableException e) { - throw e.getCause(); + // Caught when an undeclared checked exception thrown below... + Throwable cause = e.getCause(); + if (cause instanceof InterruptedException) { + throw new HiveSQLException(cause); + } + throw cause; } catch (InvocationTargetException e) { if (e.getCause() instanceof HiveSQLException) { HiveSQLException hiveExc = (HiveSQLException) e.getCause(); diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java index a830eb9b0f..69f93892eb 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java @@ -153,22 +153,21 @@ public Result invokeInternal(final Object proxy, final Method method, final Obje return new Result(object, retryCount); } catch (UndeclaredThrowableException e) { - if (e.getCause() != null) { - if (e.getCause() instanceof javax.jdo.JDOException) { - // Due to reflection, the jdo exception is wrapped in - // invocationTargetException - caughtException = e.getCause(); - } else if (e.getCause() instanceof MetaException && e.getCause().getCause() != null - && e.getCause().getCause() instanceof javax.jdo.JDOException) { - // The JDOException may be wrapped further in a MetaException - caughtException = e.getCause().getCause(); - } else { - LOG.error(ExceptionUtils.getStackTrace(e.getCause())); - throw e.getCause(); - } + // Caught when an undeclared checked exception thrown below... + Throwable cause = e.getCause(); + if (cause instanceof InterruptedException) { + throw new MetaException(ExceptionUtils.getStackTrace(cause)); + } else if (cause instanceof javax.jdo.JDOException) { + // Due to reflection, the jdo exception is wrapped in + // invocationTargetException + caughtException = cause; + } else if (cause instanceof MetaException && cause.getCause() != null + && cause.getCause() instanceof javax.jdo.JDOException) { + // The JDOException may be wrapped further in a MetaException + caughtException = cause.getCause(); } else { - LOG.error(ExceptionUtils.getStackTrace(e)); - throw e; + LOG.error(ExceptionUtils.getStackTrace(cause)); + throw cause; } } catch (InvocationTargetException e) { if (e.getCause() instanceof javax.jdo.JDOException) { diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java index f97f638ba6..9629d2ff5f 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java @@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +import org.apache.commons.lang.exception.ExceptionUtils; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.common.classification.RetrySemantics; @@ -215,7 +216,12 @@ public Object run() throws MetaException { } break; } catch (UndeclaredThrowableException e) { - throw e.getCause(); + // Caught when an undeclared checked exception thrown below... + Throwable cause = e.getCause(); + if (cause instanceof InterruptedException) { + throw new MetaException(ExceptionUtils.getStackTrace(cause)); + } + throw cause; } catch (InvocationTargetException e) { Throwable t = e.getCause(); if (t instanceof TApplicationException) { -- 2.28.0.windows.1