Tengfei Huang created SPARK-62353:
-------------------------------------
Summary: Shuffle migration during decommission restores map
outputs removed by a stage rollback
Key: SPARK-62353
URL: https://issues.apache.org/jira/browse/SPARK-62353
Project: Spark
Issue Type: Task
Components: Spark Core
Affects Versions: 4.2.1
Reporter: Tengfei Huang
h3. Problem
When a stage rollback removes all map outputs of a shuffle with
{{{}MapOutputTrackerMaster.unregisterAllMapAndMergeOutput{}}}, a shuffle block
migration (graceful executor decommission) that completes afterwards can
re-register one of the removed outputs. The resubmitted stage then skips that
partition, so consumers read a mix of outputs from before the rollback and
recomputed outputs. When the rollback is for an indeterminate stage, query
results can be wrong.
h3. Cause
# {{unregisterAllMapAndMergeOutput}} calls
{{{}ShuffleStatus.removeOutputsByFilter(_ => true){}}}, which moves every
{{MapStatus}} to {{{}mapStatusesDeleted{}}}. The shuffle stays registered and
its files stay on the executors. The callers are
{{DAGScheduler.rollbackShuffleMapStage}} (indeterminate and checksum mismatch
rollback) and the three barrier stage retry paths, and all of them need every
partition recomputed.
# A decommissioning executor keeps migrating every local shuffle index file
({{{}BlockManagerDecommissioner.refreshMigratableShuffleBlocks{}}},
{{{}IndexShuffleBlockResolver.getStoredShuffles{}}}). The rollback does not
stop it.
# When the peer stores the index block it reports it, and
{{BlockManagerMasterEndpoint.updateShuffleBlockInfo}} calls
{{{}MapOutputTrackerMaster.updateMapOutput{}}}.
{{ShuffleStatus.updateMapOutput}} finds the map id in {{mapStatusesDeleted}}
and registers the old {{MapStatus}} again at the new location. That recovery is
meant for outputs lost with an executor (SPARK-35593), but it cannot tell them
apart from outputs a rollback removed.
# The resubmitted stage gets its tasks from {{{}findMissingPartitions(){}}},
which no longer includes that partition. {{Stage.maxAttemptIdToIgnore}} and
{{ShuffleMapStage.latestFailedBarrierAttemptId}} only filter task completions,
not migration reports.
{{submitMissingTasks}} removes the outputs again right before
{{findMissingPartitions()}} when the stage being submitted is statically
indeterminate, but that does not cover:
* A checksum mismatch rollback
({{{}ShuffleDependency.checksumMismatchFullRetryEnabled{}}} is true), which
skips that step. SQL shuffles use this path by default:
{{spark.sql.shuffle.orderIndependentChecksum.enabled}} and
{{spark.sql.shuffle.orderIndependentChecksum.enableFullRetryOnMismatch}} both
default to true.
* A succeeding map stage rolled back because its parent is indeterminate. When
that stage is submitted, {{rollbackSucceedingStages}} sees it is already
rolling back for its latest attempt and does not remove its outputs again.
h3. Reproduction
In {{DAGSchedulerSuite}} on master, calling {{updateMapOutput}} the way
{{BlockManagerMasterEndpoint}} does for a migrated index block:
{code:scala}
test("migration must not restore outputs removed by a checksum mismatch
rollback") {
val rdd1 = new MyRDD(sc, 2, Nil)
val dep1 = new ShuffleDependency(rdd1, new HashPartitioner(2),
_checksumMismatchFullRetryEnabled = true)
val rdd2 = new MyRDD(sc, 2, List(dep1), tracker = mapOutputTracker)
val dep2 = new ShuffleDependency(rdd2, new HashPartitioner(2),
_checksumMismatchFullRetryEnabled = true)
submit(new MyRDD(sc, 2, List(dep2), tracker = mapOutputTracker), Array(0, 1))
completeShuffleMapStageSuccessfully(0, 0, 2, Seq("hostA", "hostA"),
checksumVal = 100)
// Stage 1 task 0 fails to fetch from hostA; task 1 registers mapId 7 on
hostB.
runEvent(makeCompletionEvent(taskSets(1).tasks(0),
FetchFailed(makeBlockManagerId("hostA"), dep1.shuffleId, 0L, 0, 0,
"ignored"), null))
runEvent(makeCompletionEvent(taskSets(1).tasks(1), Success,
makeMapStatus("hostB", 2, mapTaskId = 7), Seq.empty, Array.empty,
createFakeTaskInfoWithId(1)))
scheduler.resubmitFailedStages()
// A rerun of stage 0 reports a different checksum, so all stage 1 outputs
are removed.
runEvent(makeCompletionEvent(taskSets(2).tasks(0), Success,
makeMapStatus("hostC", 2, checksumVal = 101)))
assert(mapOutputTracker.getNumAvailableOutputs(dep2.shuffleId) == 0)
// hostB is decommissioning and finishes migrating the removed output of
mapId 7.
mapOutputTracker.updateMapOutput(dep2.shuffleId, 7L,
makeBlockManagerId("hostD"))
val numAvailableAfterMigration =
mapOutputTracker.getNumAvailableOutputs(dep2.shuffleId)
runEvent(makeCompletionEvent(taskSets(2).tasks(1), Success,
makeMapStatus("hostC", 2, checksumVal = 100)))
val retryPartitions = taskSets(3).tasks.map(_.partitionId).toSeq
assert(numAvailableAfterMigration == 0) // fails: 1
// Stage 1 must rerun every partition.
assert(retryPartitions == Seq(0, 1)) // fails: Seq(0)
}
{code}
Results with and without the {{updateMapOutput}} call between the rollback and
the retry:
||Rollback||Without the migration report||With the migration report||
|Checksum mismatch (the test above)|Stage 1 retry runs partitions 0 and
1|Partition 1 is restored; the retry runs partition 0 only|
|Statically indeterminate parent (three indeterminate map stages, as in the
SPARK-25341 test)|Stage 1 retry runs partitions 0 and 1|Partition 1 is
restored; the retry runs partition 0 only|
The existing test "SPARK-59094: retry all indeterminate barrier tasks after
$failureType and relocation" also shows the restore: it asserts that
{{findMissingPartitions}} becomes {{Seq(1)}} after the report. It passes only
because the barrier stage there is statically indeterminate and gets cleared
again when it is resubmitted.
h3. Expected behavior
A migration report must not restore an output that
{{unregisterAllMapAndMergeOutput}} removed, because the whole shuffle is going
to be recomputed. Relocations buffered in {{pendingMigratedOutputs}} before the
removal should be dropped too. Outputs lost in other ways, for example with a
decommissioned executor, should stay recoverable, and the retry's new outputs
(which have new map ids) should migrate and be recovered as before.
With {{spark.shuffle.useOldFetchProtocol=true}} the map id is the partition id,
so a report for a removed output looks the same as one for the retry. The
indeterminate rollback already fails the job under that protocol when the stage
has available outputs, but the barrier retry paths do not check the protocol.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]