Skip to content

Conversation

@rdblue
Copy link
Contributor

@rdblue rdblue commented Jul 7, 2016

What changes were proposed in this pull request?

This uses the try/finally pattern to ensure streams are closed after use. UnsafeShuffleWriter wasn't closing compression streams, causing them to leak resources until garbage collected. This was causing a problem with codecs that use off-heap memory.

How was this patch tested?

Current tests are sufficient. This should not change behavior.

ByteStreams.copy(partitionInputStream, mergedFileOutputStream);
innerThrewException = false;
} finally {
Closeables.close(partitionInputStream, innerThrewException);
Copy link
Member

Choose a reason for hiding this comment

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

Not that it matters much, but what about also using the Utils.tryWithSafeFinally pattern here for some consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the usual equivalent for Java code.

Copy link
Member

Choose a reason for hiding this comment

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

Oh duh it's Java. I have made that mistake about 10 times now

@SparkQA
Copy link

SparkQA commented Jul 7, 2016

Test build #61916 has finished for PR 14093 at commit 14ba621.

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

This adds an option to LimitedInputStream to not close the underlying
stream when it is reused, which is the case in UnsafeShuffleWriter.
@SparkQA
Copy link

SparkQA commented Jul 7, 2016

Test build #61926 has finished for PR 14093 at commit 601f934.

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

left -= skipped;
return skipped;
}
@Override
Copy link
Contributor

Choose a reason for hiding this comment

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

add a blank line here?

@rxin
Copy link
Contributor

rxin commented Jul 8, 2016

cc @JoshRosen

@JoshRosen
Copy link
Contributor

LGTM pending Jenkins.

@SparkQA
Copy link

SparkQA commented Jul 8, 2016

Test build #61988 has finished for PR 14093 at commit 661539f.

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

@rxin
Copy link
Contributor

rxin commented Jul 8, 2016

Merging in master/2.0.

@asfgit asfgit closed this in 67e085e Jul 8, 2016
asfgit pushed a commit that referenced this pull request Jul 8, 2016
## What changes were proposed in this pull request?

This uses the try/finally pattern to ensure streams are closed after use. `UnsafeShuffleWriter` wasn't closing compression streams, causing them to leak resources until garbage collected. This was causing a problem with codecs that use off-heap memory.

## How was this patch tested?

Current tests are sufficient. This should not change behavior.

Author: Ryan Blue <blue@apache.org>

Closes #14093 from rdblue/SPARK-16420-unsafe-shuffle-writer-leak.

(cherry picked from commit 67e085e)
Signed-off-by: Reynold Xin <rxin@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.

5 participants