holdenk commented on a change in pull request #28708: URL: https://github.com/apache/spark/pull/28708#discussion_r435555809
########## File path: core/src/main/scala/org/apache/spark/storage/BlockManager.scala ########## @@ -1790,6 +1822,108 @@ private[spark] class BlockManager( } } + private class ShuffleMigrationRunnable(peer: BlockManagerId) extends Runnable { + @volatile var running = true + override def run(): Unit = { + var migrating: Option[(Int, Long)] = None + val storageLevel = StorageLevel( + useDisk = true, + useMemory = false, + useOffHeap = false, + deserialized = false, + replication = 1) + logInfo(s"Starting migration thread for ${peer}") + // Once a block fails to transfer to an executor stop trying to transfer more blocks + try { + while (running) { + val migrating = Option(shufflesToMigrate.poll()) + migrating match { + case None => + logInfo("Nothing to migrate") + // Nothing to do right now, but maybe a transfer will fail or a new block + // will finish being committed. + val SLEEP_TIME_SECS = 1 + Thread.sleep(SLEEP_TIME_SECS * 1000L) + case Some((shuffleId, mapId)) => + logInfo(s"Trying to migrate shuffle ${shuffleId},${mapId} to ${peer}") + val blocks = + migratableResolver.getMigrationBlocks(shuffleId, mapId) + logInfo(s"Got migration sub-blocks ${blocks}") + blocks.foreach { case (blockId, buffer) => + logInfo(s"Migrating sub-block ${blockId}") + blockTransferService.uploadBlockSync( + peer.host, + peer.port, + peer.executorId, + blockId, + buffer, + storageLevel, + null)// class tag, we don't need for shuffle + logInfo(s"Migrated sub block ${blockId}") + } + logInfo(s"Migrated ${shuffleId},${mapId} to ${peer}") Review comment: We don't delete the file from the current host right away. Once the BlockUpdate message is processed on the master it will go to the peer it has been migrated to. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org