You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/16 10:42:52 UTC

[GitHub] [spark] yabola commented on a diff in pull request #38560: [WIP][SPARK-38005][core] Support cleaning up merged shuffle files and state from external shuffle service

yabola commented on code in PR #38560:
URL: https://github.com/apache/spark/pull/38560#discussion_r1023798104


##########
common/network-common/src/main/java/org/apache/spark/network/util/PushBasedShuffleUtils.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.network.util;
+
+public class PushBasedShuffleUtils {
+
+  /**
+   * Push based shuffle requires a comparable Id to distinguish the shuffle data among multiple application attempts.
+   * This variable is derived from the String typed appAttemptId. If no appAttemptId is set, the default
+   * comparableAppAttemptId is -1.
+   */
+  public static final int DEFAUT_APP_ATTEMPT_ID = -1;

Review Comment:
   Unified push based shuffle identification variables here, which will be used in yarn external shuffle service and spark core module.



##########
core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala:
##########
@@ -327,43 +327,52 @@ class BlockManagerMasterEndpoint(
       }
     }.toSeq
 
-    // Find all shuffle blocks on executors that are no longer running
-    val blocksToDeleteByShuffleService =
-      new mutable.HashMap[BlockManagerId, mutable.HashSet[BlockId]]
+    var removeShuffleFromShuffleServicesFutures = Seq.empty[Future[Boolean]]
     if (externalShuffleServiceRemoveShuffleEnabled) {
-      mapOutputTracker.shuffleStatuses.get(shuffleId).foreach { shuffleStatus =>
-        shuffleStatus.withMapStatuses { mapStatuses =>
-          mapStatuses.foreach { mapStatus =>
-            // Check if the executor has been deallocated
-            if (!blockManagerIdByExecutor.contains(mapStatus.location.executorId)) {
-              val blocksToDel =
-                shuffleManager.shuffleBlockResolver.getBlocksForShuffle(shuffleId, mapStatus.mapId)
-              if (blocksToDel.nonEmpty) {
-                val blocks = blocksToDeleteByShuffleService.getOrElseUpdate(mapStatus.location,
-                  new mutable.HashSet[BlockId])
-                blocks ++= blocksToDel
+      val shuffleClient = externalBlockStoreClient.get
+      // Find all shuffle blocks on executors that are no longer running
+      val blocksToDelete = new mutable.HashMap[BlockManagerId, mutable.HashSet[BlockId]]
+      mapOutputTracker.shuffleStatuses.get(shuffleId) match {
+        case Some(shuffleStatus) =>
+          shuffleStatus.withMapStatuses { mapStatuses =>
+            mapStatuses.foreach { mapStatus =>
+              // Check if the executor has been deallocated
+              if (!blockManagerIdByExecutor.contains(mapStatus.location.executorId)) {
+                val blocksToDel = shuffleManager.shuffleBlockResolver
+                  .getBlocksForShuffle(shuffleId, mapStatus.mapId)
+                if (blocksToDel.nonEmpty) {
+                  val blocks = blocksToDelete.getOrElseUpdate(mapStatus.location,
+                    new mutable.HashSet[BlockId])
+                  blocks ++= blocksToDel
+                }

Review Comment:
   The previous code is difficult to understand because of the scala syntax. For example, `mapOutputTracker.shuffleStatuses.get(shuffleId).**foreach**`  The **foreach** here is not actually an iterator. 
   `externalBlockStoreClient.map` the **externalBlockStoreClient**  is not actually an iterator.
   
   I didn't change the code logic, just changed the style



##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/RemoteBlockPushResolver.java:
##########
@@ -654,8 +731,7 @@ public MergeStatuses finalizeShuffleMerge(FinalizeShuffleMerge msg) {
           // If no blocks pushed for the finalizeShuffleMerge shuffleMergeId then return
           // empty MergeStatuses but cleanup the older shuffleMergeId files.
           submitCleanupTask(() ->
-              closeAndDeleteOutdatedPartitions(
-                  appAttemptShuffleMergeId, mergePartitionsInfo.shuffleMergePartitions));
+              deleteCurrentShufflePartitions(appShuffleInfo, shuffleId, appAttemptShuffleMergeId));

Review Comment:
   I checked the `appAttemptShuffleMergeId` in the code before. 
   I think if we want to delete partitions merged data, then we must delete the corresponding ShuffleMergeId in DB (Otherwise, inconsistency will occur when restoring shuffle info from db and shufflemergeid is only generated when finalized)



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org