errose28 commented on code in PR #6967:
URL: https://github.com/apache/ozone/pull/6967#discussion_r1690310384


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/AbstractContainerReportHandler.java:
##########
@@ -349,8 +349,17 @@ private boolean updateContainerState(final DatanodeDetails 
datanode,
       break;
     case DELETING:
       /*
-       * The container is under deleting. do nothing.
+      HDDS-11136: If a DELETING container has a non-empty CLOSED replica, the 
container should be moved back to CLOSED
+      state.
        */
+      if (replica.getState() == State.CLOSED || replica.getState() == 
State.QUASI_CLOSED && replica.hasIsEmpty() &&
+          !replica.getIsEmpty()) {

Review Comment:
   ```suggestion
         if ((replica.getState() == State.CLOSED || replica.getState() == 
State.QUASI_CLOSED)) && replica.hasIsEmpty() &&
             !replica.getIsEmpty()) {
   ```
   Operator precedence would have caused a bug here. Adding parenthesis fixes 
it but I would usually split something like this out for readability:
   
   ```java
   boolean replicaStateAllowed = replica.getState() == State.CLOSED || 
replica.getState() == State.QUASI_CLOSED;
   boolean replicaNotEmpty = replica.hasIsEmpty() && !replica.getIsEmpty();
   if (replicaStateAllowed && replicaNotEmpty) {
   ```
   
   Looks like we need tests that empty replicas in valid states do not trigger 
the transition



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to