Skip to content

Commit

Permalink
Fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshRosen committed Jun 2, 2016
1 parent 36536d7 commit 8f04720
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions core/src/main/scala/org/apache/spark/storage/BlockManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,14 @@ private[spark] class BlockManager(
// Look for block on disk, potentially storing it back in memory if required
if (level.useDisk) {
logDebug(s"Getting block $blockId from disk")
val bytes: ByteBuffer = diskStore.getBytes(blockId) match {
case Some(b) => b
case None =>
throw new BlockException(
blockId, s"Block $blockId not found on disk, though it should be")
val bytes: ByteBuffer = if (diskStore.contains(blockId)) {
// DiskStore.getBytes() always returns Some, so this .get() is guaranteed to be safe
diskStore.getBytes(blockId).get
} else {
// Remove the missing block so that its unavailability is reported to the driver
removeBlock(blockId)
throw new BlockException(
blockId, s"Block $blockId not found on disk, though it should be")
}
assert(0 == bytes.position())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ class BlockManagerSuite extends SparkFunSuite with Matchers with BeforeAndAfterE
// Because the BlockManager's metadata claims that the block exists (i.e. that it's present
// in at least one store), the read attempts to read it and fails when the on-disk file is
// missing.
intercept[SparkException] {
intercept[BlockException] {
readMethod(store)
}
// Subsequent read attempts will succeed; the block isn't present but we return an expected
Expand Down

0 comments on commit 8f04720

Please sign in to comment.