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

[#1634] fix(server): remove app folder if app is expired #1635

Merged
merged 4 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -18,7 +18,6 @@
package org.apache.uniffle.server;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -763,22 +762,18 @@ public void removeResources(String appId, boolean checkAppExpired) {
return;
}
final long start = System.currentTimeMillis();
String user = getUserByAppId(appId);
ShuffleTaskInfo shuffleTaskInfo = shuffleTaskInfos.remove(appId);
if (shuffleTaskInfo == null) {
LOG.info("Resource for appId[" + appId + "] had been removed before.");
return;
}

final Map<Integer, Roaring64NavigableMap> shuffleToCachedBlockIds =
shuffleTaskInfo.getCachedBlockIds();
partitionsToBlockIds.remove(appId);
shuffleBufferManager.removeBuffer(appId);
shuffleFlushManager.removeResources(appId);
if (!shuffleToCachedBlockIds.isEmpty()) {
storageManager.removeResources(
new AppPurgeEvent(appId, user, new ArrayList<>(shuffleToCachedBlockIds.keySet())));
}

zuston marked this conversation as resolved.
Show resolved Hide resolved
storageManager.removeResources(new AppPurgeEvent(appId, shuffleTaskInfo.getUser()));

if (shuffleTaskInfo.hasHugePartition()) {
ShuffleServerMetrics.gaugeAppWithHugePartitionNum.dec();
ShuffleServerMetrics.gaugeHugePartitionNum.dec(shuffleTaskInfo.getHugePartitionSize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,11 @@ public void removeShuffleDataWithHdfsTest() throws Exception {
assertTrue(fs.exists(new Path(appBasePath)));
assertNull(shuffleBufferManager.getBufferPool().get(appId).get(0));
assertNotNull(shuffleBufferManager.getBufferPool().get(appId).get(1));

// the shufflePurgeEvent only will delete the children folders
// Once the app is expired, all the app folder should be deleted.
zuston marked this conversation as resolved.
Show resolved Hide resolved
shuffleTaskManager.removeResources(appId, false);
assertFalse(fs.exists(new Path(appBasePath)));
}

@Test
Expand Down Expand Up @@ -528,6 +532,14 @@ public void removeShuffleDataWithLocalfileTest() throws Exception {
assertEquals(0, files.length);
}
}

// the shufflePurgeEvent only will delete the children folders
// Once the app is expired, all the app folder should be deleted.
zuston marked this conversation as resolved.
Show resolved Hide resolved
shuffleTaskManager.removeResources(appId, false);
for (String path : conf.get(ShuffleServerConf.RSS_STORAGE_BASE_PATH)) {
String appPath = path + "/" + appId;
assertFalse(new File(appPath).exists());
}
}

@Test
Expand Down
Loading