Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
df48e01
LIHADOOP-48527 Magnet shuffle service block transfer netty protocol
Victsm May 9, 2020
6472267
LIHADOOP-53438 Using different appId for the tests in RemoteBlockPush…
otterc May 12, 2020
1c78e1d
LIHADOOP-53496 Not logging all block push exceptions on the client
otterc May 15, 2020
71f3246
LIHADOOP-53700 Separate configuration for caching the merged index fi…
zhouyejoe Jun 1, 2020
221178f
LIHADOOP-53940 Logging the data file and index file path when shuffle…
otterc Jun 10, 2020
55b4a5f
LIHADOOP-54059 LIHADOOP-53496 Handle the inconsistencies between loc…
otterc Jun 15, 2020
f9d0e86
LIHADOOP-54379 Sorting the disks both on shuffle service and executors
otterc Jun 24, 2020
548e2c0
LIHADOOP-52494 Magnet fallback to origin shuffle blocks when fetch of…
otterc Jul 24, 2020
50efba9
LIHADOOP-55372 reduced the default for minChunkSizeInMergedShuffleFile
otterc Aug 26, 2020
8a6e01b
LIHADOOP-55315 Avoid network when fetching merged shuffle file in loc…
zhouyejoe Sep 9, 2020
ae5ffac
LIHADOOP-55654 Duplicate application init calls trigger NPE and wrong…
zhouyejoe Sep 12, 2020
e51042b
Further prune changes that should go into a later PR.
Victsm Sep 23, 2020
83aca99
LIHADOOP-54379 Sorting the disks both on shuffle service and executors
otterc Jun 24, 2020
04e0efe
LIHADOOP-55022 Disable the merged shuffle file cleanup in stopApplica…
zhouyejoe Aug 11, 2020
71dfd48
Tests and cleanup
otterc Oct 6, 2020
0c411c1
LIHADOOP-55948 Failure in the push stream should not change the curre…
otterc Oct 1, 2020
d029463
Minor style corrections
otterc Oct 15, 2020
8f3839f
Fixed style issues
otterc Oct 15, 2020
1cd2d03
Renamed variables, methods, fixed indentation, addressed other review…
otterc Oct 19, 2020
3356c19
Addressing review comments
otterc Oct 23, 2020
d879beb
Changed the partitions map and addressed other review comments
otterc Oct 26, 2020
48ae819
Added support for subdirs under merge_manager dirs and removed the ya…
otterc Oct 28, 2020
9b031f7
Addressed test failure and other review comments in RemoteBlockPushRe…
otterc Oct 29, 2020
807cc7b
Minor change in finalization
otterc Oct 29, 2020
5b169bc
Removing the partition from inner map after the files are closed
otterc Oct 30, 2020
9ece587
Server side configuration to specify the implementation of MergedShuf…
otterc Oct 30, 2020
d13c7ad
Change the Push block stream to not encode shuffle Id, map index, and…
otterc Nov 2, 2020
63843bb
Fixed typos, address review comments, made NoOp the default impl, and…
otterc Nov 2, 2020
d35aa4b
Addressed review comments
otterc Nov 3, 2020
ba92311
Fix IndexOutOfBoundsException and avoid instantiating AppsPathInfo mu…
otterc Nov 4, 2020
9be25b3
Removed duplicate declaration of shuffle push prefix
otterc Nov 4, 2020
ba51796
Added UT for collision with 2 streams
otterc Nov 4, 2020
1f4fcfe
Removed unnecessary TODOs, marked MergedShuffleFileManager evolving, …
otterc Nov 4, 2020
28edaae
Changed the serialization on chunktracker and removed serializedSizeI…
otterc Nov 6, 2020
cb1881c
Use RandomAccessFile
otterc Nov 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
LIHADOOP-54059 LIHADOOP-53496 Handle the inconsistencies between loca…
…l dirs provided to executor and the shuffle service and not log all exceptions at error/warning level

RB=2152736
BUG=LIHADOOP-53496,LIHADOOP-54059
G=spark-reviewers
R=yezhou,mshen
A=mshen
  • Loading branch information
otterc committed Nov 6, 2020
commit 55b4a5fcf63c82ebbcd619402944470633d0ae11
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class RemoteBlockPushResolver implements MergedShuffleFileManager {
private static final Logger logger = LoggerFactory.getLogger(RemoteBlockPushResolver.class);

private final Path[] localDirs;
private final ConcurrentMap<String, Path> appsRelativePath;
private final ConcurrentMap<String, AppPathsInfo> appsPathInfo;
private final ConcurrentMap<AppShufflePartitionId, AppShufflePartitionInfo> partitions;

private final Executor directoryCleaner;
Expand All @@ -86,7 +86,7 @@ public RemoteBlockPushResolver(TransportConf conf, String[] localDirs) {
this.localDirs[i] = Paths.get(localDirs[i]);
}
this.partitions = Maps.newConcurrentMap();
this.appsRelativePath = Maps.newConcurrentMap();
this.appsPathInfo = Maps.newConcurrentMap();
this.directoryCleaner = Executors.newSingleThreadExecutor(
// Add `spark` prefix because it will run in NM in Yarn mode.
NettyUtils.createThreadFactory("spark-shuffle-merged-shuffle-directory-cleaner"));
Expand Down Expand Up @@ -181,10 +181,13 @@ public ManagedBuffer getMergedBlockData(String appId, int shuffleId, int reduceI
// TODO should we use subDirsPerLocalDir to potentially reduce inode size?
private File getFile(String appId, String filename) {
int hash = JavaUtils.nonNegativeHash(filename);
Path localDir = localDirs[hash % localDirs.length];
Path relativeMergeDir = Preconditions.checkNotNull(
appsRelativePath.get(appId), "application " + appId + " is not registered.");
return new File(localDir.resolve(relativeMergeDir).toFile(), filename);
// TODO: Change the message when this service is able to handle NM restart
AppPathsInfo appPathsInfo = Preconditions.checkNotNull(
appsPathInfo.get(appId),
"application " + appId + " is not registered or NM was restarted.");
Path[] activeLocalDirs = appPathsInfo.getActiveLocalDirs(localDirs);
Path localDir = activeLocalDirs[hash % activeLocalDirs.length];
return new File(localDir.resolve(appPathsInfo.relativeMergeDir).toFile(), filename);
}

private File getMergedShuffleFile(AppShufflePartitionId id) {
Expand All @@ -200,8 +203,10 @@ private File getMergedIndexFile(AppShufflePartitionId id) {
@Override
public void applicationRemoved(String appId, boolean cleanupLocalDirs) {
logger.info("Application {} removed, cleanupLocalDirs = {}", appId, cleanupLocalDirs);
Path relativeMergeDir = Preconditions.checkNotNull(
appsRelativePath.remove(appId), "application " + appId + " is not registered.");
// TODO: Change the message when this service is able to handle NM restart
AppPathsInfo appPathsInfo = Preconditions.checkNotNull(
appsPathInfo.get(appId),
"application " + appId + " is not registered or NM was restarted.");
Iterator<Map.Entry<AppShufflePartitionId, AppShufflePartitionInfo>> iterator =
partitions.entrySet().iterator();
while (iterator.hasNext()) {
Expand All @@ -219,8 +224,8 @@ public void applicationRemoved(String appId, boolean cleanupLocalDirs) {
}

if (cleanupLocalDirs) {
Path[] dirs = Arrays.stream(localDirs)
.map(dir -> dir.resolve(relativeMergeDir)).toArray(Path[]::new);
Path[] dirs = Arrays.stream(appPathsInfo.activeLocalDirs)
.map(dir -> dir.resolve(appPathsInfo.relativeMergeDir)).toArray(Path[]::new);
directoryCleaner.execute(() -> deleteExecutorDirs(dirs));
}
}
Expand Down Expand Up @@ -484,8 +489,21 @@ public void onComplete(String streamId) throws IOException {
}

@Override
public void onFailure(String streamId, Throwable cause) throws IOException {
logger.error("Encountered issue when merging shuffle partition block {}", msg, cause);
public void onFailure(String streamId, Throwable throwable) throws IOException {
if ((throwable.getMessage() != null &&
(throwable.getMessage().contains(
BlockPushException.COULD_NOT_FIND_OPPORTUNITY_MSG_PREFIX) ||
throwable.getMessage().contains(BlockPushException.TOO_LATE_MESSAGE_SUFFIX))) ||

(throwable.getCause() != null && throwable.getCause().getMessage() != null &&
(throwable.getCause().getMessage().contains(
BlockPushException.COULD_NOT_FIND_OPPORTUNITY_MSG_PREFIX) ||
throwable.getCause().getMessage().contains(
BlockPushException.TOO_LATE_MESSAGE_SUFFIX)))) {
logger.debug("Encountered issue when merging shuffle partition block {}", msg, throwable);
} else {
logger.error("Encountered issue when merging shuffle partition block {}", msg, throwable);
}
// Only update partitionInfo if the failure corresponds to a valid request. If the
// request is too late, i.e. received after shuffle merge finalize, #onFailure will
// also be triggered, and we can just ignore. Also, if we couldn't find an opportunity
Expand Down Expand Up @@ -549,7 +567,7 @@ public MergeStatuses finalizeShuffleMerge(FinalizeShuffleMerge msg) throws IOExc
@Override
public void registerApplication(String appId, String relativeAppPath) {
logger.debug("register application with RemoteBlockPushResolver {} {}", appId, relativeAppPath);
appsRelativePath.put(appId, Paths.get(relativeAppPath));
appsPathInfo.put(appId, new AppPathsInfo(Paths.get(relativeAppPath)));
}

/**
Expand Down Expand Up @@ -688,4 +706,34 @@ void updateLastChunkOffset(long lastChunkOffset) throws IOException {
this.lastChunkOffset = lastChunkOffset;
}
}

/**
* Wraps all the information related to the merge_dir of an application.
*/
private static class AppPathsInfo {

private final Path relativeMergeDir;
private Path[] activeLocalDirs;

AppPathsInfo(Path relativeMergeDir) {
this.relativeMergeDir = Preconditions.checkNotNull(
relativeMergeDir, "relative merge directory path cannot be null");
}

private Path[] getActiveLocalDirs(Path[] localDirs) {
if (activeLocalDirs != null) {
return activeLocalDirs;
}
synchronized (this) {
activeLocalDirs = Arrays.stream(localDirs)
.filter(rootDir -> rootDir.resolve(relativeMergeDir).toFile().exists())
.toArray(Path[]::new);
if (activeLocalDirs.length == 0) {
throw new RuntimeException(
"Did not find any active local directories wrt " + relativeMergeDir);
}
}
return activeLocalDirs;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;

import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
Expand Down Expand Up @@ -82,7 +83,7 @@ private void cleanupLocalDirs() throws IOException {
public void testNoIndexFile() {
try {
String appId = "app_NoIndexFile";
registerApplication(appId);
registerApplication(appId, localDirs);
pushResolver.getChunkCount(appId, 0, 0);
removeApplication(appId);
} catch (Throwable t) {
Expand All @@ -94,7 +95,7 @@ public void testNoIndexFile() {
@Test
public void testChunkCountsAndBlockData() throws IOException {
String appId = "app_ChunkCountsAndBlockData";
registerApplication(appId);
registerApplication(appId, localDirs);
PushBlockStream[] pushBlocks = new PushBlockStream[] {
new PushBlockStream(appId, "shuffle_0_0_0", 0),
new PushBlockStream(appId, "shuffle_0_1_0", 0),
Expand All @@ -113,7 +114,31 @@ public void testChunkCountsAndBlockData() throws IOException {
@Test
public void testMultipleBlocksInAChunk() throws IOException {
String appId = "app_MultipleBlocksInAChunk";
registerApplication(appId);
registerApplication(appId, localDirs);
PushBlockStream[] pushBlocks = new PushBlockStream[] {
new PushBlockStream(appId, "shuffle_0_0_0", 0),
new PushBlockStream(appId, "shuffle_0_1_0", 0),
new PushBlockStream(appId, "shuffle_0_2_0", 0),
new PushBlockStream(appId, "shuffle_0_3_0", 0),
};
ByteBuffer[] buffers = new ByteBuffer[]{
ByteBuffer.wrap(new byte[2]),
ByteBuffer.wrap(new byte[3]),
ByteBuffer.wrap(new byte[5]),
ByteBuffer.wrap(new byte[3])
};
pushBlockHelper(appId, pushBlocks, buffers);
int numChunks = pushResolver.getChunkCount(appId, 0, 0);
assertEquals(3, numChunks);
validateChunks(appId,0, 0, numChunks, new int[]{5, 5, 3});
removeApplication(appId);
}

@Test
public void testAppUsingFewerLocalDirs() throws IOException {
String appId = "app_AppUsingFewerLocalDirs";
String[] activeLocalDirs = Arrays.stream(localDirs).skip(1).toArray(String[]::new);
registerApplication(appId, activeLocalDirs);
PushBlockStream[] pushBlocks = new PushBlockStream[] {
new PushBlockStream(appId, "shuffle_0_0_0", 0),
new PushBlockStream(appId, "shuffle_0_1_0", 0),
Expand All @@ -138,8 +163,8 @@ public void testMultipleBlocksInAChunk() throws IOException {
* This is because when the application gets removed, the directory cleaner removes the merged
* data and file in a different thread which can delete the relevant data of a different test.
*/
private void registerApplication(String appId) throws IOException {
for (String localDir : localDirs) {
private void registerApplication(String appId, String[] activeLocalDirs) throws IOException {
for (String localDir : activeLocalDirs) {
Files.createDirectories(Paths.get(localDir).resolve(appId + "/merge_manager"));
}
pushResolver.registerApplication(appId, appId + "/merge_manager");
Expand Down