hadoop-ozone-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bha...@apache.org
Subject [hadoop-ozone] branch ozone-0.5.0 updated: HDDS-3118. Possible deadlock in LockManager. (#627) (#647)
Date Fri, 06 Mar 2020 17:17:47 GMT
This is an automated email from the ASF dual-hosted git repository.

bharat pushed a commit to branch ozone-0.5.0
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/ozone-0.5.0 by this push:
     new 637add0  HDDS-3118. Possible deadlock in LockManager. (#627) (#647)
637add0 is described below

commit 637add05d410c8722741c0764578a8eb10d92197
Author: Bharat Viswanadham <bharat@apache.org>
AuthorDate: Fri Mar 6 09:17:42 2020 -0800

    HDDS-3118. Possible deadlock in LockManager. (#627) (#647)
---
 .../org/apache/hadoop/hdds/HddsConfigKeys.java     |  3 ---
 .../org/apache/hadoop/ozone/lock/LockManager.java  |  6 +----
 .../common/src/main/resources/ozone-default.xml    | 10 --------
 .../apache/hadoop/ozone/lock/TestLockManager.java  | 30 ++++++++++++++++++++++
 ...TestOzoneManagerDoubleBufferWithOMResponse.java |  2 --
 5 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java
index 30974db..3d2b703 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java
@@ -104,9 +104,6 @@ public final class HddsConfigKeys {
   public static final double
       HDDS_SCM_SAFEMODE_ONE_NODE_REPORTED_PIPELINE_PCT_DEFAULT = 0.90;
 
-  public static final String HDDS_LOCK_MAX_CONCURRENCY =
-      "hdds.lock.max.concurrency";
-  public static final int HDDS_LOCK_MAX_CONCURRENCY_DEFAULT = 100;
   // This configuration setting is used as a fallback location by all
   // Ozone/HDDS services for their metadata. It is useful as a single
   // config point for test/PoC clusters.
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/lock/LockManager.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/lock/LockManager.java
index 3c2b5d4..84aca6d 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/lock/LockManager.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/lock/LockManager.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.ozone.lock;
 
 import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdds.HddsConfigKeys;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -57,12 +56,9 @@ public class LockManager<R> {
    * @param fair - true to use fair lock ordering, else non-fair lock ordering.
    */
   public LockManager(final Configuration conf, boolean fair) {
-    final int maxPoolSize = conf.getInt(
-        HddsConfigKeys.HDDS_LOCK_MAX_CONCURRENCY,
-        HddsConfigKeys.HDDS_LOCK_MAX_CONCURRENCY_DEFAULT);
     lockPool =
         new GenericObjectPool<>(new PooledLockFactory(fair));
-    lockPool.setMaxTotal(maxPoolSize);
+    lockPool.setMaxTotal(-1);
   }
 
   /**
diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml
index 9c16045..4602a04 100644
--- a/hadoop-hdds/common/src/main/resources/ozone-default.xml
+++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml
@@ -1396,16 +1396,6 @@
   </property>
 
   <property>
-    <name>hdds.lock.max.concurrency</name>
-    <value>100</value>
-    <tag>HDDS</tag>
-    <description>Locks in HDDS/Ozone uses object pool to maintain active locks
-      in the system, this property defines the max limit for the locks that
-      will be maintained in the pool.
-    </description>
-  </property>
-
-  <property>
     <name>ozone.s3g.authentication.kerberos.principal</name>
     <value/>
     <tag>OZONE, S3GATEWAY</tag>
diff --git a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/lock/TestLockManager.java
b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/lock/TestLockManager.java
index e88b1bb..a59eadd 100644
--- a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/lock/TestLockManager.java
+++ b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/lock/TestLockManager.java
@@ -18,10 +18,13 @@
 package org.apache.hadoop.ozone.lock;
 
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.Daemon;
 import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Test-cases to test LockManager.
@@ -170,4 +173,31 @@ public class TestLockManager {
     Assert.assertTrue(gotLock.get());
   }
 
+  @Test
+  public void testConcurrentWriteLockWithDifferentResource() throws Exception {
+    OzoneConfiguration conf = new OzoneConfiguration();
+    final int count = 100;
+    final LockManager<Integer> manager = new LockManager<>(conf);
+    final int sleep = 10;
+    final AtomicInteger done = new AtomicInteger();
+    for (int i = 0; i < count; i++) {
+      final Integer id = i;
+      Daemon d1 = new Daemon(() -> {
+        try {
+          manager.writeLock(id);
+          Thread.sleep(sleep);
+        } catch (InterruptedException e) {
+          e.printStackTrace();
+        } finally {
+          manager.writeUnlock(id);
+        }
+        done.getAndIncrement();
+      });
+      d1.setName("Locker-" + i);
+      d1.start();
+    }
+    GenericTestUtils.waitFor(() -> done.get() == count, 100,
+        10 * count * sleep);
+    Assert.assertEquals(count, done.get());
+  }
 }
\ No newline at end of file
diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBufferWithOMResponse.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBufferWithOMResponse.java
index 78cd419..989092a 100644
--- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBufferWithOMResponse.java
+++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerDoubleBufferWithOMResponse.java
@@ -61,7 +61,6 @@ import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Daemon;
 import org.mockito.Mockito;
 
-import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_LOCK_MAX_CONCURRENCY;
 import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
@@ -92,7 +91,6 @@ public class TestOzoneManagerDoubleBufferWithOMResponse {
     OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
     ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS,
         folder.newFolder().getAbsolutePath());
-    ozoneConfiguration.setInt(HDDS_LOCK_MAX_CONCURRENCY, 1000);
     omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
     when(ozoneManager.getMetrics()).thenReturn(omMetrics);
     when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);


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


Mime
View raw message