diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java index d506b0c87d..65b97ca8c2 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java @@ -22,6 +22,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.StorageUnit; import org.apache.hadoop.hdds.protocol.DatanodeDetails; +import org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleEvent; import org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleState; import org.apache.hadoop.hdds.protocol.proto.HddsProtos.SCMContainerInfo; import org.apache.hadoop.hdds.scm.block.PendingDeleteStatusList; @@ -532,6 +533,18 @@ public void processContainerReports(DatanodeDetails datanodeDetails, HddsProtos.SCMContainerInfo knownState = HddsProtos.SCMContainerInfo.PARSER.parseFrom(containerBytes); + if (knownState.getState() == LifeCycleState.CLOSING + && contInfo.getState() == LifeCycleState.CLOSED) { + + updateContainerState(contInfo.getContainerID(), + LifeCycleEvent.CLOSE); + + //reread the container + knownState = + HddsProtos.SCMContainerInfo.PARSER + .parseFrom(containerStore.get(dbKey)); + } + HddsProtos.SCMContainerInfo newState = reconcileState(contInfo, knownState, datanodeDetails);