[ 
https://issues.apache.org/jira/browse/HDDS-1517?focusedWorklogId=243404&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-243404
 ]

ASF GitHub Bot logged work on HDDS-1517:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/May/19 15:20
            Start Date: 16/May/19 15:20
    Worklog Time Spent: 10m 
      Work Description: jiwq commented on pull request #826: HDDS-1517. 
AllocateBlock call fails with ContainerNotFoundException.
URL: https://github.com/apache/hadoop/pull/826#discussion_r284762022
 
 

 ##########
 File path: 
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestSCMContainerManager.java
 ##########
 @@ -144,6 +145,41 @@ public void testallocateContainerDistributesAllocation() 
throws Exception {
     Assert.assertTrue(pipelineList.size() > 5);
   }
 
+  @Test
+  public void testAllocateContainerInParallel() throws Exception {
+    int threadCount = 20;
+    List<ExecutorService> executors = new ArrayList<>(threadCount);
+    for (int i = 0; i < threadCount; i++) {
+      executors.add(Executors.newSingleThreadExecutor());
+    }
+    List<CompletableFuture<ContainerInfo>> futureList =
+        new ArrayList<>(threadCount);
+    for (int i = 0; i < threadCount; i++) {
+      final CompletableFuture<ContainerInfo> future =
+          new CompletableFuture<>();
+      CompletableFuture.supplyAsync(() -> {
+        try {
+          ContainerInfo containerInfo = containerManager
+              .allocateContainer(xceiverClientManager.getType(),
+                  xceiverClientManager.getFactor(), containerOwner);
+
+          Assert.assertNotNull(containerInfo);
+          Assert.assertNotNull(containerInfo.getPipelineID());
+          future.complete(containerInfo);
+          return containerInfo;
+        } catch (IOException e) {
+          future.completeExceptionally(e);
+        } return future;
+      }, executors.get(i)); futureList.add(future);
+    }
+    try {
+      CompletableFuture
+          .allOf(futureList.toArray(new CompletableFuture[futureList.size()]))
+          .get();
+    } catch (Exception e) {
+      Assert.fail("testAllocateBlockInParallel failed");
+    }
+  }
 
 Review comment:
   Need a blank line between two methods.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 243404)
    Time Spent: 20m  (was: 10m)

> AllocateBlock call fails with ContainerNotFoundException
> --------------------------------------------------------
>
>                 Key: HDDS-1517
>                 URL: https://issues.apache.org/jira/browse/HDDS-1517
>             Project: Hadoop Distributed Data Store
>          Issue Type: Bug
>          Components: SCM
>    Affects Versions: 0.5.0
>            Reporter: Shashikant Banerjee
>            Assignee: Shashikant Banerjee
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.4.1
>
>         Attachments: HDDS-1517.000.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> In allocateContainer call,  the container is first added to pipelineStateMap 
> and then added to container cache. If two allocate blocks execute 
> concurrently, it might happen that one find the container to exist in the 
> pipelineStateMap but the container is yet to be updated in the container 
> cache, hence failing with CONTAINER_NOT_FOUND exception.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to