From 274c2f0e7f4c20816c2983d54f43b173a95656a8 Mon Sep 17 00:00:00 2001 From: mattmccline-microsoft <84488164+mattmccline-microsoft@users.noreply.github.com> Date: Mon, 26 Jul 2021 00:23:44 -0700 Subject: [PATCH] Patch #1 Interrupted Part 1 Master --- .../RetryingThriftCLIServiceClient.java | 7 ++++- .../metastore/RetryingMetaStoreClient.java | 8 ++++- .../hive/metastore/RetryingHMSHandler.java | 29 +++++++++---------- 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/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java index 6eadf19462..beca4a4fc1 100644 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/RetryingMetaStoreClient.java @@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; +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; @@ -221,7 +222,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) { diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java index 17ba8f834e..cd48b21d62 100644 --- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java +++ b/standalone-metastore/metastore-server/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) { -- 2.28.0.windows.1