Skip to content
Snippets Groups Projects
Commit 5ad5e348 authored by Raymond Liu's avatar Raymond Liu Committed by Reynold Xin
Browse files

[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 <raymond.liu@intel.com>

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.
parent 587d3201
No related branches found
No related tags found
No related merge requests found
......@@ -363,6 +363,13 @@ private[spark] class BlockManager(
val info = blockInfo.get(blockId).orNull
if (info != null) {
info.synchronized {
// Double check to make sure the block is still there, since removeBlock
// method also synchronizes on BlockInfo object, so the block might have
// been removed when we actually come here.
if (blockInfo.get(blockId).isEmpty) {
logDebug(s"Block $blockId had been removed")
return None
}
// If another thread is writing the block, wait for it to become ready.
if (!info.waitForReady()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment