siddhantsangwan commented on code in PR #3535:
URL: https://github.com/apache/ozone/pull/3535#discussion_r909440236
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java:
##########
@@ -1066,6 +1062,12 @@ public void stop() {
balancingThread.getId() != Thread.currentThread().getId()) {
balancingThread.interrupt();
try {
+ if (lock.isHeldByCurrentThread()) {
+ LOG.warn("Waiting for balancing thread \"{}\" to join while current"
+
+ " thread holds lock. This could result in a deadlock if" +
+ " balancing thread is also waiting to acquire the lock.",
+ balancingThread.getName());
Review Comment:
This is what the log looks like on introducing a lock just for testing:
```
2022-06-29 15:25:49,096 [main] WARN balancer.ContainerBalancer
(ContainerBalancer.java:stop(1072)) - Waiting for balancing thread
"ContainerBalancer" to join while current thread "main" holds lock. This could
result in a deadlock if balancing thread is also waiting to acquire the lock.
[java.lang.Thread.getStackTrace(Thread.java:1559)
org.apache.hadoop.hdds.scm.container.balancer.ContainerBalancer.stop(ContainerBalancer.java:1070)
org.apache.hadoop.hdds.scm.container.balancer.ContainerBalancer.stopBalancer(ContainerBalancer.java:1103)
org.apache.hadoop.hdds.scm.container.balancer.TestContainerBalancer.stopBalancer(TestContainerBalancer.java:942)
org.apache.hadoop.hdds.scm.container.balancer.TestContainerBalancer.testStartAndImmediateStopForDeadlock(TestContainerBalancer.java:747)
```
--
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]