Skip to content
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

[ISSUE-392] Fix the bug in the shuffle data cleanup checker that causes false reports of disk corruption #393

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
public class LocalStorageChecker extends Checker {

private static final Logger LOG = LoggerFactory.getLogger(LocalStorageChecker.class);
public static final String CHECKER_DIR_NAME = ".check";

private final double diskMaxUsagePercentage;
private final double diskRecoveryUsagePercentage;
Expand Down Expand Up @@ -164,7 +165,8 @@ boolean checkStorageReadAndWrite() {
if (storage.isCorrupted()) {
return false;
}
File checkDir = new File(storageDir, "check");
// Use the hidden file to avoid being cleanup
File checkDir = new File(storageDir, CHECKER_DIR_NAME);
try {
if (!checkDir.mkdirs()) {
return false;
Expand Down Expand Up @@ -196,13 +198,13 @@ boolean checkStorageReadAndWrite() {
} while (readBytes != -1);
}
} catch (Exception e) {
LOG.error("Storage read and write error ", e);
LOG.error("Storage read and write error. Storage dir: {}", storageDir, e);
return false;
} finally {
try {
FileUtils.deleteDirectory(checkDir);
} catch (IOException ioe) {
LOG.error("delete directory fail", ioe);
LOG.error("delete directory fail. Storage dir: {}", storageDir, ioe);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,14 @@ public void checkAndClearLeakShuffleDataTest(@TempDir File tempDir) throws Excep
// make sure heartbeat timeout and resources are removed
Thread.sleep(5000);

// Create the hidden dir to simulate LocalStorageChecker's check
String storageDir = tempDir.getAbsolutePath();
File hiddenFile = new File(storageDir + "/" + LocalStorageChecker.CHECKER_DIR_NAME);
hiddenFile.mkdir();

appIdsOnDisk = getAppIdsOnDisk(localStorageManager);
assertFalse(appIdsOnDisk.contains(appId));
assertFalse(appIdsOnDisk.contains(LocalStorageChecker.CHECKER_DIR_NAME));

// mock leak shuffle data
File file = new File(tempDir, appId);
Expand All @@ -717,6 +723,7 @@ public void checkAndClearLeakShuffleDataTest(@TempDir File tempDir) throws Excep
// execute checkLeakShuffleData
shuffleTaskManager.checkLeakShuffleData();
assertFalse(file.exists());
assertTrue(hiddenFile.exists());
}

private Set<String> getAppIdsOnDisk(LocalStorageManager localStorageManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public Set<String> getAppIds() {
File[] files = baseFolder.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
if (file.isDirectory() && !file.isHidden()) {
appIds.add(file.getName());
}
}
Expand Down