GitHub user sameeragarwal opened a pull request:

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

    [SPARK-14454][SQL][1.6] Better exception handling while marking tasks as 
failed

    Backports https://github.com/apache/spark/pull/12234 to 1.6. Original 
description below:
    
    ## What changes were proposed in this pull request?
    
    This patch adds support for better handling of exceptions inside catch 
blocks if the code within the block throws an exception. For instance here is 
the code in a catch block before this change in `WriterContainer.scala`: 
    
    ```scala
    logError("Aborting task.", cause)
    // call failure callbacks first, so we could have a chance to cleanup the 
writer.
    TaskContext.get().asInstanceOf[TaskContextImpl].markTaskFailed(cause)
    if (currentWriter != null) {
      currentWriter.close()
    }
    abortTask()
    throw new SparkException("Task failed while writing rows.", cause)
    ```
    
    If `markTaskFailed` or `currentWriter.close` throws an exception, we 
currently lose the original cause. This PR fixes this problem by implementing a 
utility function `Utils.tryWithSafeCatch` that suppresses 
(`Throwable.addSuppressed`) the exception that are thrown within the catch 
block and rethrowing the original exception.
    
    ## How was this patch tested?
    
    No new functionality added

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

    $ git pull https://github.com/sameeragarwal/spark fix-exception-1.6

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

    https://github.com/apache/spark/pull/12272.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 #12272
    
----
commit 0defe220b3f6df7979483ce5959e5485e56353c6
Author: Sameer Agarwal <[email protected]>
Date:   2016-04-07T06:29:34Z

    Better exception handling while marking tasks as failed

----


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to