Skip to content

Commit 5ad5e34

Browse files
colorantrxin
authored andcommitted
[SPARK-2162] Double check in doGetLocal to avoid read on removed block.
other wise, it will either read in vain in memory level case, or throw exception in disk level case when it believe the block is there while actually it had been removed. Author: Raymond Liu <[email protected]> Closes #1103 from colorant/bm and squashes the following commits: daac114 [Raymond Liu] Address comments d1ea287 [Raymond Liu] Double check in doGetLocal to avoid read on removed block.
1 parent 587d320 commit 5ad5e34

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/scala/org/apache/spark/storage/BlockManager.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ private[spark] class BlockManager(
363363
val info = blockInfo.get(blockId).orNull
364364
if (info != null) {
365365
info.synchronized {
366+
// Double check to make sure the block is still there, since removeBlock
367+
// method also synchronizes on BlockInfo object, so the block might have
368+
// been removed when we actually come here.
369+
if (blockInfo.get(blockId).isEmpty) {
370+
logDebug(s"Block $blockId had been removed")
371+
return None
372+
}
366373

367374
// If another thread is writing the block, wait for it to become ready.
368375
if (!info.waitForReady()) {

0 commit comments

Comments
 (0)