bharatviswa504 commented on a change in pull request #627: HDDS-3118. Possible 
deadlock in LockManager.
URL: https://github.com/apache/hadoop-ozone/pull/627#discussion_r387453839
 
 

 ##########
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/lock/LockManager.java
 ##########
 @@ -186,21 +186,42 @@ private ActiveLock getLockForLocking(final R resource) {
      * be removed from the activeLocks map and returned to
      * the object pool.
      */
-    return activeLocks.compute(resource, (k, v) -> {
+    ActiveLock computedLock = activeLocks.compute(resource, (k, v) -> {
       final ActiveLock lock;
+      if (v == null) {
+        return null;
+      } else {
+        lock = v;
+      }
+      lock.incrementActiveCount();
+      return lock;
+    });
+
+
+    if (computedLock == null) {
       try {
-        if (v == null) {
-          lock = lockPool.borrowObject();
-        } else {
-          lock = v;
-        }
-        lock.incrementActiveCount();
+        final ActiveLock lock2 = lockPool.borrowObject();
+        computedLock = activeLocks.compute(resource, (k, v) -> {
+          final ActiveLock lock;
+          try {
+            if (v == null) {
+              lock = lock2;
+            } else {
+              lockPool.returnObject(lock2);
+              lock = v;
+            }
+            lock.incrementActiveCount();
+          } catch (Exception ex) {
+            throw new RuntimeException(ex);
 
 Review comment:
   Based on Xiaoyu's comment reverted this change.

----------------------------------------------------------------
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: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to