You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2016/06/13 23:28:25 UTC
hive git commit: HIVE-13866 : flatten callstack for directSQL errors
(Sergey Shelukhin, reviewed by Ashutosh Chauhan)
Repository: hive
Updated Branches:
refs/heads/master 00e177614 -> b3b4516ac
HIVE-13866 : flatten callstack for directSQL errors (Sergey Shelukhin, reviewed by Ashutosh Chauhan)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b3b4516a
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b3b4516a
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b3b4516a
Branch: refs/heads/master
Commit: b3b4516ac5dfc2d47011ae1550dcfa96a1290bfa
Parents: 00e1776
Author: Sergey Shelukhin <se...@apache.org>
Authored: Mon Jun 13 16:28:09 2016 -0700
Committer: Sergey Shelukhin <se...@apache.org>
Committed: Mon Jun 13 16:28:09 2016 -0700
----------------------------------------------------------------------
.../hadoop/hive/metastore/ObjectStore.java | 43 +++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/b3b4516a/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 f98de13..da188d3 100644
--- a/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -2696,7 +2696,16 @@ public class ObjectStore implements RawStore, Configurable {
}
private void handleDirectSqlError(Exception ex) throws MetaException, NoSuchObjectException {
- LOG.warn("Direct SQL failed" + (allowJdo ? ", falling back to ORM" : ""), ex);
+ String message = null;
+ try {
+ message = generateShorterMessage(ex);
+ } catch (Throwable t) {
+ message = ex.toString() + "; error building a better message: " + t.getMessage();
+ }
+ LOG.warn(message); // Don't log the exception, people just get confused.
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Full DirectSQL callstack for debugging (note: this is not an error)", ex);
+ }
if (!allowJdo) {
if (ex instanceof MetaException) {
throw (MetaException)ex;
@@ -2739,6 +2748,38 @@ public class ObjectStore implements RawStore, Configurable {
doUseDirectSql = false;
}
+ private String generateShorterMessage(Exception ex) {
+ StringBuilder message = new StringBuilder(
+ "Falling back to ORM path due to direct SQL failure (this is not an error): ");
+ Throwable t = ex;
+ StackTraceElement[] prevStack = null;
+ while (t != null) {
+ message.append(t.getMessage());
+ StackTraceElement[] stack = t.getStackTrace();
+ int uniqueFrames = stack.length - 1;
+ if (prevStack != null) {
+ int n = prevStack.length - 1;
+ while (uniqueFrames >= 0 && n >= 0 && stack[uniqueFrames].equals(prevStack[n])) {
+ uniqueFrames--; n--;
+ }
+ }
+ for (int i = 0; i <= uniqueFrames; ++i) {
+ StackTraceElement ste = stack[i];
+ message.append(" at ").append(ste);
+ if (ste.getMethodName() != null && ste.getMethodName().contains("getSqlResult")
+ && (ste.getFileName() == null || ste.getFileName().contains("ObjectStore"))) {
+ break;
+ }
+ }
+ prevStack = stack;
+ t = t.getCause();
+ if (t != null) {
+ message.append(";\n Caused by: ");
+ }
+ }
+ return message.toString();
+ }
+
public void disableDirectSql() {
this.doUseDirectSql = false;
}