This is an automated email from the ASF dual-hosted git repository.

smengcl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 095faaeec37 HDDS-17451. SCM terminates when it applies a 
transitionDeletingOrDeletedToClosedState Raft log entry written by SCM 2.0 or 
2.1 (#11751)
095faaeec37 is described below

commit 095faaeec3794b0d224e0bb714f44f702780818b
Author: Siyao Meng <[email protected]>
AuthorDate: Thu Oct 29 17:01:05 2026 -0700

    HDDS-17451. SCM terminates when it applies a 
transitionDeletingOrDeletedToClosedState Raft log entry written by SCM 2.0 or 
2.1 (#11751)
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../hdds/scm/container/ContainerStateManager.java  |  8 ++++
 .../scm/container/ContainerStateManagerImpl.java   |  6 +++
 .../ha/invoker/ContainerStateManagerInvoker.java   | 43 +++++++++++++++-------
 .../scm/container/TestContainerStateManager.java   | 37 ++++++++++++++++++-
 4 files changed, 79 insertions(+), 15 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
index c80996226b5..a41a39243c0 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
@@ -198,6 +198,14 @@ void 
updateContainerStateWithSequenceId(HddsProtos.ContainerID id,
   void transitionDeletingOrDeletedToTargetState(HddsProtos.ContainerID id, 
LifeCycleState targetState)
       throws IOException;
 
+  /**
+   * Kept to apply Raft log entries written by SCM 2.0 and 2.1.
+   * Same as {@link #transitionDeletingOrDeletedToTargetState} with CLOSED.
+   */
+  @Deprecated
+  @Replicate
+  void transitionDeletingOrDeletedToClosedState(HddsProtos.ContainerID id) 
throws IOException;
+
   /**
    *
    */
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java
index 213f7256d61..b97bcbb27a9 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManagerImpl.java
@@ -489,6 +489,12 @@ public void 
transitionDeletingOrDeletedToTargetState(HddsProtos.ContainerID cont
     }
   }
 
+  @Deprecated
+  @Override
+  public void transitionDeletingOrDeletedToClosedState(HddsProtos.ContainerID 
containerID) throws IOException {
+    transitionDeletingOrDeletedToTargetState(containerID, CLOSED);
+  }
+
   @Override
   public Set<ContainerReplica> getContainerReplicas(final ContainerID id) {
     try (AutoCloseableLock ignored = readLock(id)) {
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ContainerStateManagerInvoker.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ContainerStateManagerInvoker.java
index 311a5defb71..05b1c8f8d86 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ContainerStateManagerInvoker.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/ContainerStateManagerInvoker.java
@@ -49,6 +49,10 @@ enum ReplicateMethod implements NameAndParameterTypes {
         null,
         new Class<?>[] {HddsProtos.ContainerID.class}
     }),
+    transitionDeletingOrDeletedToClosedState(new Class<?>[][] {
+        null,
+        new Class<?>[] {HddsProtos.ContainerID.class}
+    }),
     transitionDeletingOrDeletedToTargetState(new Class<?>[][] {
         null,
         null,
@@ -167,6 +171,12 @@ public void removeContainerReplica(ContainerReplica arg0) {
         invoker.getImpl().removeContainerReplica(arg0);
       }
 
+      @Override
+      public void 
transitionDeletingOrDeletedToClosedState(HddsProtos.ContainerID arg0) throws 
IOException {
+        final Object[] args = {arg0};
+        
invoker.invokeReplicateDirect(ReplicateMethod.transitionDeletingOrDeletedToClosedState,
 args);
+      }
+
       @Override
       public void 
transitionDeletingOrDeletedToTargetState(HddsProtos.ContainerID arg0, 
LifeCycleState arg1) throws
           IOException {
@@ -300,33 +310,38 @@ public Message invokeLocal(String methodName, Object[] p) 
throws Exception {
       getImpl().removeContainerReplica(arg22);
       return Message.EMPTY;
 
-    case "transitionDeletingOrDeletedToTargetState":
+    case "transitionDeletingOrDeletedToClosedState":
       final HddsProtos.ContainerID arg23 = p.length > 0 ? 
(HddsProtos.ContainerID) p[0] : null;
-      final LifeCycleState arg24 = p.length > 1 ? (LifeCycleState) p[1] : null;
-      getImpl().transitionDeletingOrDeletedToTargetState(arg23, arg24);
+      getImpl().transitionDeletingOrDeletedToClosedState(arg23);
+      return Message.EMPTY;
+
+    case "transitionDeletingOrDeletedToTargetState":
+      final HddsProtos.ContainerID arg24 = p.length > 0 ? 
(HddsProtos.ContainerID) p[0] : null;
+      final LifeCycleState arg25 = p.length > 1 ? (LifeCycleState) p[1] : null;
+      getImpl().transitionDeletingOrDeletedToTargetState(arg24, arg25);
       return Message.EMPTY;
 
     case "updateContainerInfo":
-      final ContainerInfoProto arg25 = p.length > 0 ? (ContainerInfoProto) 
p[0] : null;
-      getImpl().updateContainerInfo(arg25);
+      final ContainerInfoProto arg26 = p.length > 0 ? (ContainerInfoProto) 
p[0] : null;
+      getImpl().updateContainerInfo(arg26);
       return Message.EMPTY;
 
     case "updateContainerReplica":
-      final ContainerReplica arg26 = p.length > 0 ? (ContainerReplica) p[0] : 
null;
-      getImpl().updateContainerReplica(arg26);
+      final ContainerReplica arg27 = p.length > 0 ? (ContainerReplica) p[0] : 
null;
+      getImpl().updateContainerReplica(arg27);
       return Message.EMPTY;
 
     case "updateContainerState":
-      final HddsProtos.ContainerID arg27 = p.length > 0 ? 
(HddsProtos.ContainerID) p[0] : null;
-      final LifeCycleEvent arg28 = p.length > 1 ? (LifeCycleEvent) p[1] : null;
-      getImpl().updateContainerState(arg27, arg28);
+      final HddsProtos.ContainerID arg28 = p.length > 0 ? 
(HddsProtos.ContainerID) p[0] : null;
+      final LifeCycleEvent arg29 = p.length > 1 ? (LifeCycleEvent) p[1] : null;
+      getImpl().updateContainerState(arg28, arg29);
       return Message.EMPTY;
 
     case "updateContainerStateWithSequenceId":
-      final HddsProtos.ContainerID arg29 = p.length > 0 ? 
(HddsProtos.ContainerID) p[0] : null;
-      final LifeCycleEvent arg30 = p.length > 1 ? (LifeCycleEvent) p[1] : null;
-      final Long arg31 = p.length > 2 ? (Long) p[2] : null;
-      getImpl().updateContainerStateWithSequenceId(arg29, arg30, arg31);
+      final HddsProtos.ContainerID arg30 = p.length > 0 ? 
(HddsProtos.ContainerID) p[0] : null;
+      final LifeCycleEvent arg31 = p.length > 1 ? (LifeCycleEvent) p[1] : null;
+      final Long arg32 = p.length > 2 ? (Long) p[2] : null;
+      getImpl().updateContainerStateWithSequenceId(arg30, arg31, arg32);
       return Message.EMPTY;
 
     default:
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManager.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManager.java
index 6b1a2cca0b2..5b8ac5e455d 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerStateManager.java
@@ -19,6 +19,7 @@
 
 import static org.apache.hadoop.hdds.scm.HddsTestUtils.getContainer;
 import static org.apache.hadoop.hdds.scm.HddsTestUtils.getECContainer;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -48,6 +49,7 @@
 import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto;
 import 
org.apache.hadoop.hdds.scm.container.common.helpers.InvalidContainerStateException;
@@ -56,6 +58,8 @@
 import org.apache.hadoop.hdds.scm.ha.SCMContext;
 import org.apache.hadoop.hdds.scm.ha.SCMHAManager;
 import org.apache.hadoop.hdds.scm.ha.SCMHAManagerStub;
+import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
+import org.apache.hadoop.hdds.scm.ha.SCMRatisResponse;
 import org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition;
 import org.apache.hadoop.hdds.scm.node.NodeStatus;
 import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
@@ -81,6 +85,7 @@
 public class TestContainerStateManager {
 
   private ContainerStateManager containerStateManager;
+  private SCMHAManager scmhaManager;
   @TempDir
   private File testDir;
   private DBStore dbStore;
@@ -94,7 +99,7 @@ public class TestContainerStateManager {
   @BeforeEach
   public void init() throws IOException, TimeoutException {
     OzoneConfiguration conf = new OzoneConfiguration();
-    SCMHAManager scmhaManager = SCMHAManagerStub.getInstance(true);
+    scmhaManager = SCMHAManagerStub.getInstance(true);
     conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
     dbStore = DBStoreBuilder.createDBStore(conf, SCMDBDefinition.get());
     pipelineManager = mock(PipelineManager.class);
@@ -235,6 +240,36 @@ public void 
testTransitionDeletingOrDeletedToTargetState(HddsProtos.LifeCycleSta
         .getState());
   }
 
+  @ParameterizedTest
+  @EnumSource(value = HddsProtos.LifeCycleState.class, names = {"DELETING", 
"DELETED"})
+  public void 
testApplyLegacyTransitionDeletingOrDeletedToClosedState(HddsProtos.LifeCycleState
 lifeCycleState)
+      throws Exception {
+    final ContainerInfo container = getContainer(lifeCycleState);
+    containerStateManager.addContainer(container.getProtobuf());
+
+    
assertThat(applyLegacyTransitionDeletingOrDeletedToClosedState(container).getException()).isNull();
+    assertEquals(HddsProtos.LifeCycleState.CLOSED, 
containerStateManager.getContainer(container.containerID())
+        .getState());
+  }
+
+  @Test
+  public void 
testApplyLegacyTransitionDeletingOrDeletedToClosedStateRejectsClosedContainer() 
throws Exception {
+    final ContainerInfo container = 
getContainer(HddsProtos.LifeCycleState.CLOSED);
+    containerStateManager.addContainer(container.getProtobuf());
+
+    
assertThat(applyLegacyTransitionDeletingOrDeletedToClosedState(container).getException())
+        .hasCauseInstanceOf(InvalidContainerStateException.class);
+  }
+
+  private SCMRatisResponse 
applyLegacyTransitionDeletingOrDeletedToClosedState(ContainerInfo container)
+      throws Exception {
+    // A Raft log entry as written by SCM 2.0 and 2.1, before the method was 
renamed.
+    final SCMRatisRequest entry = 
SCMRatisRequest.decode(SCMRatisRequest.of(RequestType.CONTAINER,
+        "transitionDeletingOrDeletedToClosedState", new Class<?>[] 
{HddsProtos.ContainerID.class},
+        container.containerID().getProtobuf()).encode());
+    return scmhaManager.getRatisServer().submitRequest(entry);
+  }
+
   @ParameterizedTest
   @EnumSource(value = HddsProtos.LifeCycleState.class,
       names = {"CLOSING", "QUASI_CLOSED", "CLOSED", "RECOVERING"})


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

Reply via email to