dineshchitlangia commented on a change in pull request #806: HDDS-3374. 
OMVolumeSetOwnerRequest doesn't check if user is already the owner
URL: https://github.com/apache/hadoop-ozone/pull/806#discussion_r406865345
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/volume/OMVolumeRequest.java
 ##########
 @@ -106,6 +106,13 @@ protected UserVolumeInfo 
addVolumeToOwnerList(UserVolumeInfo volumeList,
       objectID = volumeList.getObjectID();
     }
 
+    // Sanity check, a user should not own same volume twice
+    //  TODO: May want to remove this due to perf if user owns a lot of 
volumes.
+    if (prevVolList.contains(volume)) {
+      throw new IOException("Invalid operation: User " + owner +
+          " is about to own a same volume " + volume + " twice!" +
+          " Check for DB consistency error.");
+    }
 
     // Add the new volume to the list
     prevVolList.add(volume);
 
 Review comment:
   Instead of throwing exception here, I was wondering if we can instead 
perform the subsequent "add new volume to list" if 
!prevVolList.contains(volume) and complement with WARN log.
   
   ```suggestion
       // Avoid adding a user to the same volume twice
       if (!prevVolList.contains(volume)) {
         // Add the new volume to the list
         prevVolList.add(volume);
         UserVolumeInfo newVolList = UserVolumeInfo.newBuilder()
             .setObjectID(objectID)
             .setUpdateID(txID)
             .addAllVolumeNames(prevVolList).build();
       }
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to