Skip to content

Commit 6665df6

Browse files
tsliwowiczAndrew Or
authored andcommitted
[SPARK-4006] Block Manager - Double Register Crash
This issue affects all versions since 0.7 up to (including) 1.1 In long running contexts, we encountered the situation of double register without a remove in between. The cause for that is unknown, and assumed a temp network issue. However, since the second register is with a BlockManagerId on a different port, blockManagerInfo.contains() returns false, while blockManagerIdByExecutor returns Some. This inconsistency is caught in a conditional statement that does System.exit(1), which is a huge robustness issue for us. The fix - simply remove the old id from both maps during register when this happens. We are mimicking the behavior of expireDeadHosts(), by doing local cleanup of the maps before trying to add new ones. Also - added some logging for register and unregister. https://issues.apache.org/jira/browse/SPARK-4006 Author: Tal Sliwowicz <[email protected]> Closes #2854 from tsliwowicz/branch-0.9.2-block-mgr-removal and squashes the following commits: 95ae4db [Tal Sliwowicz] [SPARK-4006] In long running contexts, we encountered the situation of double registe... 81d69f0 [Tal Sliwowicz] fixed comment efd93f2 [Tal Sliwowicz] In long running contexts, we encountered the situation of double register without a remove in between. The cause for that is unknown, and assumed a temp network issue.
1 parent 3fba7b7 commit 6665df6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class BlockManagerMasterActor(val isLocal: Boolean, conf: SparkConf) extends Act
160160
blockLocations.remove(locations)
161161
}
162162
}
163+
logInfo(s"Removing block manager $blockManagerId")
163164
}
164165

165166
private def expireDeadHosts() {
@@ -225,14 +226,18 @@ class BlockManagerMasterActor(val isLocal: Boolean, conf: SparkConf) extends Act
225226
private def register(id: BlockManagerId, maxMemSize: Long, slaveActor: ActorRef) {
226227
if (!blockManagerInfo.contains(id)) {
227228
blockManagerIdByExecutor.get(id.executorId) match {
228-
case Some(manager) =>
229-
// A block manager of the same executor already exists.
230-
// This should never happen. Let's just quit.
231-
logError("Got two different block manager registrations on " + id.executorId)
232-
System.exit(1)
229+
case Some(oldId) =>
230+
// A block manager of the same executor already exists, so remove it (assumed dead)
231+
logError("Got two different block manager registrations on same executor - "
232+
+ s" will replace old one $oldId with new one $id")
233+
removeExecutor(id.executorId)
233234
case None =>
234-
blockManagerIdByExecutor(id.executorId) = id
235235
}
236+
logInfo("Registering block manager %s with %s RAM, %s".format(
237+
id.hostPort, Utils.bytesToString(maxMemSize), id))
238+
239+
blockManagerIdByExecutor(id.executorId) = id
240+
236241
blockManagerInfo(id) = new BlockManagerMasterActor.BlockManagerInfo(
237242
id, System.currentTimeMillis(), maxMemSize, slaveActor)
238243
}

0 commit comments

Comments
 (0)