You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/10/06 08:53:49 UTC

[GitHub] [ozone] sumitagrawl commented on a diff in pull request #3782: HDDS-7214. Continuous start & stop can have hanging threads in stopping

sumitagrawl commented on code in PR #3782:
URL: https://github.com/apache/ozone/pull/3782#discussion_r988739541


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -893,32 +80,36 @@ private void resetState() {
   @Override
   public void notifyStatusChanged() {
     boolean shouldStop = false;
-    boolean shouldRun = false;
     lock.lock();
     try {
       if (!scmContext.isLeader() || scmContext.isInSafeMode()) {
-        shouldStop = isBalancerRunning();
-      } else {
-        shouldRun = shouldRun();
+        shouldStop = canBalancerStop();
       }
     } finally {
       lock.unlock();
     }
-
     if (shouldStop) {
       LOG.info("Stopping ContainerBalancer in this scm on status change");
       stop();
+      return;
     }
 
-    if (shouldRun) {
-      LOG.info("Starting ContainerBalancer in this scm on status change");
-      try {
-        start();
-      } catch (IllegalContainerBalancerStateException |
-          InvalidContainerBalancerConfigurationException e) {
-        LOG.warn("Could not start ContainerBalancer on raft/safe-mode " +
-            "status change.", e);
+    lock.lock();

Review Comment:
   > It is a bit inconsistent that we need to take lock for start but not for stop call above.
   
   This is done as stop has a blocking call with join, waiting thread to stop, this may take longer time. Stop lock is done inside at granular level, avoiding area of join.
   



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

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org