-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-3151] [Block Manager] DiskStore.getBytes fails for files larger than 2GB #18855
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
Changes from all commits
fc3f1d7
8468738
1580449
c5028f5
908c786
67f4259
8338b4e
4a320e6
5a5c344
6cbe8d0
f6fb9e9
0e3cd82
a911c85
c877dcf
8be899f
732073c
d0c98a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,18 +50,18 @@ class DiskStoreSuite extends SparkFunSuite { | |
| val diskStoreMapped = new DiskStore(conf.clone().set(confKey, "0"), diskBlockManager, | ||
| securityManager) | ||
| diskStoreMapped.putBytes(blockId, byteBuffer) | ||
| val mapped = diskStoreMapped.getBytes(blockId).asInstanceOf[ByteBufferBlockData].buffer | ||
| val mapped = diskStoreMapped.getBytes(blockId).toByteBuffer() | ||
| assert(diskStoreMapped.remove(blockId)) | ||
|
|
||
| val diskStoreNotMapped = new DiskStore(conf.clone().set(confKey, "1m"), diskBlockManager, | ||
| securityManager) | ||
| diskStoreNotMapped.putBytes(blockId, byteBuffer) | ||
| val notMapped = diskStoreNotMapped.getBytes(blockId).asInstanceOf[ByteBufferBlockData].buffer | ||
| val notMapped = diskStoreNotMapped.getBytes(blockId).toByteBuffer() | ||
|
|
||
| // Not possible to do isInstanceOf due to visibility of HeapByteBuffer | ||
| assert(notMapped.getChunks().forall(_.getClass.getName.endsWith("HeapByteBuffer")), | ||
| assert(notMapped.getClass.getName.endsWith("HeapByteBuffer"), | ||
| "Expected HeapByteBuffer for un-mapped read") | ||
| assert(mapped.getChunks().forall(_.isInstanceOf[MappedByteBuffer]), | ||
| assert(mapped.isInstanceOf[MappedByteBuffer], | ||
| "Expected MappedByteBuffer for mapped read") | ||
|
|
||
| def arrayFromByteBuffer(in: ByteBuffer): Array[Byte] = { | ||
|
|
@@ -70,8 +70,8 @@ class DiskStoreSuite extends SparkFunSuite { | |
| array | ||
| } | ||
|
|
||
| assert(Arrays.equals(mapped.toArray, bytes)) | ||
| assert(Arrays.equals(notMapped.toArray, bytes)) | ||
| assert(Arrays.equals(new ChunkedByteBuffer(mapped).toArray, bytes)) | ||
| assert(Arrays.equals(new ChunkedByteBuffer(notMapped).toArray, bytes)) | ||
| } | ||
|
|
||
| test("block size tracking") { | ||
|
|
@@ -92,6 +92,44 @@ class DiskStoreSuite extends SparkFunSuite { | |
| assert(diskStore.getSize(blockId) === 0L) | ||
| } | ||
|
|
||
| test("blocks larger than 2gb") { | ||
| val conf = new SparkConf() | ||
| .set("spark.storage.memoryMapLimitForTests", "10k" ) | ||
| val diskBlockManager = new DiskBlockManager(conf, deleteFilesOnStop = true) | ||
| val diskStore = new DiskStore(conf, diskBlockManager, new SecurityManager(conf)) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove this empty line |
||
| val blockId = BlockId("rdd_1_2") | ||
| diskStore.put(blockId) { chan => | ||
| val arr = new Array[Byte](1024) | ||
| for { | ||
| _ <- 0 until 20 | ||
| } { | ||
| val buf = ByteBuffer.wrap(arr) | ||
| while (buf.hasRemaining()) { | ||
| chan.write(buf) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val blockData = diskStore.getBytes(blockId) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kiszk, this is the test case I was referring to. |
||
| assert(blockData.size == 20 * 1024) | ||
|
|
||
| val chunkedByteBuffer = blockData.toChunkedByteBuffer(ByteBuffer.allocate) | ||
| val chunks = chunkedByteBuffer.chunks | ||
| assert(chunks.size === 2) | ||
| for (chunk <- chunks) { | ||
| assert(chunk.limit === 10 * 1024) | ||
| } | ||
|
|
||
| val e = intercept[IllegalArgumentException]{ | ||
| blockData.toByteBuffer() | ||
| } | ||
|
|
||
| assert(e.getMessage === | ||
| s"requirement failed: can't create a byte buffer of size ${blockData.size}" + | ||
| " since it exceeds 10.0 KB.") | ||
| } | ||
|
|
||
| test("block data encryption") { | ||
| val testDir = Utils.createTempDir() | ||
| val testData = new Array[Byte](128 * 1024) | ||
|
|
||
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.
we will still hit the 2g limitation here, I'm wondering which end-to-end use cases are affected by it.
Uh oh!
There was an error while loading. Please reload this page.
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.
indeed.
I chose to postpone the failure from
DiskStroe.getBytesto this place as I believe it introduces no regression while still allowing the more common 'streaming' like use-case.further more, I think this plays well with the comment about future deprecation of
org.apache.spark.network.buffer.ManagedBuffer#nioByteBufferwhich seems to be the main reason forBlockDataexposing thetoByteBuffermethod.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.
@cloud-fan
it took me roughly 4 hours, but I looked both at the shuffle cod path and at
BlockManager.getRemoteBytes:it seems the first is robust to large blocks by using Netty's stream capabilities,
the later seems to be broken as it's not using the Netty's streaming capabilities and actually tries to copy the result buffer into a heap based buffer. I think this deserves its own JIRA/PR.
I think these two places plus the external shuffle server cover most of the relevant use cases (aside from local caching which i believe this PR completes in terms of being 2GB proof).