Repository: spark
Updated Branches:
refs/heads/branch-1.1 f0c571760 -> abdb90bd7
[SPARK-4097] Fix the race condition of 'thread'
There is a chance that `thread` is null when calling `thread.interrupt()`.
```Scala
override def cancel(): Unit = this.synchronized {
_cancelled = true
if (thread != null) {
thread.interrupt()
}
}
```
Should put `thread = null` into a `synchronized` block to fix the race
condition.
Author: zsxwing <[email protected]>
Closes #2957 from zsxwing/SPARK-4097 and squashes the following commits:
edf0aee [zsxwing] Add comments to explain the lock
c5cfeca [zsxwing] Fix the race condition of 'thread'
(cherry picked from commit e7fd80413d531e23b6c4def0ee32e52a39da36fa)
Signed-off-by: Reynold Xin <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/abdb90bd
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/abdb90bd
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/abdb90bd
Branch: refs/heads/branch-1.1
Commit: abdb90bd7ef1f9d84d63b001b7a305c577b8e0f2
Parents: f0c5717
Author: zsxwing <[email protected]>
Authored: Wed Oct 29 14:42:50 2014 -0700
Committer: Reynold Xin <[email protected]>
Committed: Wed Oct 29 14:43:48 2014 -0700
----------------------------------------------------------------------
core/src/main/scala/org/apache/spark/FutureAction.scala | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/abdb90bd/core/src/main/scala/org/apache/spark/FutureAction.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/FutureAction.scala
b/core/src/main/scala/org/apache/spark/FutureAction.scala
index 1e4dec8..3bbf1aa 100644
--- a/core/src/main/scala/org/apache/spark/FutureAction.scala
+++ b/core/src/main/scala/org/apache/spark/FutureAction.scala
@@ -190,7 +190,11 @@ class ComplexFutureAction[T] extends FutureAction[T] {
} catch {
case e: Exception => p.failure(e)
} finally {
- thread = null
+ // This lock guarantees when calling `thread.interrupt()` in `cancel`,
+ // thread won't be set to null.
+ ComplexFutureAction.this.synchronized {
+ thread = null
+ }
}
}
this
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]