adoroszlai commented on a change in pull request #624: HDDS-3110. Fix race 
condition in Recon's container and pipeline handling.
URL: https://github.com/apache/hadoop-ozone/pull/624#discussion_r386833383
 
 

 ##########
 File path: 
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconIncrementalContainerReportHandler.java
 ##########
 @@ -70,19 +70,22 @@ public void onMessage(final 
IncrementalContainerReportFromDatanode report,
         final DatanodeDetails dd = report.getDatanodeDetails();
         final ContainerID id = ContainerID.valueof(
             replicaProto.getContainerID());
-        if (!getContainerManager().exists(id)) {
-          LOG.info("New container {} got from {}.", id,
-              report.getDatanodeDetails());
-          try {
-            ContainerWithPipeline containerWithPipeline =
-                scmClient.getContainerWithPipeline(id.getId());
-            LOG.info("Verified new container from SCM {} ",
-                containerWithPipeline.getContainerInfo().containerID());
-            containerManager.addNewContainer(id.getId(), 
containerWithPipeline);
-          } catch (IOException ioEx) {
-            LOG.error("Exception while getting new container info from SCM",
-                ioEx);
-            return;
+        synchronized (containerManager) {
+          if (!containerManager.exists(id)) {
+            LOG.info("New container {} got from {}.", id,
+                report.getDatanodeDetails());
+            try {
+              ContainerWithPipeline containerWithPipeline =
+                  scmClient.getContainerWithPipeline(id.getId());
+              LOG.info("Verified new container from SCM {} ",
+                  containerWithPipeline.getContainerInfo().containerID());
+              containerManager
+                  .addNewContainer(id.getId(), containerWithPipeline);
+            } catch (IOException ioEx) {
+              LOG.error("Exception while getting new container info from SCM",
+                  ioEx);
+              return;
+            }
 
 Review comment:
   Looks like this block could be shared between the two container report 
handlers.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to