hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [4/4] hbase git commit: HBASE-21117 fix table locking when moveTables, fix HBASE-20666 rsgroups issue
Date Tue, 02 Oct 2018 00:11:11 GMT
HBASE-21117 fix table locking when moveTables, fix HBASE-20666 rsgroups issue

Signed-off-by: Andrew Purtell <apurtell@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7dc20d8a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7dc20d8a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7dc20d8a

Branch: refs/heads/branch-1.4
Commit: 7dc20d8a9cdf0210eed49c88e13eeb4a9cf79801
Parents: 0918e8f
Author: Xu Cang <xcang@salesforce.com>
Authored: Sun Aug 26 00:37:06 2018 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Mon Oct 1 17:04:49 2018 -0700

----------------------------------------------------------------------
 .../hbase/rsgroup/RSGroupAdminServer.java       | 12 ++--
 .../hadoop/hbase/rsgroup/TestRSGroups.java      | 68 ++++++++++++++++++++
 .../master/procedure/CreateTableProcedure.java  |  4 ++
 3 files changed, 76 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7dc20d8a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
index a2d3589..c6c90d9 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
@@ -275,15 +275,11 @@ public class RSGroupAdminServer implements RSGroupAdmin {
         continue;
       }
       TableLock lock = master.getTableLockManager().writeLock(table, "Group: table move");
-      try {
-        lock.acquire();
-        for (HRegionInfo region :
-            master.getAssignmentManager().getRegionStates().getRegionsOfTable(table)) {
-          master.getAssignmentManager().unassign(region);
-        }
-      } finally {
-        lock.release();
+      for (HRegionInfo region :
+          master.getAssignmentManager().getRegionStates().getRegionsOfTable(table)) {
+        master.getAssignmentManager().unassign(region);
       }
+
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/7dc20d8a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
index 50d9c8c..9831ef5 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -48,10 +49,12 @@ import org.apache.hadoop.hbase.coprocessor.ObserverContext;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
 import org.apache.hadoop.hbase.master.ServerManager;
+import org.apache.hadoop.hbase.master.TableNamespaceManager;
 import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
 import org.apache.hadoop.hbase.net.Address;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
+import org.apache.hadoop.hbase.quotas.QuotaUtil;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.After;
@@ -90,7 +93,10 @@ public class TestRSGroups extends TestRSGroupsBase {
         ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,
         NUM_SLAVES_BASE - 1);
     TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
+    initialize();
+  }
 
+  private static void initialize() throws Exception {
     admin = TEST_UTIL.getHBaseAdmin();
     cluster = TEST_UTIL.getHBaseCluster();
     master = ((MiniHBaseCluster)cluster).getMaster();
@@ -450,4 +456,66 @@ public class TestRSGroups extends TestRSGroupsBase {
     admin.cloneSnapshot(snapshotName, clonedTableName);
   }
 
+  @Test
+  public void testRSGroupListDoesNotContainFailedTableCreation() throws Exception {
+    toggleQuotaCheckAndRestartMiniCluster(true);
+    String nsp = "np1";
+    NamespaceDescriptor nspDesc =
+        NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS,
"5")
+            .addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "2").build();
+    admin.createNamespace(nspDesc);
+    assertEquals(3, admin.listNamespaceDescriptors().length);
+    HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
+    HTableDescriptor tableDescOne =
+        new HTableDescriptor(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1"));
+    tableDescOne.addFamily(fam1);
+    admin.createTable(tableDescOne);
+
+    HTableDescriptor tableDescTwo =
+        new HTableDescriptor(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2"));
+    tableDescTwo.addFamily(fam1);
+    boolean constraintViolated = false;
+
+    try {
+      admin.createTable(tableDescTwo, Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"),
+          6);
+      Assert.fail("Creation table should fail because of quota violation.");
+    } catch (Exception exp) {
+      assertTrue(exp instanceof IOException);
+      constraintViolated = true;
+    } finally {
+      assertTrue("Constraint not violated for table " + tableDescTwo.getTableName(),
+          constraintViolated);
+    }
+    List<RSGroupInfo> rsGroupInfoList = rsGroupAdmin.listRSGroups();
+    boolean foundTable2 = false;
+    boolean foundTable1 = false;
+    for (int i = 0; i < rsGroupInfoList.size(); i++){
+      if(rsGroupInfoList.get(i).getTables().contains(tableDescTwo.getTableName())){
+        foundTable2 = true;
+      }
+      if(rsGroupInfoList.get(i).getTables().contains(tableDescOne.getTableName())){
+        foundTable1 = true;
+      }
+    }
+    assertFalse("Found table2 in rsgroup list.", foundTable2);
+    assertTrue("Did not find table1 in rsgroup list", foundTable1);
+
+    TEST_UTIL.deleteTable(tableDescOne.getTableName());
+    admin.deleteNamespace(nspDesc.getName());
+    toggleQuotaCheckAndRestartMiniCluster(false);
+
+  }
+
+  private void toggleQuotaCheckAndRestartMiniCluster(boolean enable) throws Exception {
+    TEST_UTIL.shutdownMiniCluster();
+    TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, enable);
+    TEST_UTIL.startMiniCluster(NUM_SLAVES_BASE - 1);
+    TEST_UTIL.getConfiguration().setInt(
+        ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,
+        NUM_SLAVES_BASE - 1);
+    TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
+    initialize();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/7dc20d8a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
index 74433b4..f4e5106 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/CreateTableProcedure.java
@@ -169,6 +169,10 @@ public class CreateTableProcedure
         case CREATE_TABLE_PRE_OPERATION:
           DeleteTableProcedure.deleteTableStates(env, getTableName());
           // TODO-MAYBE: call the deleteTable coprocessor event?
+          final MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost();
+          if (cpHost != null) {
+            cpHost.postDeleteTable(getTableName());
+          }
           ProcedurePrepareLatch.releaseLatch(syncLatch, this);
           break;
         default:


Mime
View raw message