You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by bh...@apache.org on 2019/04/16 20:49:41 UTC

[hadoop] branch trunk updated: HDDS-1374. ContainerStateMap cannot find container while allocating blocks. (#735)

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

bharat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3ac3e50  HDDS-1374. ContainerStateMap cannot find container while allocating blocks. (#735)
3ac3e50 is described below

commit 3ac3e50b207e27c69e26669c47b1642827c76db0
Author: Bharat Viswanadham <bh...@apache.org>
AuthorDate: Tue Apr 16 13:49:29 2019 -0700

    HDDS-1374. ContainerStateMap cannot find container while allocating blocks. (#735)
---
 .../hadoop/hdds/scm/container/SCMContainerManager.java     | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
index 1fa8395..80d7ec1 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
@@ -246,7 +246,17 @@ public class SCMContainerManager implements ContainerManager {
           containerStateManager.allocateContainer(pipelineManager, type,
               replicationFactor, owner);
       // Add container to DB.
-      addContainerToDB(containerInfo);
+      try {
+        addContainerToDB(containerInfo);
+      } catch (IOException ex) {
+        // When adding to DB failed, we are removing from containerStateMap.
+        // We should also remove from pipeline2Container Map in
+        // PipelineStateManager.
+        pipelineManager.removeContainerFromPipeline(
+            containerInfo.getPipelineID(),
+            new ContainerID(containerInfo.getContainerID()));
+        throw ex;
+      }
       return containerInfo;
     } finally {
       lock.unlock();
@@ -440,6 +450,8 @@ public class SCMContainerManager implements ContainerManager {
     } catch (IOException ex) {
       // If adding to containerStore fails, we should remove the container
       // from in-memory map.
+      LOG.error("Add Container to DB failed for ContainerID #{}",
+          containerInfo.getContainerID());
       try {
         containerStateManager.removeContainer(containerInfo.containerID());
       } catch (ContainerNotFoundException cnfe) {


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org