-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-3277] Fix external spilling with LZ4 assertion error #2187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
QA tests have started for PR 2187 at commit
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cool trick I used in YarnSparkHadoopUtilSuite is to do something like this:
def spillingTest(name: String)(testFn: => Unit) = test(name) {
blah blah blah testFn() blah
}
Then you can register like this:
spillingTest("spilling with null keys and values") {
// body of testSpillingWithNullKeysAndValues
}
Would look a little bit cleaner overall, but no biggie.
|
LGTM, kinda skimmed through the tests since it looked like most changes were changing |
|
QA tests have finished for PR 2187 at commit
|
|
QA tests have started for PR 2187 at commit
|
**Summary of the changes** The bulk of this PR is comprised of tests and documentation; the actual fix is really just adding 1 line of code (see `BlockObjectWriter.scala`). We currently do not run the `External*` test suites with different compression codecs, and this would have caught the bug reported in [SPARK-3277](https://issues.apache.org/jira/browse/SPARK-3277). This PR extends the existing code to test spilling using all compression codecs known to Spark, including `LZ4`. **The bug itself** In `DiskBlockObjectWriter`, we only report the shuffle bytes written before we close the streams. With `LZ4`, all the bytes written reported by our metrics were 0 because `flush()` was not taking effect for some reason. In general, compression codecs may write additional bytes to the file after we call `close()`, and so we must also capture those bytes in our shuffle write metrics. Thanks mridulm and pwendell for help with debugging. Author: Andrew Or <[email protected]> Author: Patrick Wendell <[email protected]> Closes #2187 from andrewor14/fix-lz4-spilling and squashes the following commits: 1b54bdc [Andrew Or] Speed up tests by not compressing everything 1c4624e [Andrew Or] Merge branch 'master' of github.com:apache/spark into fix-lz4-spilling 6b2e7d1 [Andrew Or] Fix compilation error 92e251b [Patrick Wendell] Better documentation for BlockObjectWriter. a1ad536 [Andrew Or] Fix tests 089593f [Andrew Or] Actually fix SPARK-3277 (tests still fail) 4bbcf68 [Andrew Or] Update tests to actually test all compression codecs b264a84 [Andrew Or] ExternalAppendOnlyMapSuite code style fixes (minor) 1bfa743 [Andrew Or] Add more information to assert for better debugging
|
QA tests have finished for PR 2187 at commit
|
|
This change looks incorrect. Since this was a blocker, would have been better to not rush into committing it. |
|
Hi @mridulm
Hmmm, maybe it's my unfamiliarity with the innards here, but why would you call close or revert after you've already committed and closed the writer? (Perhaps close() could be made idempotent, but that would just protect against buggy code?) |
|
A closed writer can be reverted in case some other writer's close fails in the shuffle group and we have to revert the entire group. Yes, close should be idempotent - which is not the case here : each close will add to metrics |
|
After a second look, close seems to be idempotent (albeit not thread-safe, but that's ok?). So it seems that the only problem is not updating |
|
Maybe I'm missing something, but I don't see a way for the writer to be reverted after |
|
I don't have my workspace handy, but search for revert usages ... That
|
|
Writers are not thread safe, so that is fine. But this is slightly involved code reused in various forms; with extremely
|
**Summary of the changes** The bulk of this PR is comprised of tests and documentation; the actual fix is really just adding 1 line of code (see `BlockObjectWriter.scala`). We currently do not run the `External*` test suites with different compression codecs, and this would have caught the bug reported in [SPARK-3277](https://issues.apache.org/jira/browse/SPARK-3277). This PR extends the existing code to test spilling using all compression codecs known to Spark, including `LZ4`. **The bug itself** In `DiskBlockObjectWriter`, we only report the shuffle bytes written before we close the streams. With `LZ4`, all the bytes written reported by our metrics were 0 because `flush()` was not taking effect for some reason. In general, compression codecs may write additional bytes to the file after we call `close()`, and so we must also capture those bytes in our shuffle write metrics. Thanks mridulm and pwendell for help with debugging. Author: Andrew Or <[email protected]> Author: Patrick Wendell <[email protected]> Closes apache#2187 from andrewor14/fix-lz4-spilling and squashes the following commits: 1b54bdc [Andrew Or] Speed up tests by not compressing everything 1c4624e [Andrew Or] Merge branch 'master' of github.com:apache/spark into fix-lz4-spilling 6b2e7d1 [Andrew Or] Fix compilation error 92e251b [Patrick Wendell] Better documentation for BlockObjectWriter. a1ad536 [Andrew Or] Fix tests 089593f [Andrew Or] Actually fix SPARK-3277 (tests still fail) 4bbcf68 [Andrew Or] Update tests to actually test all compression codecs b264a84 [Andrew Or] ExternalAppendOnlyMapSuite code style fixes (minor) 1bfa743 [Andrew Or] Add more information to assert for better debugging
Summary of the changes
The bulk of this PR is comprised of tests and documentation; the actual fix is really just adding 1 line of code (see
BlockObjectWriter.scala). We currently do not run theExternal*test suites with different compression codecs, and this would have caught the bug reported in SPARK-3277. This PR extends the existing code to test spilling using all compression codecs known to Spark, includingLZ4.The bug itself
In
DiskBlockObjectWriter, we only report the shuffle bytes written before we close the streams. WithLZ4, all the bytes written reported by our metrics were 0 becauseflush()was not taking effect for some reason. In general, compression codecs may write additional bytes to the file after we callclose(), and so we must also capture those bytes in our shuffle write metrics.Thanks @mridulm and @pwendell for help with debugging.