-
Notifications
You must be signed in to change notification settings - Fork 28.5k
[SPARK-15355] [CORE] Proactive block replication #14412
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
Closed
shubhamchopra
wants to merge
6
commits into
apache:master
from
shubhamchopra:ProactiveBlockReplication
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
016ea9f
Pro-actively replenishing blocks from failed executors.
shubhamchopra 16975b6
Incorporating feedback from @sameeragarwal
shubhamchopra beb9eb3
Incorporating suggestions from @JoshRosen and @sameeragarwal
shubhamchopra 275cbea
Minor correction.
shubhamchopra cee8e76
Adding assertion checks to test if all the read locks are released.
shubhamchopra 212baab
Adding delay to give enough time for replication and release of read …
shubhamchopra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import java.util.{HashMap => JHashMap} | |
import scala.collection.mutable | ||
import scala.collection.JavaConverters._ | ||
import scala.concurrent.{ExecutionContext, Future} | ||
import scala.util.Random | ||
|
||
import org.apache.spark.SparkConf | ||
import org.apache.spark.annotation.DeveloperApi | ||
|
@@ -65,6 +66,8 @@ class BlockManagerMasterEndpoint( | |
mapper | ||
} | ||
|
||
val proactivelyReplicate = conf.get("spark.storage.replication.proactive", "false").toBoolean | ||
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. Please document this new configuration in |
||
|
||
logInfo("BlockManagerMasterEndpoint up") | ||
|
||
override def receiveAndReply(context: RpcCallContext): PartialFunction[Any, Unit] = { | ||
|
@@ -195,17 +198,38 @@ class BlockManagerMasterEndpoint( | |
|
||
// Remove it from blockManagerInfo and remove all the blocks. | ||
blockManagerInfo.remove(blockManagerId) | ||
|
||
val iterator = info.blocks.keySet.iterator | ||
while (iterator.hasNext) { | ||
val blockId = iterator.next | ||
val locations = blockLocations.get(blockId) | ||
locations -= blockManagerId | ||
// De-register the block if none of the block managers have it. Otherwise, if pro-active | ||
// replication is enabled, and a block is either an RDD or a test block (the latter is used | ||
// for unit testing), we send a message to a randomly chosen executor location to replicate | ||
// the given block. Note that we ignore other block types (such as broadcast/shuffle blocks | ||
// etc.) as replication doesn't make much sense in that context. | ||
if (locations.size == 0) { | ||
blockLocations.remove(blockId) | ||
logWarning(s"No more replicas available for $blockId !") | ||
} else if (proactivelyReplicate && (blockId.isRDD || blockId.isInstanceOf[TestBlockId])) { | ||
// As a heursitic, assume single executor failure to find out the number of replicas that | ||
// existed before failure | ||
val maxReplicas = locations.size + 1 | ||
val i = (new Random(blockId.hashCode)).nextInt(locations.size) | ||
val blockLocations = locations.toSeq | ||
val candidateBMId = blockLocations(i) | ||
blockManagerInfo.get(candidateBMId).foreach { bm => | ||
val remainingLocations = locations.toSeq.filter(bm => bm != candidateBMId) | ||
val replicateMsg = ReplicateBlock(blockId, remainingLocations, maxReplicas) | ||
bm.slaveEndpoint.ask[Boolean](replicateMsg) | ||
} | ||
} | ||
} | ||
|
||
listenerBus.post(SparkListenerBlockManagerRemoved(System.currentTimeMillis(), blockManagerId)) | ||
logInfo(s"Removing block manager $blockManagerId") | ||
|
||
} | ||
|
||
private def removeExecutor(execId: String) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While I think it's still valid to replace the inequality with a strictly-less-than check, but just out of curiosity, can the number of
peersReplicatedTo
ever exceednumPeersToReplicateTo
?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.
One scenario I can think of is if an executor with the block being replicated is lost (due to say a delayed heartbeat) and joins back again. The current implementation would recognize the block manager needs to reregister and will report all blocks. The probability of this happening increases with pro-active replication, I think.