Repository: spark Updated Branches: refs/heads/master ae4e3def5 -> be317d4a9
[SPARK-10001][CORE] Don't short-circuit actions in signal handlers ## What changes were proposed in this pull request? The current signal handlers have a subtle bug that stops evaluating registered actions as soon as one of them returns true, this is because `forall` is short-circuited. This PR adds a strict mapping stage before evaluating returned result. There are no known occurrences of the bug and this is a preemptive fix. ## How was this patch tested? As with the original introduction of signal handlers, this was tested manually (unit testing with signals is not straightforward). Author: Jakob Odersky <[email protected]> Closes #12745 from jodersky/SPARK-10001-hotfix. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/be317d4a Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/be317d4a Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/be317d4a Branch: refs/heads/master Commit: be317d4a90b3ca906fefeb438f89a09b1c7da5a8 Parents: ae4e3de Author: Jakob Odersky <[email protected]> Authored: Wed Apr 27 22:46:43 2016 -0700 Committer: Reynold Xin <[email protected]> Committed: Wed Apr 27 22:46:43 2016 -0700 ---------------------------------------------------------------------- core/src/main/scala/org/apache/spark/util/SignalUtils.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/be317d4a/core/src/main/scala/org/apache/spark/util/SignalUtils.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/org/apache/spark/util/SignalUtils.scala b/core/src/main/scala/org/apache/spark/util/SignalUtils.scala index 9479d8f..5a24965 100644 --- a/core/src/main/scala/org/apache/spark/util/SignalUtils.scala +++ b/core/src/main/scala/org/apache/spark/util/SignalUtils.scala @@ -92,9 +92,11 @@ private[spark] object SignalUtils extends Logging { // register old handler, will receive incoming signals while this handler is running Signal.handle(signal, prevHandler) - // run all actions, escalate to parent handler if no action catches the signal - // (i.e. all actions return false) - val escalate = actions.asScala.forall { action => !action() } + // Run all actions, escalate to parent handler if no action catches the signal + // (i.e. all actions return false). Note that calling `map` is to ensure that + // all actions are run, `forall` is short-circuited and will stop evaluating + // after reaching a first false predicate. + val escalate = actions.asScala.map(action => action()).forall(_ == false) if (escalate) { prevHandler.handle(sig) } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
