-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-25341][Core] Support rolling back a shuffle map stage and re-generate the shuffle files #25620
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 #25620
Changes from all commits
bbce8b4
578c233
cb612e5
f4471b2
b31d1f5
ff8fde9
2bb4388
061e363
212b201
0d91544
da73b56
69d59a1
c86f6cc
d2215b2
28c9f9c
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 |
|---|---|---|
|
|
@@ -106,7 +106,7 @@ protected void handleMessage( | |
| numBlockIds += ids.length; | ||
| } | ||
| streamId = streamManager.registerStream(client.getClientId(), | ||
| new ManagedBufferIterator(msg, numBlockIds), client.getChannel()); | ||
| new ShuffleManagedBufferIterator(msg), client.getChannel()); | ||
| } else { | ||
| // For the compatibility with the old version, still keep the support for OpenBlocks. | ||
| OpenBlocks msg = (OpenBlocks) msgObj; | ||
|
|
@@ -299,21 +299,6 @@ private int[] shuffleMapIdAndReduceIds(String[] blockIds, int shuffleId) { | |
| return mapIdAndReduceIds; | ||
| } | ||
|
|
||
| ManagedBufferIterator(FetchShuffleBlocks msg, int numBlockIds) { | ||
| final int[] mapIdAndReduceIds = new int[2 * numBlockIds]; | ||
| int idx = 0; | ||
| for (int i = 0; i < msg.mapIds.length; i++) { | ||
| for (int reduceId : msg.reduceIds[i]) { | ||
| mapIdAndReduceIds[idx++] = msg.mapIds[i]; | ||
| mapIdAndReduceIds[idx++] = reduceId; | ||
| } | ||
| } | ||
| assert(idx == 2 * numBlockIds); | ||
| size = mapIdAndReduceIds.length; | ||
| blockDataForIndexFn = index -> blockManager.getBlockData(msg.appId, msg.execId, | ||
| msg.shuffleId, mapIdAndReduceIds[index], mapIdAndReduceIds[index + 1]); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasNext() { | ||
| return index < size; | ||
|
|
@@ -328,6 +313,49 @@ public ManagedBuffer next() { | |
| } | ||
| } | ||
|
|
||
| private class ShuffleManagedBufferIterator implements Iterator<ManagedBuffer> { | ||
|
|
||
| private int mapIdx = 0; | ||
| private int reduceIdx = 0; | ||
|
|
||
| private final String appId; | ||
| private final String execId; | ||
| private final int shuffleId; | ||
| private final long[] mapIds; | ||
| private final int[][] reduceIds; | ||
|
|
||
| ShuffleManagedBufferIterator(FetchShuffleBlocks msg) { | ||
| appId = msg.appId; | ||
| execId = msg.execId; | ||
| shuffleId = msg.shuffleId; | ||
| mapIds = msg.mapIds; | ||
| reduceIds = msg.reduceIds; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasNext() { | ||
| // mapIds.length must equal to reduceIds.length, and the passed in FetchShuffleBlocks | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we add check logic here to be safe?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea if the place is not super performance critical I'd prefer a double check here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done the double-check in 00e78b2. |
||
| // must have non-empty mapIds and reduceIds, see the checking logic in | ||
| // OneForOneBlockFetcher. | ||
| assert(mapIds.length != 0 && mapIds.length == reduceIds.length); | ||
| return mapIdx < mapIds.length && reduceIdx < reduceIds[mapIdx].length; | ||
| } | ||
|
|
||
| @Override | ||
| public ManagedBuffer next() { | ||
| final ManagedBuffer block = blockManager.getBlockData( | ||
| appId, execId, shuffleId, mapIds[mapIdx], reduceIds[mapIdx][reduceIdx]); | ||
| if (reduceIdx < reduceIds[mapIdx].length - 1) { | ||
| reduceIdx += 1; | ||
| } else { | ||
| reduceIdx = 0; | ||
| mapIdx += 1; | ||
| } | ||
| metrics.blockTransferRateBytes.mark(block != null ? block.size() : 0); | ||
| return block; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void channelActive(TransportClient client) { | ||
| metrics.activeConnections.inc(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,7 @@ public ManagedBuffer getBlockData( | |
| String appId, | ||
| String execId, | ||
| int shuffleId, | ||
| int mapId, | ||
| long mapId, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xuanyuanking why change this from int to long? Is it possible that a mapId can be greater than 2^31?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previous the map id is the index of the mapper, and can get conflicts when we re-run the task. Now the map id is the task id, which is unique. task id needs to be long.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, after this patch, we set mapId by using the |
||
| int reduceId) { | ||
| ExecutorShuffleInfo executor = executors.get(new AppExecId(appId, execId)); | ||
| if (executor == null) { | ||
|
|
@@ -296,7 +296,7 @@ private void deleteNonShuffleServiceServedFiles(String[] dirs) { | |
| * and the block id format is from ShuffleDataBlockId and ShuffleIndexBlockId. | ||
| */ | ||
| private ManagedBuffer getSortBasedShuffleBlockData( | ||
| ExecutorShuffleInfo executor, int shuffleId, int mapId, int reduceId) { | ||
| ExecutorShuffleInfo executor, int shuffleId, long mapId, int reduceId) { | ||
| File indexFile = ExecutorDiskUtils.getFile(executor.localDirs, executor.subDirsPerLocalDir, | ||
| "shuffle_" + shuffleId + "_" + mapId + "_0.index"); | ||
|
|
||
|
|
||
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.
we can also remove
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.
The numBlockIds used in callback: