siddhantsangwan commented on a change in pull request #2578:
URL: https://github.com/apache/ozone/pull/2578#discussion_r723152657



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -743,14 +768,14 @@ public void stop() {
         return;
       }
       balancerRunning = false;
-      currentBalancingThread.interrupt();
-      currentBalancingThread.join(1000);
+      if (Thread.currentThread().getId() != currentBalancingThread.getId()) {
+        currentBalancingThread.interrupt();
+        currentBalancingThread.join();
+      }

Review comment:
       @lokeshj1703 
   > Why do we need isBalancerRunning check before calling stop method? It 
should be ok to call stop directly.
   
   I was thinking of this case:
   Suppose `stop()` is called by the CLI. In the stop method, `balancerRunning` 
would be set to false and `currentBalancingThread` would be interrupted. Then 
`join()` will wait for `currentBalancingThread` to die while holding the lock. 
If `currentBalancingThread` now calls `stop()`, it will get disabled since the 
lock isn't available. This is a possible deadlock.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to