Repository: spark
Updated Branches:
  refs/heads/branch-1.5 6eec04e0a -> 1bba62e93


[SPARK-14149] Log exceptions in tryOrIOException

## What changes were proposed in this pull request?
We ran into a problem today debugging some class loading problem during 
deserialization, and JVM was masking the underlying exception which made it 
very difficult to debug. We can however log the exceptions using try/catch 
ourselves in serialization/deserialization. The good thing is that all these 
methods are already using Utils.tryOrIOException, so we can just put the try 
catch and logging in a single place.

## How was this patch tested?
A logging change with a manual test.

Author: Reynold Xin <r...@databricks.com>

Closes #11951 from rxin/SPARK-14149.

(cherry picked from commit 70a6f0bb57ca2248444157e2707fbcc3cb04e3bc)
Signed-off-by: Reynold Xin <r...@databricks.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/1bba62e9
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/1bba62e9
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/1bba62e9

Branch: refs/heads/branch-1.5
Commit: 1bba62e935b4b415414211247c778cafc618ad87
Parents: 6eec04e
Author: Reynold Xin <r...@databricks.com>
Authored: Fri Mar 25 01:17:23 2016 -0700
Committer: Reynold Xin <r...@databricks.com>
Committed: Fri Mar 25 01:17:41 2016 -0700

----------------------------------------------------------------------
 .../scala/org/apache/spark/util/Utils.scala     | 23 +++++---------------
 .../InsertIntoHadoopFsRelation.scala            |  8 +++----
 2 files changed, 9 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/1bba62e9/core/src/main/scala/org/apache/spark/util/Utils.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala 
b/core/src/main/scala/org/apache/spark/util/Utils.scala
index 9dce33c..993ac36 100644
--- a/core/src/main/scala/org/apache/spark/util/Utils.scala
+++ b/core/src/main/scala/org/apache/spark/util/Utils.scala
@@ -1149,21 +1149,6 @@ private[spark] object Utils extends Logging {
   }
 
   /**
-   * Execute a block of code that evaluates to Unit, re-throwing any non-fatal 
uncaught
-   * exceptions as IOException.  This is used when implementing Externalizable 
and Serializable's
-   * read and write methods, since Java's serializer will not report 
non-IOExceptions properly;
-   * see SPARK-4080 for more context.
-   */
-  def tryOrIOException(block: => Unit) {
-    try {
-      block
-    } catch {
-      case e: IOException => throw e
-      case NonFatal(t) => throw new IOException(t)
-    }
-  }
-
-  /**
    * Execute a block of code that returns a value, re-throwing any non-fatal 
uncaught
    * exceptions as IOException. This is used when implementing Externalizable 
and Serializable's
    * read and write methods, since Java's serializer will not report 
non-IOExceptions properly;
@@ -1173,8 +1158,12 @@ private[spark] object Utils extends Logging {
     try {
       block
     } catch {
-      case e: IOException => throw e
-      case NonFatal(t) => throw new IOException(t)
+      case e: IOException =>
+        logError("Exception encountered", e)
+        throw e
+      case NonFatal(e) =>
+        logError("Exception encountered", e)
+        throw new IOException(e)
     }
   }
 

http://git-wip-us.apache.org/repos/asf/spark/blob/1bba62e9/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelation.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelation.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelation.scala
index 735d52f..7a94c07 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelation.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/InsertIntoHadoopFsRelation.scala
@@ -75,11 +75,9 @@ private[sql] case class InsertIntoHadoopFsRelation(
       case (SaveMode.ErrorIfExists, true) =>
         throw new AnalysisException(s"path $qualifiedOutputPath already 
exists.")
       case (SaveMode.Overwrite, true) =>
-        Utils.tryOrIOException {
-          if (!fs.delete(qualifiedOutputPath, true /* recursively */)) {
-            throw new IOException(s"Unable to clear output " +
-              s"directory $qualifiedOutputPath prior to writing to it")
-          }
+        if (!fs.delete(qualifiedOutputPath, true /* recursively */)) {
+          throw new IOException(s"Unable to clear output " +
+            s"directory $qualifiedOutputPath prior to writing to it")
         }
         true
       case (SaveMode.Append, _) | (SaveMode.Overwrite, _) | 
(SaveMode.ErrorIfExists, false) =>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to