[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.
This commit is contained in:
parent
587d32012c
commit
5ad5e3486a
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue