You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by ro...@apache.org on 2023/05/23 14:24:25 UTC
[incubator-uniffle] branch master updated: [MINOR] fix: Fix LocalStorageManager divide by zero exception (#900)
This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new e6f8fcb5 [MINOR] fix: Fix LocalStorageManager divide by zero exception (#900)
e6f8fcb5 is described below
commit e6f8fcb5241869464d1915cdbe26ad1565755bfd
Author: Xianming Lei <31...@users.noreply.github.com>
AuthorDate: Tue May 23 22:24:19 2023 +0800
[MINOR] fix: Fix LocalStorageManager divide by zero exception (#900)
### What changes were proposed in this pull request?
Fix LocalStorageManager divide by zero exception when all local disks corrupted.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
UT.
Co-authored-by: leixianming <le...@didiglobal.com>
---
.../java/org/apache/uniffle/server/storage/LocalStorageManager.java | 4 ++++
.../org/apache/uniffle/server/storage/LocalStorageManagerTest.java | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java b/server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java
index c1bb63b7..4080eba0 100644
--- a/server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java
+++ b/server/src/main/java/org/apache/uniffle/server/storage/LocalStorageManager.java
@@ -189,6 +189,10 @@ public class LocalStorageManager extends SingleStorageManager {
.stream()
.filter(x -> x.canWrite() && !x.isCorrupted())
.collect(Collectors.toList());
+
+ if (candidates.size() == 0) {
+ return null;
+ }
final LocalStorage selectedStorage = candidates.get(
ShuffleStorageUtils.getStorageIndex(
candidates.size(),
diff --git a/server/src/test/java/org/apache/uniffle/server/storage/LocalStorageManagerTest.java b/server/src/test/java/org/apache/uniffle/server/storage/LocalStorageManagerTest.java
index 43c8f064..049ee35d 100644
--- a/server/src/test/java/org/apache/uniffle/server/storage/LocalStorageManagerTest.java
+++ b/server/src/test/java/org/apache/uniffle/server/storage/LocalStorageManagerTest.java
@@ -47,6 +47,7 @@ import org.apache.uniffle.storage.util.StorageType;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -159,6 +160,11 @@ public class LocalStorageManagerTest {
((LocalStorage)restStorage).markCorrupted();
Storage storage8 = localStorageManager.selectStorage(dataReadEvent);
assertEquals(storage7, storage8);
+
+ // make all storage corrupted
+ ((LocalStorage)localStorageManager.selectStorage(dataFlushEvent1)).markCorrupted();
+ ShuffleDataFlushEvent dataFlushEvent3 = toDataFlushEvent(appId, 1, 2);
+ assertNull(localStorageManager.selectStorage(dataFlushEvent3));
}
@Test