cloud-fan commented on code in PR #58437:
URL: https://github.com/apache/spark/pull/58437#discussion_r4565826938
##########
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:
**Nit (P3):** When a host-scope cleanup keeps only reliably stored map
output and removes no merge result, this overload now skips `incrementEpoch()`.
That is the path `handleWorkerRemoved` takes under a shuffle plugin whose
`supportsReliableStorage()` returns true and whose handles leave
`reliablyStored` empty. No test pins the skip: the host-loss test in
`MapOutputTrackerSuite` and the push-based worker-host loss test in
`DAGSchedulerSuite` both remove a merge result and expect an advance, the
non-push variant never reaches this method, and 'worker removal keeps outputs
and a FetchFailed clears only the failed shuffle' checks only output counts. If
this path went back to advancing unconditionally, every worker removal would
again make every executor drop and refetch its cached map statuses, and no test
would fail. Recording the epoch before `WorkerRemoved` in that test and
asserting it is unchanged afterwards would pin it, as 'executor loss skips
reliably-stored shuffles but not
local-disk ones' already does for the executor-scope skip.
**Verification:**
- **Regression:** With a shuffle plugin that reports reliable storage and
shuffles that set no per-shuffle value, removing a worker whose host holds only
reliably stored map output and no merge result keeps the map output registered
and leaves the map-output epoch unchanged, and the check fails when the
host-scope cleanup is changed to advance the epoch 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:
**Nit (P3):** The test mocks `supportsReliableStorage()` to true, so the
`Some(true)` shuffle keeping hostA's output agrees with the global flag rather
than overriding it; only the `Some(false)` shuffle behaves despite the flag. As
written, the comment says both handles override the flag, which misstates the
direction this test pins.
```suggestion
// Some(true) keeps hostA's output; Some(false) loses it despite the
global flag.
```
**Verification:**
- **Inspection:** The comment above the assertions in the test where a
handle reporting false overrides a true global reliable-storage flag no longer
says the handle reporting true keeps its output despite the flag, and it
matches the flag value the test configures.
--
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]