You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by andrewor14 <gi...@git.apache.org> on 2014/05/13 20:38:36 UTC

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

GitHub user andrewor14 opened a pull request:

    https://github.com/apache/spark/pull/759

    [SPARK-1816] LiveListenerBus dies if a listener throws an exception

    The solution is to wrap a try / catch / log around the posting of each event to each listener.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/andrewor14/spark listener-die

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/759.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #759
    
----
commit 0df0e2a2395715f25ba637097500f7df117bb9a0
Author: Andrew Or <an...@gmail.com>
Date:   2014-05-13T18:34:46Z

    Try/catch and log exceptions when posting events

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43032248
  
    Merged build finished. All automated tests passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43001369
  
    Merged build finished. All automated tests passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/759#discussion_r12601376
  
    --- Diff: core/src/test/scala/org/apache/spark/scheduler/SparkListenerSuite.scala ---
    @@ -377,4 +411,12 @@ class SparkListenerSuite extends FunSuite with LocalSparkContext with ShouldMatc
           startedGettingResultTasks += taskGettingResult.taskInfo.index
         }
       }
    +
    +  /**
    +   * A simple listener that throws an exception on job end.
    +   */
    +  private class BadListener extends SparkListener {
    +    override def onJobEnd(jobEnd: SparkListenerJobEnd) = { 1 / 0 }
    --- End diff --
    
    I'd recommend just throwing some exception instead.
    
    (Not the case with Scala apparently, but I've seen Java compilers that issue a compile-time error when you do that.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-42996604
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/759#discussion_r12614769
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/SparkListenerBus.scala ---
    @@ -34,38 +36,48 @@ private[spark] trait SparkListenerBus {
       }
     
       /**
    -   * Post an event to all attached listeners. This does nothing if the event is
    -   * SparkListenerShutdown.
    +   * Post an event to all attached listeners.
    +   * This does nothing if the event is SparkListenerShutdown.
        */
       def postToAll(event: SparkListenerEvent) {
         event match {
           case stageSubmitted: SparkListenerStageSubmitted =>
    -        sparkListeners.foreach(_.onStageSubmitted(stageSubmitted))
    +        foreachListener(_.onStageSubmitted(stageSubmitted))
           case stageCompleted: SparkListenerStageCompleted =>
    -        sparkListeners.foreach(_.onStageCompleted(stageCompleted))
    +        foreachListener(_.onStageCompleted(stageCompleted))
           case jobStart: SparkListenerJobStart =>
    -        sparkListeners.foreach(_.onJobStart(jobStart))
    +        foreachListener(_.onJobStart(jobStart))
           case jobEnd: SparkListenerJobEnd =>
    -        sparkListeners.foreach(_.onJobEnd(jobEnd))
    +        foreachListener(_.onJobEnd(jobEnd))
           case taskStart: SparkListenerTaskStart =>
    -        sparkListeners.foreach(_.onTaskStart(taskStart))
    +        foreachListener(_.onTaskStart(taskStart))
           case taskGettingResult: SparkListenerTaskGettingResult =>
    -        sparkListeners.foreach(_.onTaskGettingResult(taskGettingResult))
    +        foreachListener(_.onTaskGettingResult(taskGettingResult))
           case taskEnd: SparkListenerTaskEnd =>
    -        sparkListeners.foreach(_.onTaskEnd(taskEnd))
    +        foreachListener(_.onTaskEnd(taskEnd))
           case environmentUpdate: SparkListenerEnvironmentUpdate =>
    -        sparkListeners.foreach(_.onEnvironmentUpdate(environmentUpdate))
    +        foreachListener(_.onEnvironmentUpdate(environmentUpdate))
           case blockManagerAdded: SparkListenerBlockManagerAdded =>
    -        sparkListeners.foreach(_.onBlockManagerAdded(blockManagerAdded))
    +        foreachListener(_.onBlockManagerAdded(blockManagerAdded))
           case blockManagerRemoved: SparkListenerBlockManagerRemoved =>
    -        sparkListeners.foreach(_.onBlockManagerRemoved(blockManagerRemoved))
    +        foreachListener(_.onBlockManagerRemoved(blockManagerRemoved))
           case unpersistRDD: SparkListenerUnpersistRDD =>
    -        sparkListeners.foreach(_.onUnpersistRDD(unpersistRDD))
    +        foreachListener(_.onUnpersistRDD(unpersistRDD))
           case applicationStart: SparkListenerApplicationStart =>
    -        sparkListeners.foreach(_.onApplicationStart(applicationStart))
    +        foreachListener(_.onApplicationStart(applicationStart))
           case applicationEnd: SparkListenerApplicationEnd =>
    -        sparkListeners.foreach(_.onApplicationEnd(applicationEnd))
    +        foreachListener(_.onApplicationEnd(applicationEnd))
           case SparkListenerShutdown =>
         }
       }
    +
    +  /**
    +   * Apply the given function to all attached listeners, catching and logging any exception.
    +   */
    +  private def foreachListener(f: SparkListener => Unit): Unit = {
    +    sparkListeners.foreach { listener =>
    --- End diff --
    
    Ok. It's not that bad if you have an editor, but yeah otherwise it's a little hard to understand.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43000073
  
    Merged build finished. All automated tests passed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43032250
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14953/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43000075
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14944/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-42995350
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43026540
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-42996617
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by pwendell <gi...@git.apache.org>.
Github user pwendell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/759#discussion_r12607103
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/SparkListenerBus.scala ---
    @@ -34,38 +36,48 @@ private[spark] trait SparkListenerBus {
       }
     
       /**
    -   * Post an event to all attached listeners. This does nothing if the event is
    -   * SparkListenerShutdown.
    +   * Post an event to all attached listeners.
    +   * This does nothing if the event is SparkListenerShutdown.
        */
       def postToAll(event: SparkListenerEvent) {
         event match {
           case stageSubmitted: SparkListenerStageSubmitted =>
    -        sparkListeners.foreach(_.onStageSubmitted(stageSubmitted))
    +        foreachListener(_.onStageSubmitted(stageSubmitted))
           case stageCompleted: SparkListenerStageCompleted =>
    -        sparkListeners.foreach(_.onStageCompleted(stageCompleted))
    +        foreachListener(_.onStageCompleted(stageCompleted))
           case jobStart: SparkListenerJobStart =>
    -        sparkListeners.foreach(_.onJobStart(jobStart))
    +        foreachListener(_.onJobStart(jobStart))
           case jobEnd: SparkListenerJobEnd =>
    -        sparkListeners.foreach(_.onJobEnd(jobEnd))
    +        foreachListener(_.onJobEnd(jobEnd))
           case taskStart: SparkListenerTaskStart =>
    -        sparkListeners.foreach(_.onTaskStart(taskStart))
    +        foreachListener(_.onTaskStart(taskStart))
           case taskGettingResult: SparkListenerTaskGettingResult =>
    -        sparkListeners.foreach(_.onTaskGettingResult(taskGettingResult))
    +        foreachListener(_.onTaskGettingResult(taskGettingResult))
           case taskEnd: SparkListenerTaskEnd =>
    -        sparkListeners.foreach(_.onTaskEnd(taskEnd))
    +        foreachListener(_.onTaskEnd(taskEnd))
           case environmentUpdate: SparkListenerEnvironmentUpdate =>
    -        sparkListeners.foreach(_.onEnvironmentUpdate(environmentUpdate))
    +        foreachListener(_.onEnvironmentUpdate(environmentUpdate))
           case blockManagerAdded: SparkListenerBlockManagerAdded =>
    -        sparkListeners.foreach(_.onBlockManagerAdded(blockManagerAdded))
    +        foreachListener(_.onBlockManagerAdded(blockManagerAdded))
           case blockManagerRemoved: SparkListenerBlockManagerRemoved =>
    -        sparkListeners.foreach(_.onBlockManagerRemoved(blockManagerRemoved))
    +        foreachListener(_.onBlockManagerRemoved(blockManagerRemoved))
           case unpersistRDD: SparkListenerUnpersistRDD =>
    -        sparkListeners.foreach(_.onUnpersistRDD(unpersistRDD))
    +        foreachListener(_.onUnpersistRDD(unpersistRDD))
           case applicationStart: SparkListenerApplicationStart =>
    -        sparkListeners.foreach(_.onApplicationStart(applicationStart))
    +        foreachListener(_.onApplicationStart(applicationStart))
           case applicationEnd: SparkListenerApplicationEnd =>
    -        sparkListeners.foreach(_.onApplicationEnd(applicationEnd))
    +        foreachListener(_.onApplicationEnd(applicationEnd))
           case SparkListenerShutdown =>
         }
       }
    +
    +  /**
    +   * Apply the given function to all attached listeners, catching and logging any exception.
    +   */
    +  private def foreachListener(f: SparkListener => Unit): Unit = {
    +    sparkListeners.foreach { listener =>
    --- End diff --
    
    To remove a few layers of indirection, maybe this could just have a `try {} catch {}`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by pwendell <gi...@git.apache.org>.
Github user pwendell commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43028424
  
    Thanks for this fix @andrewor14 - Jenkins, test this please.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43028484
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43001370
  
    All automated tests passed.
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14945/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/759#discussion_r12601499
  
    --- Diff: core/src/test/scala/org/apache/spark/scheduler/SparkListenerSuite.scala ---
    @@ -377,4 +411,12 @@ class SparkListenerSuite extends FunSuite with LocalSparkContext with ShouldMatc
           startedGettingResultTasks += taskGettingResult.taskInfo.index
         }
       }
    +
    +  /**
    +   * A simple listener that throws an exception on job end.
    +   */
    +  private class BadListener extends SparkListener {
    +    override def onJobEnd(jobEnd: SparkListenerJobEnd) = { 1 / 0 }
    --- End diff --
    
    I see. My compiler didn't get mad at me, but I guess it's safer if I throw an exception. I'll update this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43027177
  
    
    Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14951/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-42995373
  
    Merged build started. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43026531
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43027176
  
    Merged build finished. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/759#issuecomment-43028479
  
     Merged build triggered. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] spark pull request: [SPARK-1816] LiveListenerBus dies if a listene...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/759


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---