Skip to content

Conversation

@holdenk
Copy link
Contributor

@holdenk holdenk commented Jun 20, 2015

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: I think this should be "propagates".

@JoshRosen
Copy link
Contributor

Thanks for fixing this; the test looks good to me, but I think we might want to preserve the old behavior of also performing error cleanup when Throwables are thrown (i.e. by using the success flag idiom that I used before, but perhaps with a comment this time to explain what's going on).

@holdenk
Copy link
Contributor Author

holdenk commented Jun 20, 2015

Sounds like a good plan.

@holdenk
Copy link
Contributor Author

holdenk commented Jun 20, 2015

Would it not make more sense to just catch/rethrow throwables? (That way if fail during cleanup we can pass back an exception indicating that cleanup failed + the underlying cause as well)?

@JoshRosen
Copy link
Contributor

I think that my concern was that wrapping a Throwable with a cause and re-throwing it might not be safe in general because catchers higher up the stack would then receive a different exception than the original Throwable, which might lead to problems if the throwable was an Error that's treated specially (e.g. ThreadDeath).

I suppose one approach would be to not re-wrap the Throwable when re-throwing. but AFAIK the compiler will complain if you re-throw Throwable in a method that doesn't declare that it throws Throwable. I think there's a reference for this in Guava's Throwables documentation: https://code.google.com/p/guava-libraries/wiki/ThrowablesExplained. It looks like this is a Java 6-ism, though, since Java 7 seems to allow this type of re-throwing: https://stackoverflow.com/questions/7428966/how-does-the-correct-rethrow-code-look-like-for-this-example

It looks like Java 7 provides us with a nice way to handle this with try-with-resources (see https://stuartmarks.wordpress.com/2011/07/21/a-new-java-exception-handling-idiom/), but I don't think we can use this here as long as we want to backport this fix to 1.4.1, which still must build for Java 6.

I think that's why I originally decided to go with the finally block, although I guess I should have added more try blocks to guard against errors during the cleanup itself.

@SparkQA
Copy link

SparkQA commented Jun 20, 2015

Test build #35360 has finished for PR 6918 at commit e503b8c.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 21, 2015

Test build #35375 has finished for PR 6918 at commit 30e558d.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 21, 2015

Test build #35376 has finished for PR 6918 at commit 039d620.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could potentially use Utils.tryWithSafeFinally, which does this sort of annoying "try/catch in a try/catch" thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class, along with a lot of the other Tungsten code, is written in Java, so we can't use Utils.tryWithSafeFinally here.

@SparkQA
Copy link

SparkQA commented Jun 22, 2015

Test build #35422 has finished for PR 6918 at commit 855f9aa.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we log in the else branch to make sure that the error is never silently swallowed?

@JoshRosen
Copy link
Contributor

LGTM pending Jenkins; thanks!

@SparkQA
Copy link

SparkQA commented Jun 23, 2015

Test build #35528 has finished for PR 6918 at commit f807832.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@JoshRosen
Copy link
Contributor

Merging this to master and branch-1.4.

asfgit pushed a commit that referenced this pull request Jun 23, 2015
…e writer

Author: Holden Karau <holden@pigscanfly.ca>

Closes #6918 from holdenk/SPARK-8498-fix-npe-in-errorhandling-path-in-unsafeshuffle-writer and squashes the following commits:

f807832 [Holden Karau] Log error if we can't throw it
855f9aa [Holden Karau] Spelling - not my strongest suite. Fix Propegates to Propagates.
039d620 [Holden Karau] Add missing closeandwriteoutput
30e558d [Holden Karau] go back to try/finally
e503b8c [Holden Karau] Improve the test to ensure we aren't masking the underlying exception
ae0b7a7 [Holden Karau] Fix the test
2e6abf7 [Holden Karau] Be more cautious when cleaning up during failed write and re-throw user exceptions

(cherry picked from commit 0f92be5)
Signed-off-by: Josh Rosen <joshrosen@databricks.com>
@asfgit asfgit closed this in 0f92be5 Jun 23, 2015
@JoshRosen
Copy link
Contributor

Dammit, I just realized that the catch Exception added in the latest commit will break compilation under Java 6 in branch-1.4 :(. I'm going to revert in branch-1.4 and will just push a hotfix later to address this (using either Guava or Unsafe to handle re-throw).

nemccarthy pushed a commit to nemccarthy/spark that referenced this pull request Jun 25, 2015
…e writer

Author: Holden Karau <holden@pigscanfly.ca>

Closes apache#6918 from holdenk/SPARK-8498-fix-npe-in-errorhandling-path-in-unsafeshuffle-writer and squashes the following commits:

f807832 [Holden Karau] Log error if we can't throw it
855f9aa [Holden Karau] Spelling - not my strongest suite. Fix Propegates to Propagates.
039d620 [Holden Karau] Add missing closeandwriteoutput
30e558d [Holden Karau] go back to try/finally
e503b8c [Holden Karau] Improve the test to ensure we aren't masking the underlying exception
ae0b7a7 [Holden Karau] Fix the test
2e6abf7 [Holden Karau] Be more cautious when cleaning up during failed write and re-throw user exceptions

(cherry picked from commit 0f92be5)
Signed-off-by: Josh Rosen <joshrosen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants