From 00fb077cb2fc3590fd7c15af9fdd1fa8b799dff0 Mon Sep 17 00:00:00 2001 From: zhoukang Date: Sat, 9 Sep 2017 09:00:56 +0800 Subject: [PATCH 1/3] [SPARK-21902][CORE] Print root cause for BlockManager#doPut --- .../main/scala/org/apache/spark/storage/BlockManager.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/scala/org/apache/spark/storage/BlockManager.scala b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala index aaacabe79ace..9968a48647bd 100644 --- a/core/src/main/scala/org/apache/spark/storage/BlockManager.scala +++ b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala @@ -988,6 +988,12 @@ private[spark] class BlockManager( logWarning(s"Putting block $blockId failed") } res + } catch { + // Since removeBlockInternal may throw exception, + // we should print exception first to show root cause. + case e: Throwable => + logWarning(s"Putting block $blockId failed due to exception $e.") + throw e } finally { // This cleanup is performed in a finally block rather than a `catch` to avoid having to // catch and properly re-throw InterruptedException. From 86525f7f7cb5c2656008ba92c44c724db186158e Mon Sep 17 00:00:00 2001 From: zhoukang Date: Sat, 9 Sep 2017 11:53:12 +0800 Subject: [PATCH 2/3] Remove duplicate logging --- core/src/main/scala/org/apache/spark/storage/BlockManager.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/storage/BlockManager.scala b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala index 9968a48647bd..f42681ac5e92 100644 --- a/core/src/main/scala/org/apache/spark/storage/BlockManager.scala +++ b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala @@ -998,7 +998,6 @@ private[spark] class BlockManager( // This cleanup is performed in a finally block rather than a `catch` to avoid having to // catch and properly re-throw InterruptedException. if (exceptionWasThrown) { - logWarning(s"Putting block $blockId failed due to an exception") // If an exception was thrown then it's possible that the code in `putBody` has already // notified the master about the availability of this block, so we need to send an update // to remove this block location. From a3ed8b38879bd017b9c9b2081cec81987e7e33ef Mon Sep 17 00:00:00 2001 From: zhoukang Date: Fri, 15 Sep 2017 11:44:34 +0800 Subject: [PATCH 3/3] Use NonFatal instead of Throwable --- core/src/main/scala/org/apache/spark/storage/BlockManager.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/storage/BlockManager.scala b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala index f42681ac5e92..b4b5938c307e 100644 --- a/core/src/main/scala/org/apache/spark/storage/BlockManager.scala +++ b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala @@ -991,7 +991,7 @@ private[spark] class BlockManager( } catch { // Since removeBlockInternal may throw exception, // we should print exception first to show root cause. - case e: Throwable => + case NonFatal(e) => logWarning(s"Putting block $blockId failed due to exception $e.") throw e } finally {