You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ai...@apache.org on 2017/05/08 14:26:12 UTC
hive git commit: HIVE-16450: Some metastore operations are not
retried even with desired underlining exceptions (Aihua Xu,
reviewed by Naveen Gangam & Peter Vary)
Repository: hive
Updated Branches:
refs/heads/master 54dbca69c -> 301e7c5ea
HIVE-16450: Some metastore operations are not retried even with desired underlining exceptions (Aihua Xu, reviewed by Naveen Gangam & Peter Vary)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/301e7c5e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/301e7c5e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/301e7c5e
Branch: refs/heads/master
Commit: 301e7c5eaba790687818a57d92b046f746bb3d76
Parents: 54dbca6
Author: Aihua Xu <ai...@apache.org>
Authored: Fri Apr 14 10:53:58 2017 -0400
Committer: Aihua Xu <ai...@apache.org>
Committed: Mon May 8 10:20:47 2017 -0400
----------------------------------------------------------------------
.../apache/hadoop/hive/metastore/Deadline.java | 29 ++++++-----------
.../hadoop/hive/metastore/MetaStoreUtils.java | 24 ++++++++++++++
.../hadoop/hive/metastore/ObjectStore.java | 34 ++++++++------------
.../hive/metastore/RetryingHMSHandler.java | 2 --
4 files changed, 47 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/301e7c5e/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java b/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java
index 71d336a..6149224 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java
@@ -86,15 +86,15 @@ public class Deadline {
*/
public static void resetTimeout(long timeoutMs) throws MetaException {
if (timeoutMs <= 0) {
- throw newMetaException(new DeadlineException("The reset timeout value should be " +
+ throw MetaStoreUtils.newMetaException(new DeadlineException("The reset timeout value should be " +
"larger than 0: " + timeoutMs));
}
Deadline deadline = getCurrentDeadline();
if (deadline != null) {
deadline.timeoutNanos = timeoutMs * 1000000L;
} else {
- throw newMetaException(new DeadlineException("The threadlocal Deadline is null," +
- " please register it firstly."));
+ throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," +
+ " please register it first."));
}
}
@@ -105,8 +105,8 @@ public class Deadline {
public static boolean startTimer(String method) throws MetaException {
Deadline deadline = getCurrentDeadline();
if (deadline == null) {
- throw newMetaException(new DeadlineException("The threadlocal Deadline is null," +
- " please register it firstly."));
+ throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," +
+ " please register it first."));
}
if (deadline.startTime != NO_DEADLINE) return false;
deadline.method = method;
@@ -125,8 +125,8 @@ public class Deadline {
deadline.startTime = NO_DEADLINE;
deadline.method = null;
} else {
- throw newMetaException(new DeadlineException("The threadlocal Deadline is null," +
- " please register it firstly."));
+ throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," +
+ " please register it first."));
}
}
@@ -146,7 +146,7 @@ public class Deadline {
if (deadline != null) {
deadline.check();
} else {
- throw newMetaException(new DeadlineException("The threadlocal Deadline is null," +
+ throw MetaStoreUtils.newMetaException(new DeadlineException("The threadlocal Deadline is null," +
" please register it first."));
}
}
@@ -165,18 +165,7 @@ public class Deadline {
+ (elapsedTime / 1000000L) + "ms exceeds " + (timeoutNanos / 1000000L) + "ms");
}
} catch (DeadlineException e) {
- throw newMetaException(e);
+ throw MetaStoreUtils.newMetaException(e);
}
}
-
- /**
- * convert DeadlineException to MetaException
- * @param e
- * @return
- */
- private static MetaException newMetaException(DeadlineException e) {
- MetaException metaException = new MetaException(e.getMessage());
- metaException.initCause(e);
- return metaException;
- }
}
http://git-wip-us.apache.org/repos/asf/hive/blob/301e7c5e/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
index d67e03f..870896c 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
@@ -1929,4 +1929,28 @@ public class MetaStoreUtils {
}
csNew.setStatsObj(list);
}
+
+ /**
+ * convert Exception to MetaException, which sets the cause to such exception
+ * @param e cause of the exception
+ * @return the MetaException with the specified exception as the cause
+ */
+ public static MetaException newMetaException(Exception e) {
+ return newMetaException(e != null ? e.getMessage() : null, e);
+ }
+
+ /**
+ * convert Exception to MetaException, which sets the cause to such exception
+ * @param errorMessage the error message for this MetaException
+ * @param e cause of the exception
+ * @return the MetaException with the specified exception as the cause
+ */
+ public static MetaException newMetaException(String errorMessage, Exception e) {
+ MetaException metaException = new MetaException(errorMessage);
+ if (e != null) {
+ metaException.initCause(e);
+ }
+ return metaException;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/hive/blob/301e7c5e/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index 29aa642..a83e12e 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -2737,7 +2737,7 @@ public class ObjectStore implements RawStore, Configurable {
throw ex;
} catch (Exception ex) {
LOG.error("", ex);
- throw new MetaException(ex.getMessage());
+ throw MetaStoreUtils.newMetaException(ex);
} finally {
close();
}
@@ -2767,7 +2767,7 @@ public class ObjectStore implements RawStore, Configurable {
if (ex instanceof MetaException) {
throw (MetaException)ex;
}
- throw new MetaException(ex.getMessage());
+ throw MetaStoreUtils.newMetaException(ex);
}
if (!isInTxn) {
JDOException rollbackEx = null;
@@ -3302,12 +3302,8 @@ public class ObjectStore implements RawStore, Configurable {
} finally {
if (!success) {
rollbackTransaction();
- MetaException metaException = new MetaException(
- "The transaction for alter partition did not commit successfully.");
- if (e != null) {
- metaException.initCause(e);
- }
- throw metaException;
+ throw MetaStoreUtils.newMetaException(
+ "The transaction for alter partition did not commit successfully.", e);
}
}
}
@@ -3331,12 +3327,8 @@ public class ObjectStore implements RawStore, Configurable {
} finally {
if (!success) {
rollbackTransaction();
- MetaException metaException = new MetaException(
- "The transaction for alter partition did not commit successfully.");
- if (e != null) {
- metaException.initCause(e);
- }
- throw metaException;
+ throw MetaStoreUtils.newMetaException(
+ "The transaction for alter partition did not commit successfully.", e);
}
}
}
@@ -6782,8 +6774,10 @@ public class ObjectStore implements RawStore, Configurable {
try {
List<MTableColumnStatistics> stats = getMTableColumnStatistics(table,
colNames, queryWrapper);
- for(MTableColumnStatistics cStat : stats) {
- statsMap.put(cStat.getColName(), cStat);
+ if (stats != null) {
+ for(MTableColumnStatistics cStat : stats) {
+ statsMap.put(cStat.getColName(), cStat);
+ }
}
} finally {
queryWrapper.close();
@@ -6946,7 +6940,7 @@ public class ObjectStore implements RawStore, Configurable {
if (ex instanceof MetaException) {
throw (MetaException) ex;
}
- throw new MetaException(ex.getMessage());
+ throw MetaStoreUtils.newMetaException(ex);
} finally {
if (!committed) {
rollbackTransaction();
@@ -6994,7 +6988,7 @@ public class ObjectStore implements RawStore, Configurable {
try {
List<MTableColumnStatistics> mStats = getMTableColumnStatistics(getTable(), colNames, queryWrapper);
- if (mStats.isEmpty()) return null;
+ if (mStats == null || mStats.isEmpty()) return null;
// LastAnalyzed is stored per column, but thrift object has it per multiple columns.
// Luckily, nobody actually uses it, so we will set to lowest value of all columns for now.
ColumnStatisticsDesc desc = StatObjectConverter.getTableColumnStatisticsDesc(mStats.get(0));
@@ -7184,7 +7178,7 @@ public class ObjectStore implements RawStore, Configurable {
if (ex instanceof MetaException) {
throw (MetaException) ex;
}
- throw new MetaException(ex.getMessage());
+ throw MetaStoreUtils.newMetaException(ex);
} finally {
if (!committed) {
rollbackTransaction();
@@ -7662,7 +7656,7 @@ public class ObjectStore implements RawStore, Configurable {
throw new MetaException("Version table not found. " + "The metastore is not upgraded to "
+ MetaStoreSchemaInfo.getHiveSchemaVersion());
} else {
- throw e;
+ throw MetaStoreUtils.newMetaException(e);
}
}
committed = commitTransaction();
http://git-wip-us.apache.org/repos/asf/hive/blob/301e7c5e/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
----------------------------------------------------------------------
diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
index f19ff6c..b1c8e39 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
@@ -153,8 +153,6 @@ public class RetryingHMSHandler implements InvocationHandler {
}
return new Result(object, retryCount);
- } catch (javax.jdo.JDOException e) {
- caughtException = e;
} catch (UndeclaredThrowableException e) {
if (e.getCause() != null) {
if (e.getCause() instanceof javax.jdo.JDOException) {