Skip to content

Commit

Permalink
[SPARK-6843][core]Add volatile for the "state"
Browse files Browse the repository at this point in the history
Fix potential visibility problem for the "state" of Executor

The field of "state" is shared and modified by multiple threads. i.e:

```scala
Within ExecutorRunner.scala

(1) workerThread = new Thread("ExecutorRunner for " + fullId) {
  override def run() { fetchAndRunExecutor() }
}
 workerThread.start()
// Shutdown hook that kills actors on shutdown.

(2)shutdownHook = new Thread() {
  override def run() {
    killProcess(Some("Worker shutting down"))
  }
}

(3)and also the "Actor thread" for worker.

```
I think we should at lease add volatile to ensure the visibility among threads otherwise the worker might send an out-of-date status to the master.

https://issues.apache.org/jira/browse/SPARK-6843

Author: lisurprise <[email protected]>

Closes apache#5448 from zhichao-li/state and squashes the following commits:

a2386e7 [lisurprise] add volatile for state field
  • Loading branch information
zhichao-li authored and srowen committed Apr 12, 2015
1 parent e9445b1 commit ddc1743
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private[deploy] class ExecutorRunner(
val workerUrl: String,
conf: SparkConf,
val appLocalDirs: Seq[String],
var state: ExecutorState.Value)
@volatile var state: ExecutorState.Value)
extends Logging {

private val fullId = appId + "/" + execId
Expand Down

0 comments on commit ddc1743

Please sign in to comment.