venkata91 commented on code in PR #58437:
URL: https://github.com/apache/spark/pull/58437#discussion_r4569828472


##########
core/src/main/scala/org/apache/spark/MapOutputTracker.scala:
##########
@@ -1045,19 +1103,76 @@ private[spark] class MapOutputTrackerMaster(
    * Removes all shuffle outputs associated with this host. Note that this 
will also remove
    * outputs which are served by an external shuffle server (if one exists).
    */
-  def removeOutputsOnHost(host: String): Unit = {
-    shuffleStatuses.valuesIterator.foreach { _.removeOutputsOnHost(host) }
-    incrementEpoch()
-  }
+  def removeOutputsOnHost(host: String): Unit =
+    removeOutputsOnHost(host, respectReliablyStored = false)
 
   /**
    * Removes all shuffle outputs associated with this executor. Note that this 
will also remove
    * outputs which are served by an external shuffle server (if one exists), 
as they are still
    * registered with this execId.
    */
-  def removeOutputsOnExecutor(execId: String): Unit = {
-    shuffleStatuses.valuesIterator.foreach { _.removeOutputsOnExecutor(execId) 
}
-    incrementEpoch()
+  def removeOutputsOnExecutor(execId: String): Unit =
+    removeOutputsOnExecutor(execId, respectReliablyStored = false)
+
+  /** Like `removeOutputsOnHost(host)`, but keeps reliably-stored map output 
if asked. */
+  def removeOutputsOnHost(host: String, respectReliablyStored: Boolean): 
CleanupOutcome =
+    removeOutputsOnHost(host, respectReliablyStored, None)
+
+  /** See `removeSelectively` for `failedShuffleId` and 
`restrictToFailedShuffle`. */
+  def removeOutputsOnHost(
+      host: String,
+      respectReliablyStored: Boolean,
+      failedShuffleId: Option[Int],
+      restrictToFailedShuffle: Boolean = false): CleanupOutcome = {
+    val outcome = removeSelectively(
+      respectReliablyStored, failedShuffleId, restrictToFailedShuffle)(
+      (status, respect) => status.removeOutputsOnHost(host, respect))
+    if (outcome.shouldBumpEpoch) incrementEpoch()

Review Comment:
   good catch. the worker removal test now records the epoch before 
WorkerRemoved and checks it's unchanged after, in 34282f5. checked it fails if 
the host cleanup bumps unconditionally.
   



##########
core/src/test/scala/org/apache/spark/scheduler/DAGSchedulerSuite.scala:
##########
@@ -1116,11 +1132,545 @@ class DAGSchedulerSuite extends SparkFunSuite with 
TempLocalSparkContext with Ti
     completeShuffleMapStageSuccessfully(0, 0, 1)
     runEvent(ExecutorLost("hostA-exec", event))
     verify(blockManagerMaster, times(1)).removeExecutorAsync("hostA-exec")
-    verify(mapOutputTracker, times(0)).removeOutputsOnExecutor("hostA-exec")
+    verify(mapOutputTracker, times(0)).removeOutputsOnExecutor("hostA-exec", 
true)
     assert(mapOutputTracker.getMapSizesByExecutorId(shuffleId, 
0).map(_._1).toSet ===
       HashSet(makeBlockManagerId("hostA"), makeBlockManagerId("hostB")))
   }
 
+  /** Runs a job over one reliably-stored shuffle (service off) and completes 
its map stage. */
+  private def submitReliableShuffleJob(
+      numMaps: Int,
+      numReduces: Int,
+      hostNames: Seq[String] = Nil): (Int, ReliablyStoredShuffleDependency) = {
+    conf.set(config.SHUFFLE_SERVICE_ENABLED.key, "false")
+    val shuffleMapRdd = new MyRDD(sc, numMaps, Nil)
+    val shuffleDep =
+      new ReliablyStoredShuffleDependency(shuffleMapRdd, new 
HashPartitioner(numReduces))
+    val reduceRdd = new MyRDD(sc, numReduces, List(shuffleDep), tracker = 
mapOutputTracker)
+    val jobId = submit(reduceRdd, (0 until numReduces).toArray)
+    val stageId = scheduler.shuffleIdToMapStage(shuffleDep.shuffleId).id
+    completeShuffleMapStageSuccessfully(stageId, 0, numReduces, hostNames = 
hostNames)
+    (jobId, shuffleDep)
+  }
+
+  test("SPARK-59138: executor loss keeps a reliably-stored shuffle but drops a 
local-disk one") {
+    // No external shuffle service, so only the reliably-stored shuffle 
survives executor loss.
+    conf.set(config.SHUFFLE_SERVICE_ENABLED.key, "false")
+
+    val reliableRdd = new MyRDD(sc, 2, Nil)
+    val reliableDep = new ReliablyStoredShuffleDependency(reliableRdd, new 
HashPartitioner(1))
+    val localRdd = new MyRDD(sc, 2, Nil)
+    val localDep = new ShuffleDependency(localRdd, new HashPartitioner(1))
+    val reduceRdd = new MyRDD(sc, 1, List(reliableDep, localDep), tracker = 
mapOutputTracker)
+    submit(reduceRdd, Array(0))
+
+    // Two independent map stages, one per shuffle; complete both on hostA / 
hostB.
+    completeShuffleMapStageSuccessfully(0, 0, 1)
+    completeShuffleMapStageSuccessfully(1, 0, 1)
+
+    runEvent(ExecutorLost("hostA-exec", ExecutorKilled))
+    verify(mapOutputTracker, times(1)).removeOutputsOnExecutor("hostA-exec", 
true)
+
+    // Reliable shuffle keeps hostA's output; local-disk shuffle loses it.
+    assert(mapOutputTracker.getMapSizesByExecutorId(reliableDep.shuffleId, 
0).map(_._1).toSet ===
+      HashSet(makeBlockManagerId("hostA"), makeBlockManagerId("hostB")))
+    intercept[MetadataFetchFailedException] {
+      mapOutputTracker.getMapSizesByExecutorId(localDep.shuffleId, 0)
+    }
+  }
+
+  test("SPARK-59138: per-shuffle reliablyStored=false overrides a global 
supportsReliableStorage") {
+    // Global flag true, but one shuffle reports Some(false); the per-shuffle 
value must win.
+    conf.set(config.SHUFFLE_SERVICE_ENABLED.key, "false")
+    conf.set(config.SHUFFLE_IO_PLUGIN_CLASS.key,
+      classOf[TestShuffleDataIOWithMockedComponents].getName)
+    when(sc.shuffleDriverComponents.supportsReliableStorage()).thenReturn(true)
+
+    val reliableRdd = new MyRDD(sc, 2, Nil)
+    val reliableDep = new ReliablyStoredShuffleDependency(reliableRdd, new 
HashPartitioner(1))
+    val fallbackRdd = new MyRDD(sc, 2, Nil)
+    val fallbackDep =
+      new ReliablyStoredShuffleDependency(fallbackRdd, new HashPartitioner(1), 
Some(false))
+    val reduceRdd = new MyRDD(sc, 1, List(reliableDep, fallbackDep), tracker = 
mapOutputTracker)
+    submit(reduceRdd, Array(0))
+
+    completeShuffleMapStageSuccessfully(0, 0, 1)
+    completeShuffleMapStageSuccessfully(1, 0, 1)
+
+    runEvent(ExecutorLost("hostA-exec", ExecutorKilled))
+
+    // Some(true) keeps hostA's output despite the global flag; Some(false) 
loses it despite it.

Review Comment:
   took the suggestion, 34282f5.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to