Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17942#discussion_r116063045
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/Task.scala ---
    @@ -115,26 +115,33 @@ private[spark] abstract class Task[T](
               case t: Throwable =>
                 e.addSuppressed(t)
             }
    +        context.markTaskCompleted(Some(e))
             throw e
         } finally {
    -      // Call the task completion callbacks.
    -      context.markTaskCompleted()
           try {
    -        Utils.tryLogNonFatalError {
    -          // Release memory used by this thread for unrolling blocks
    -          
SparkEnv.get.blockManager.memoryStore.releaseUnrollMemoryForThisTask(MemoryMode.ON_HEAP)
    -          
SparkEnv.get.blockManager.memoryStore.releaseUnrollMemoryForThisTask(MemoryMode.OFF_HEAP)
    -          // Notify any tasks waiting for execution memory to be freed to 
wake up and try to
    -          // acquire memory again. This makes impossible the scenario 
where a task sleeps forever
    -          // because there are no other tasks left to notify it. Since 
this is safe to do but may
    -          // not be strictly necessary, we should revisit whether we can 
remove this in the future.
    -          val memoryManager = SparkEnv.get.memoryManager
    -          memoryManager.synchronized { memoryManager.notifyAll() }
    -        }
    +        // Call the task completion callbacks. If "markTaskCompleted" is 
called twice, the second
    +        // one is no-op.
    +        context.markTaskCompleted(None)
    --- End diff --
    
    > We end up calling markTaskCompleted twice when there is an exception 
thrown, right ?
    
    Yes.
    
    > Perhaps do this one when no Throwable is thrown.
    
    Then if `context.markTaskCompleted(None)` throws an exception, 
`context.markTaskFailed(e)` will be called, so TaskFailureListener may be 
called after TaskCompletionListener. This is a slight behavior change. Not sure 
if it's safe. Someone may depend on the order of calling listeners?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to