nandakumar131 commented on a change in pull request #682: HDDS-1372. getContainerWithPipeline for a standalone pipeline fails with ConcurrentModificationException. URL: https://github.com/apache/hadoop/pull/682#discussion_r272286786
########## File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestSCMContainerManager.java ########## @@ -194,6 +197,49 @@ public void testGetContainerWithPipeline() throws Exception { Assert.assertTrue(replicaNodes.contains(dn1)); } + @Test + public void testGetContainerReplicaWithParallelUpdate() throws Exception { + testGetContainerWithPipeline(); + final Optional<ContainerID> id = containerManager.getContainerIDs() + .stream().findFirst(); + Assert.assertTrue(id.isPresent()); + final ContainerID cId = id.get(); + final Optional<ContainerReplica> replica = containerManager + .getContainerReplicas(cId).stream().findFirst(); + Assert.assertTrue(replica.isPresent()); + final ContainerReplica cReplica = replica.get(); + final AtomicBoolean runUpdaterThread = + new AtomicBoolean(true); + + Thread updaterThread = new Thread(() -> { + while (runUpdaterThread.get()) { + try { + containerManager.removeContainerReplica(cId, cReplica); + containerManager.updateContainerReplica(cId, cReplica); + } catch (ContainerNotFoundException e) { + e.printStackTrace(); + } catch (ContainerReplicaNotFoundException e) { + Assert.fail("Missing Container Replica for " + id); + } + } + }); + + updaterThread.setDaemon(true); + updaterThread.start(); + + IntStream.range(0, 10).forEach(i -> { Review comment: 1000 will be very high, let make it 100. I was able to reproduce the issue every time with just 10 iterations. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org