Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
03459545
Commit
03459545
authored
12 years ago
by
Patrick Wendell
Browse files
Options
Downloads
Patches
Plain Diff
SPARK-738: Spark should detect and squash nonserializable exceptions
parent
63e1999f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/executor/Executor.scala
+14
-2
14 additions, 2 deletions
core/src/main/scala/spark/executor/Executor.scala
core/src/test/scala/spark/DistributedSuite.scala
+21
-0
21 additions, 0 deletions
core/src/test/scala/spark/DistributedSuite.scala
with
35 additions
and
2 deletions
core/src/main/scala/spark/executor/Executor.scala
+
14
−
2
View file @
03459545
package
spark.executor
import
java.io.
{
File
,
FileOutputStream
}
import
java.io.
{
NotSerializableException
,
File
,
FileOutputStream
}
import
java.net.
{
URI
,
URL
,
URLClassLoader
}
import
java.util.concurrent._
...
...
@@ -123,7 +123,19 @@ private[spark] class Executor(executorId: String, slaveHostname: String, propert
case
t
:
Throwable
=>
{
val
reason
=
ExceptionFailure
(
t
)
context
.
statusUpdate
(
taskId
,
TaskState
.
FAILED
,
ser
.
serialize
(
reason
))
val
serReason
=
try
{
ser
.
serialize
(
reason
)
}
catch
{
case
e
:
NotSerializableException
=>
{
val
message
=
"Spark caught unserializable exn: "
+
t
.
toString
val
throwable
=
new
Exception
(
message
)
throwable
.
setStackTrace
(
t
.
getStackTrace
)
ser
.
serialize
(
new
ExceptionFailure
(
throwable
))
}
}
context
.
statusUpdate
(
taskId
,
TaskState
.
FAILED
,
serReason
)
// TODO: Should we exit the whole executor here? On the one hand, the failed task may
// have left some weird state around depending on when the exception was thrown, but on
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/spark/DistributedSuite.scala
+
21
−
0
View file @
03459545
...
...
@@ -18,6 +18,9 @@ import scala.collection.mutable.ArrayBuffer
import
SparkContext._
import
storage.
{
GetBlock
,
BlockManagerWorker
,
StorageLevel
}
class
NotSerializableClass
class
NotSerializableExn
(
val
notSer
:
NotSerializableClass
)
extends
Throwable
()
{}
class
DistributedSuite
extends
FunSuite
with
ShouldMatchers
with
BeforeAndAfter
with
LocalSparkContext
{
val
clusterUrl
=
"local-cluster[2,1,512]"
...
...
@@ -27,6 +30,24 @@ class DistributedSuite extends FunSuite with ShouldMatchers with BeforeAndAfter
System
.
clearProperty
(
"spark.storage.memoryFraction"
)
}
test
(
"task throws not serializable exception"
)
{
// Ensures that executors do not crash when an exn is not serializable. If executors crash,
// this test will hang. Correct behavior is that executors don't crash but fail tasks
// and the scheduler throws a SparkException.
// numSlaves must be less than numPartitions
val
numSlaves
=
3
val
numPartitions
=
10
sc
=
new
SparkContext
(
"local-cluster[%s,1,512]"
.
format
(
numSlaves
),
"test"
)
val
data
=
sc
.
parallelize
(
1
to
100
,
numPartitions
).
map
(
x
=>
(
x
,
x
)).
map
(
x
=>
throw
new
NotSerializableExn
(
new
NotSerializableClass
))
intercept
[
SparkException
]
{
data
.
count
()
}
resetSparkContext
()
}
test
(
"local-cluster format"
)
{
sc
=
new
SparkContext
(
"local-cluster[2,1,512]"
,
"test"
)
assert
(
sc
.
parallelize
(
1
to
2
,
2
).
count
()
==
2
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment