-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25341][Core] Support rolling back a shuffle map stage and re-generate the shuffle files #24892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-25341][Core] Support rolling back a shuffle map stage and re-generate the shuffle files #24892
Changes from 5 commits
18b1a12
e7365e3
99c2b4a
122a8fe
eb5c58b
67f70a4
0e8ff21
4f9606c
8873f11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,18 @@ public void registerExecutor( | |
| executors.put(fullId, executorInfo); | ||
| } | ||
|
|
||
| /** | ||
| * Overload getBlockData with setting shuffleGenerationId to an invalid value of -1. | ||
| */ | ||
| public ManagedBuffer getBlockData( | ||
| String appId, | ||
| String execId, | ||
| int shuffleId, | ||
| int mapId, | ||
| int reduceId) { | ||
| return getBlockData(appId, execId, shuffleId, -1, mapId, reduceId); | ||
| } | ||
|
|
||
| /** | ||
| * Obtains a FileSegmentManagedBuffer from (shuffleId, mapId, reduceId). We make assumptions | ||
| * about how the hash and sort based shuffles store their data. | ||
|
|
@@ -172,14 +184,16 @@ public ManagedBuffer getBlockData( | |
| String appId, | ||
| String execId, | ||
| int shuffleId, | ||
| int shuffleGenerationId, | ||
| int mapId, | ||
| int reduceId) { | ||
| ExecutorShuffleInfo executor = executors.get(new AppExecId(appId, execId)); | ||
| if (executor == null) { | ||
| throw new RuntimeException( | ||
| String.format("Executor is not registered (appId=%s, execId=%s)", appId, execId)); | ||
| } | ||
| return getSortBasedShuffleBlockData(executor, shuffleId, mapId, reduceId); | ||
| return getSortBasedShuffleBlockData( | ||
| executor, shuffleId, shuffleGenerationId, mapId, reduceId); | ||
| } | ||
|
|
||
| public ManagedBuffer getRddBlockData( | ||
|
|
@@ -291,22 +305,29 @@ private void deleteNonShuffleServiceServedFiles(String[] dirs) { | |
| } | ||
|
|
||
| /** | ||
| * Sort-based shuffle data uses an index called "shuffle_ShuffleId_MapId_0.index" into a data file | ||
| * called "shuffle_ShuffleId_MapId_0.data". This logic is from IndexShuffleBlockResolver, | ||
| * Sort-based shuffle data uses an index called "shuffle_ShuffleId_MapId_0.index" into a data | ||
xuanyuanking marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * file called "shuffle_ShuffleId_MapId_0.data". This logic is from IndexShuffleBlockResolver, | ||
| * and the block id format is from ShuffleDataBlockId and ShuffleIndexBlockId. | ||
| * While the shuffle data and index file generated from the indeterminate stage, | ||
| * the ShuffleDataBlockId and ShuffleIndexBlockId will be extended by the shuffle generation id. | ||
| */ | ||
| private ManagedBuffer getSortBasedShuffleBlockData( | ||
| ExecutorShuffleInfo executor, int shuffleId, int mapId, int reduceId) { | ||
| ExecutorShuffleInfo executor, int shuffleId, int shuffleGenerationId, | ||
| int mapId, int reduceId) { | ||
| String baseFileName = "shuffle_" + shuffleId + "_" + mapId + "_0"; | ||
|
||
| if (shuffleGenerationId != -1) { | ||
| baseFileName = baseFileName + "_" + shuffleGenerationId; | ||
| } | ||
| File indexFile = ExecutorDiskUtils.getFile(executor.localDirs, executor.subDirsPerLocalDir, | ||
| "shuffle_" + shuffleId + "_" + mapId + "_0.index"); | ||
| baseFileName + ".index"); | ||
|
|
||
| try { | ||
| ShuffleIndexInformation shuffleIndexInformation = shuffleIndexCache.get(indexFile); | ||
| ShuffleIndexRecord shuffleIndexRecord = shuffleIndexInformation.getIndex(reduceId); | ||
| return new FileSegmentManagedBuffer( | ||
| conf, | ||
| ExecutorDiskUtils.getFile(executor.localDirs, executor.subDirsPerLocalDir, | ||
| "shuffle_" + shuffleId + "_" + mapId + "_0.data"), | ||
| ExecutorDiskUtils.getFile( | ||
| executor.localDirs, executor.subDirsPerLocalDir, baseFileName + ".data"), | ||
| shuffleIndexRecord.getOffset(), | ||
| shuffleIndexRecord.getLength()); | ||
| } catch (ExecutionException e) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * 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.shuffle; | ||
|
|
||
| import org.apache.spark.network.client.TransportClient; | ||
| import org.apache.spark.network.shuffle.protocol.BlockTransferMessage; | ||
| import org.apache.spark.network.shuffle.protocol.OpenBlocks; | ||
| import org.apache.spark.network.util.TransportConf; | ||
|
|
||
| public class OneForOneDataBlockFetcher extends OneForOneBlockFetcher { | ||
| public OneForOneDataBlockFetcher( | ||
| TransportClient client, | ||
| String appId, | ||
| String execId, | ||
| String[] blockIds, | ||
| BlockFetchingListener listener, | ||
| TransportConf transportConf, | ||
| DownloadFileManager downloadFileManager) { | ||
| super(client, appId, execId, blockIds, listener, transportConf, downloadFileManager); | ||
| } | ||
|
|
||
| /** | ||
| * Create the corresponding message for this fetcher. | ||
| * For non shuffle blocks, just use OpenBlocks message for all cases. | ||
| */ | ||
| @Override | ||
| public BlockTransferMessage createBlockTransferMessage() { | ||
| return new OpenBlocks(appId, execId, blockIds); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it mean this method can only fetch shuffle blocks? Shall we rename the method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, after the refactor e7365e3, finally, we can rename the method and split shuffle fetch and data fetch into 2 separated function, thanks for your guidance and advice!
Done in 67f70a4.