You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2021/05/10 08:06:05 UTC

[GitHub] [ratis] szetszwo commented on a change in pull request #477: RATIS-1375. Handle bad storage dir due to disk failures.

szetszwo commented on a change in pull request #477:
URL: https://github.com/apache/ratis/pull/477#discussion_r629128917



##########
File path: ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
##########
@@ -104,17 +104,24 @@
     configurationManager = new ConfigurationManager(initialConf);
     LOG.info("{}: {}", getMemberId(), configurationManager);
 
+    boolean storageFound = false;
     List<File> directories = RaftServerConfigKeys.storageDir(prop);
     while (!directories.isEmpty()) {
       // use full uuid string to create a subdirectory
       File dir = chooseStorageDir(directories, group.getGroupId().getUuid().toString());
       try {
         storage = new RaftStorageImpl(dir, RaftServerConfigKeys.Log.corruptionPolicy(prop));
+        storageFound = true;
         break;
-      } catch (AccessDeniedException e) {
-        directories.remove(dir);
+      } catch (IOException e) {
+        directories.removeIf(d -> d.getAbsolutePath().equals(dir.getParent()));
       }
     }
+
+    if (!storageFound) {
+      throw new IOException("No healthy directories found for RaftStorage");

Review comment:
       Let's add directory list `RaftServerConfigKeys.storageDir(prop)` to the error message.

##########
File path: ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
##########
@@ -104,17 +104,24 @@
     configurationManager = new ConfigurationManager(initialConf);
     LOG.info("{}: {}", getMemberId(), configurationManager);
 
+    boolean storageFound = false;
     List<File> directories = RaftServerConfigKeys.storageDir(prop);
     while (!directories.isEmpty()) {
       // use full uuid string to create a subdirectory
       File dir = chooseStorageDir(directories, group.getGroupId().getUuid().toString());
       try {
         storage = new RaftStorageImpl(dir, RaftServerConfigKeys.Log.corruptionPolicy(prop));
+        storageFound = true;
         break;
-      } catch (AccessDeniedException e) {
-        directories.remove(dir);
+      } catch (IOException e) {
+        directories.removeIf(d -> d.getAbsolutePath().equals(dir.getParent()));

Review comment:
       If we don't remove it, the while-loop won't terminate.

##########
File path: ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
##########
@@ -104,17 +104,24 @@
     configurationManager = new ConfigurationManager(initialConf);
     LOG.info("{}: {}", getMemberId(), configurationManager);
 
+    boolean storageFound = false;
     List<File> directories = RaftServerConfigKeys.storageDir(prop);
     while (!directories.isEmpty()) {
       // use full uuid string to create a subdirectory
       File dir = chooseStorageDir(directories, group.getGroupId().getUuid().toString());
       try {
         storage = new RaftStorageImpl(dir, RaftServerConfigKeys.Log.corruptionPolicy(prop));
+        storageFound = true;
         break;
-      } catch (AccessDeniedException e) {
-        directories.remove(dir);
+      } catch (IOException e) {

Review comment:
       Let's log the IOException.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org