[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2019-12-20 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r360627566
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError("Uncaught OutOfMemoryError in thread " + thread + ", process 
halted.", oom)
 
 Review comment:
   thanks for the suggestion!  modded accordingly.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2019-12-20 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r360627600
 
 

 ##
 File path: 
core/src/test/scala/org/apache/spark/util/SparkUncaughtExceptionHandlerSuite.scala
 ##
 @@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.util
+
+import java.io.File
+
+import org.apache.spark.SparkFunSuite
+
+class SparkUncaughtExceptionSuite extends SparkFunSuite {
+
+  private val sparkHome =
+sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!"))
+
+  // creates a spark-class process that invokes the exception thrower
+  // the testcases will detect the process's exit code
+  def getThrowerProcess(exceptionThrower: Any, exitOnUncaughtException: 
Boolean): Process = {
+Utils.executeCommand(
+  Seq(s"$sparkHome/bin/spark-class",
+exceptionThrower.getClass.getCanonicalName.dropRight(1), // drops the 
"$" at the end
+if (exitOnUncaughtException) "true" else "false"),
 
 Review comment:
   thanks for the suggestion!  modded accordingly.
   also changed to use .toBoolean for converting string to boolean.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2019-12-20 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r360627627
 
 

 ##
 File path: 
core/src/test/scala/org/apache/spark/util/SparkUncaughtExceptionHandlerSuite.scala
 ##
 @@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.util
+
+import java.io.File
+
+import org.apache.spark.SparkFunSuite
+
+class SparkUncaughtExceptionSuite extends SparkFunSuite {
+
+  private val sparkHome =
+sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!"))
+
+  // creates a spark-class process that invokes the exception thrower
+  // the testcases will detect the process's exit code
+  def getThrowerProcess(exceptionThrower: Any, exitOnUncaughtException: 
Boolean): Process = {
+Utils.executeCommand(
+  Seq(s"$sparkHome/bin/spark-class",
+exceptionThrower.getClass.getCanonicalName.dropRight(1), // drops the 
"$" at the end
+if (exitOnUncaughtException) "true" else "false"),
+  new File(sparkHome),
+  Map("SPARK_TESTING" -> "1", "SPARK_HOME" -> sparkHome))
+  }
+
+  test("SPARK-30310: Test uncaught RuntimeException, exitOnUncaughtException = 
true") {
+val process = getThrowerProcess(RuntimeExceptionThrower, 
exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.UNCAUGHT_EXCEPTION)
+  }
+
+  test("SPARK-30310: Test uncaught RuntimeException, exitOnUncaughtException = 
false") {
+val process = getThrowerProcess(RuntimeExceptionThrower, 
exitOnUncaughtException = false)
+assert(process.waitFor == 0)
+  }
+
+  test("SPARK-30310: Test uncaught OutOfMemoryError, exitOnUncaughtException = 
true") {
+val process = getThrowerProcess(OutOfMemoryErrorThrower, 
exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+  test("SPARK-30310: Test uncaught OutOfMemoryError, exitOnUncaughtException = 
false") {
+val process = getThrowerProcess(OutOfMemoryErrorThrower, 
exitOnUncaughtException = false)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException, 
exitOnUncaughtException = true") {
+val process = getThrowerProcess(SparkFatalExceptionThrower, 
exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.UNCAUGHT_EXCEPTION)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException, 
exitOnUncaughtException = false") {
+val process = getThrowerProcess(SparkFatalExceptionThrower, 
exitOnUncaughtException = false)
+assert(process.waitFor == 0)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException (OOM), 
exitOnUncaughtException = true") {
+val process = getThrowerProcess(SparkFatalExceptionWithOOMThrower,
+  exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException (OOM), 
exitOnUncaughtException = false") {
+val process = getThrowerProcess(SparkFatalExceptionWithOOMThrower,
+  exitOnUncaughtException = false)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+}
+
+// a thread that uses SparkUncaughtExceptionHandler, then throws the throwable
+class ThrowableThrowerThread(t: Throwable,
+exitOnUncaughtException: Boolean) extends Thread {
+  override def run() {
+Thread.setDefaultUncaughtExceptionHandler(
+  new SparkUncaughtExceptionHandler(exitOnUncaughtException))
+throw t
+  }
+}
+
+// Objects to be invoked by spark-class for different Throwable types
+// that SparkUncaughtExceptionHandler handles.  spark-class will exit with
+// exit code dictated by either SparkUncaughtExceptionHandler (SparkExitCode)
+// or main() (0)
+
+object RuntimeExceptionThrower {
+  def main(args: Array[String]): Unit = {
+val t = new ThrowableThrowerThread(new RuntimeException, if (args(0) == 
"true") true else false)
+t.start()
+t.join()
+System.exit(0)
+  }
+}
+
+object OutOfMemoryErrorThrower {
+  def main(args: Array[String]): Unit = {
+val t = new ThrowableThrowerThread(new OutOfMemoryError, if (args(0) == 
"true")

[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-06 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363475923
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
 
 Review comment:
   Thanks for the comment.  
   
   Well the reason why for the logError is because it wasn't obvious to users 
or devs why the worker would just disappeared as DEAD on the UI, and there was 
nothing in the worker log file to tell what happened.  We couldn't find out why 
until we set SPARK_NO_DAEMONIZE=1 and examined the exit code.
   
   Is there any alternative to indicate the process halted unexpectedly?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363790772
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
 
 Review comment:
   Thanks for the comment.
   
   But the `ShutdownHookManager.inShutdown()` call in the try block could also 
trigger another exception though, at least in theory?
   
   But yes I agree, if the logError triggers it in the try then doing another 
logError in the catch won't do any good.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363963250
 
 

 ##
 File path: 
core/src/test/scala/org/apache/spark/util/SparkUncaughtExceptionHandlerSuite.scala
 ##
 @@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.util
+
+import java.io.File
+
+import scala.util.Try
+
+import org.apache.spark.SparkFunSuite
+
+class SparkUncaughtExceptionHandlerSuite extends SparkFunSuite {
+
+  private val sparkHome =
+sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!"))
+
+  // creates a spark-class process that invokes the exception thrower
+  // the testcases will detect the process's exit code
+  def getThrowerProcess(exceptionThrower: Any, exitOnUncaughtException: 
Boolean): Process = {
+Utils.executeCommand(
+  Seq(s"$sparkHome/bin/spark-class",
+exceptionThrower.getClass.getCanonicalName.dropRight(1), // drops the 
"$" at the end
+exitOnUncaughtException.toString),
+  new File(sparkHome),
+  Map("SPARK_TESTING" -> "1", "SPARK_HOME" -> sparkHome))
+  }
+
+  test("SPARK-30310: Test uncaught RuntimeException, exitOnUncaughtException = 
true") {
 
 Review comment:
   Thanks for the suggestion!   Modified as such.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363963188
 
 

 ##
 File path: 
core/src/test/scala/org/apache/spark/util/SparkUncaughtExceptionHandlerSuite.scala
 ##
 @@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.util
+
+import java.io.File
+
+import scala.util.Try
+
+import org.apache.spark.SparkFunSuite
+
+class SparkUncaughtExceptionHandlerSuite extends SparkFunSuite {
+
+  private val sparkHome =
+sys.props.getOrElse("spark.test.home", fail("spark.test.home is not set!"))
+
+  // creates a spark-class process that invokes the exception thrower
+  // the testcases will detect the process's exit code
+  def getThrowerProcess(exceptionThrower: Any, exitOnUncaughtException: 
Boolean): Process = {
+Utils.executeCommand(
+  Seq(s"$sparkHome/bin/spark-class",
+exceptionThrower.getClass.getCanonicalName.dropRight(1), // drops the 
"$" at the end
+exitOnUncaughtException.toString),
+  new File(sparkHome),
+  Map("SPARK_TESTING" -> "1", "SPARK_HOME" -> sparkHome))
+  }
+
+  test("SPARK-30310: Test uncaught RuntimeException, exitOnUncaughtException = 
true") {
+val process = getThrowerProcess(RuntimeExceptionThrower, 
exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.UNCAUGHT_EXCEPTION)
+  }
+
+  test("SPARK-30310: Test uncaught RuntimeException, exitOnUncaughtException = 
false") {
+val process = getThrowerProcess(RuntimeExceptionThrower, 
exitOnUncaughtException = false)
+assert(process.waitFor == 0)
+  }
+
+  test("SPARK-30310: Test uncaught OutOfMemoryError, exitOnUncaughtException = 
true") {
+val process = getThrowerProcess(OutOfMemoryErrorThrower, 
exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+  test("SPARK-30310: Test uncaught OutOfMemoryError, exitOnUncaughtException = 
false") {
+val process = getThrowerProcess(OutOfMemoryErrorThrower, 
exitOnUncaughtException = false)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException, 
exitOnUncaughtException = true") {
+val process = getThrowerProcess(SparkFatalExceptionThrower, 
exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.UNCAUGHT_EXCEPTION)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException, 
exitOnUncaughtException = false") {
+val process = getThrowerProcess(SparkFatalExceptionThrower, 
exitOnUncaughtException = false)
+assert(process.waitFor == 0)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException (OOM), 
exitOnUncaughtException = true") {
+val process = getThrowerProcess(SparkFatalExceptionWithOOMThrower,
+  exitOnUncaughtException = true)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+  test("SPARK-30310: Test uncaught SparkFatalException (OOM), 
exitOnUncaughtException = false") {
+val process = getThrowerProcess(SparkFatalExceptionWithOOMThrower,
+  exitOnUncaughtException = false)
+assert(process.waitFor == SparkExitCode.OOM)
+  }
+
+}
+
+// a thread that uses SparkUncaughtExceptionHandler, then throws the throwable
+class ThrowableThrowerThread(t: Throwable,
+exitOnUncaughtException: Boolean) extends Thread {
+  override def run() {
+Thread.setDefaultUncaughtExceptionHandler(
+  new SparkUncaughtExceptionHandler(exitOnUncaughtException))
+throw t
+  }
+}
+
+// Objects to be invoked by spark-class for different Throwable types
+// that SparkUncaughtExceptionHandler handles.  spark-class will exit with
+// exit code dictated by either:
+// - SparkUncaughtExceptionHandler (SparkExitCode)
+// - main() (0, or -1 when args is empty)
+
+object RuntimeExceptionThrower {
 
 Review comment:
   Thanks for the suggestion!   Modified as such.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about th

[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363790772
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
 
 Review comment:
   Thanks for the comment.
   
   But the `ShutdownHookManager.inShutdown()` call in the try block could also 
trigger another exception though, at least in theory?  In that case I believe 
the logError in Throwable would log it OK.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363966736
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
 
 Review comment:
   I agree if it were the logError in the try block that triggers another 
exception then doing another logError won't do any good.  But for other cases 
where logError still works, it would provide better debugging messages.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r363993038
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
 
 Review comment:
   Thanks for the comment!  How about something like this?  Consider if we get 
there we don't really care why logError fails.
   
   ```
   try { logError(s"Uncaught OutOfMemoryError in thread $thread, 
process halted.", oom) }
   catch { case _: Throwable => }
   Runtime.getRuntime.halt(SparkExitCode.OOM)
   ```
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r364045750
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,17 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
 
 Review comment:
   Thanks @srowen and @HeartSaVioR, I'll make that into the next commit.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-07 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r364059159
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,24 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+try { logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom) }
 
 Review comment:
   I actually agree!  Will modify.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] Resolve missing match case in SparkUncaughtExceptionHandler and added tests

2020-01-09 Thread GitBox
tinhto-000 commented on a change in pull request #26955: [SPARK-30310] [Core] 
Resolve missing match case in SparkUncaughtExceptionHandler and added tests
URL: https://github.com/apache/spark/pull/26955#discussion_r364773098
 
 

 ##
 File path: 
core/src/main/scala/org/apache/spark/util/SparkUncaughtExceptionHandler.scala
 ##
 @@ -48,11 +48,28 @@ private[spark] class SparkUncaughtExceptionHandler(val 
exitOnUncaughtException:
 System.exit(SparkExitCode.OOM)
   case _ if exitOnUncaughtException =>
 System.exit(SparkExitCode.UNCAUGHT_EXCEPTION)
+  case _ =>
+// SPARK-30310: Don't System.exit() when exitOnUncaughtException 
is false
 }
   }
 } catch {
-  case oom: OutOfMemoryError => Runtime.getRuntime.halt(SparkExitCode.OOM)
-  case t: Throwable => 
Runtime.getRuntime.halt(SparkExitCode.UNCAUGHT_EXCEPTION_TWICE)
+  case oom: OutOfMemoryError =>
+try {
+  logError(s"Uncaught OutOfMemoryError in thread $thread, process 
halted.", oom)
+}
+catch {
 
 Review comment:
   Done! :-)


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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