szetszwo commented on code in PR #10525:
URL: https://github.com/apache/ozone/pull/10525#discussion_r3478191845


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java:
##########
@@ -404,23 +404,30 @@ public void updateContainerStateWithSequenceId(final 
HddsProtos.ContainerID cont
           LOG.warn("Container sequenceId is {} greater than the leader 
container sequenceId {}",
               containerInfo.getSequenceId(), sequenceId);
         }
-        
-        final LifeCycleState oldState = containerInfo.getState();
-        final LifeCycleState newState = stateMachine.getNextState(
-            oldState, event);
-        if (newState.getNumber() > oldState.getNumber()) {
-          ExecutionUtil.create(() -> {
-            containers.updateState(id, oldState, newState);
-            transactionBuffer.addToBuffer(containerStore, id,
-                containers.getContainerInfo(id));
-          }).onException(() -> {
-            containers.updateState(id, newState, oldState);
-            ContainerInfo currentInfo = containers.getContainerInfo(id);
-            transactionBuffer.addToBuffer(containerStore, id, currentInfo);
-
-          }).execute();
-          containerStateChangeActions.getOrDefault(event, info -> { })
-              .accept(containerInfo);
+
+        try {
+          final LifeCycleState oldState = containerInfo.getState();
+          final LifeCycleState newState = stateMachine.getNextState(
+              oldState, event);
+
+          if (newState.getNumber() > oldState.getNumber()) {
+            ExecutionUtil.create(() -> {
+              containers.updateState(id, oldState, newState);
+              transactionBuffer.addToBuffer(containerStore, id,
+                  containers.getContainerInfo(id));
+            }).onException(() -> {
+              containers.updateState(id, newState, oldState);
+              ContainerInfo currentInfo = containers.getContainerInfo(id);
+              transactionBuffer.addToBuffer(containerStore, id, currentInfo);
+
+            }).execute();
+            containerStateChangeActions.getOrDefault(event, info -> { })
+                .accept(containerInfo);
+          }
+        } catch (InvalidStateTransitionException ex) {
+          LOG.warn("Ignoring invalid container state transition for container 
{} " +
+                  "for event {} at state {}",
+              id, event, containerInfo.getState(), ex);

Review Comment:
   - Let's catch it at the existing try-block.
   - The exception already have event and state.  Let's don't print them again.
   - Let's include the sequenceId.
   ```diff
   +++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java
   @@ -389,7 +389,7 @@ public boolean contains(ContainerID id) {
      public void updateContainerStateWithSequenceId(final 
HddsProtos.ContainerID containerID,
                                                      final LifeCycleEvent 
event,
                                                      final Long sequenceId)
   -      throws IOException, InvalidStateTransitionException {
   +      throws IOException {
        // TODO: Remove the protobuf conversion after fixing ContainerStateMap.
        final ContainerID id = ContainerID.getFromProtobuf(containerID);
    
   @@ -423,6 +423,9 @@ public void updateContainerStateWithSequenceId(final 
HddsProtos.ContainerID cont
                  .accept(containerInfo);
            }
          }
   +    } catch (InvalidStateTransitionException e) {
   +      LOG.warn("Failed to updateContainerStateWithSequenceId for container 
{} at sequenceId {}, ignoring it.",
   +          id, sequenceId, e);
        }
      }
   ```



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