-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-33587][Core]Kill the executor on nested fatal errors #30528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ import scala.collection.immutable | |
| import scala.collection.mutable.{ArrayBuffer, Map} | ||
| import scala.concurrent.duration._ | ||
|
|
||
| import com.google.common.cache.{CacheBuilder, CacheLoader} | ||
| import org.mockito.ArgumentCaptor | ||
| import org.mockito.ArgumentMatchers.{any, eq => meq} | ||
| import org.mockito.Mockito.{inOrder, verify, when} | ||
|
|
@@ -43,7 +44,7 @@ import org.apache.spark.TaskState.TaskState | |
| import org.apache.spark.broadcast.Broadcast | ||
| import org.apache.spark.internal.config._ | ||
| import org.apache.spark.internal.config.UI._ | ||
| import org.apache.spark.memory.TestMemoryManager | ||
| import org.apache.spark.memory.{SparkOutOfMemoryError, TestMemoryManager} | ||
| import org.apache.spark.metrics.MetricsSystem | ||
| import org.apache.spark.rdd.RDD | ||
| import org.apache.spark.resource.ResourceInformation | ||
|
|
@@ -52,7 +53,7 @@ import org.apache.spark.scheduler.{DirectTaskResult, FakeTask, ResultTask, Task, | |
| import org.apache.spark.serializer.{JavaSerializer, SerializerInstance, SerializerManager} | ||
| import org.apache.spark.shuffle.FetchFailedException | ||
| import org.apache.spark.storage.{BlockManager, BlockManagerId} | ||
| import org.apache.spark.util.{LongAccumulator, UninterruptibleThread} | ||
| import org.apache.spark.util.{LongAccumulator, ThreadUtils, UninterruptibleThread} | ||
|
|
||
| class ExecutorSuite extends SparkFunSuite | ||
| with LocalSparkContext with MockitoSugar with Eventually with PrivateMethodTester { | ||
|
|
@@ -402,6 +403,74 @@ class ExecutorSuite extends SparkFunSuite | |
| assert(taskMetrics.getMetricValue("JVMHeapMemory") > 0) | ||
| } | ||
|
|
||
| test("SPARK-33587: isFatalError") { | ||
| def errorInThreadPool(e: => Throwable): Throwable = { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to make this test cover the cases I mentioned in the description. |
||
| intercept[Throwable] { | ||
| val taskPool = ThreadUtils.newDaemonFixedThreadPool(1, "test") | ||
| try { | ||
| val f = taskPool.submit(new java.util.concurrent.Callable[String] { | ||
| override def call(): String = throw e | ||
| }) | ||
| f.get() | ||
| } finally { | ||
| taskPool.shutdown() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| def errorInGuavaCache(e: => Throwable): Throwable = { | ||
| val cache = CacheBuilder.newBuilder() | ||
| .build(new CacheLoader[String, String] { | ||
| override def load(key: String): String = throw e | ||
| }) | ||
| intercept[Throwable] { | ||
| cache.get("test") | ||
| } | ||
| } | ||
|
|
||
| def testThrowable( | ||
| e: => Throwable, | ||
| depthToCheck: Int, | ||
| isFatal: Boolean): Unit = { | ||
| import Executor.isFatalError | ||
| // `e`'s depth is 1 so `depthToCheck` needs to be at least 3 to detect fatal errors. | ||
| assert(isFatalError(e, depthToCheck) == (depthToCheck >= 1 && isFatal)) | ||
| // `e`'s depth is 2 so `depthToCheck` needs to be at least 3 to detect fatal errors. | ||
| assert(isFatalError(errorInThreadPool(e), depthToCheck) == (depthToCheck >= 2 && isFatal)) | ||
| assert(isFatalError(errorInGuavaCache(e), depthToCheck) == (depthToCheck >= 2 && isFatal)) | ||
| assert(isFatalError( | ||
| new SparkException("foo", e), | ||
| depthToCheck) == (depthToCheck >= 2 && isFatal)) | ||
| // `e`'s depth is 3 so `depthToCheck` needs to be at least 3 to detect fatal errors. | ||
| assert(isFatalError( | ||
| errorInThreadPool(errorInGuavaCache(e)), | ||
| depthToCheck) == (depthToCheck >= 3 && isFatal)) | ||
| assert(isFatalError( | ||
| errorInGuavaCache(errorInThreadPool(e)), | ||
| depthToCheck) == (depthToCheck >= 3 && isFatal)) | ||
| assert(isFatalError( | ||
| new SparkException("foo", new SparkException("foo", e)), | ||
| depthToCheck) == (depthToCheck >= 3 && isFatal)) | ||
| } | ||
|
|
||
| for (depthToCheck <- 0 to 5) { | ||
| testThrowable(new OutOfMemoryError(), depthToCheck, isFatal = true) | ||
| testThrowable(new InterruptedException(), depthToCheck, isFatal = false) | ||
| testThrowable(new RuntimeException("test"), depthToCheck, isFatal = false) | ||
| testThrowable(new SparkOutOfMemoryError("test"), depthToCheck, isFatal = false) | ||
| } | ||
|
|
||
| // Verify we can handle the cycle in the exception chain | ||
| val e1 = new Exception("test1") | ||
| val e2 = new Exception("test2") | ||
| e1.initCause(e2) | ||
| e2.initCause(e1) | ||
| for (depthToCheck <- 0 to 5) { | ||
| testThrowable(e1, depthToCheck, isFatal = false) | ||
| testThrowable(e2, depthToCheck, isFatal = false) | ||
| } | ||
| } | ||
|
|
||
| private def createMockEnv(conf: SparkConf, serializer: JavaSerializer): SparkEnv = { | ||
| val mockEnv = mock[SparkEnv] | ||
| val mockRpcEnv = mock[RpcEnv] | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in case, we are sure that OOM cannot be caused by a fatal error, and it cannot present somewhere in the chain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an existing behavior. #20014 added SparkOutOfMemoryError to avoid killing the executor when it's not thrown by JVM.