You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by xu...@apache.org on 2019/02/18 18:56:51 UTC

[hbase] branch branch-1 updated: HBASE-21866 Do not move the table to null rsgroup when creating an existing table

This is an automated email from the ASF dual-hosted git repository.

xucang pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1 by this push:
     new ed6939f  HBASE-21866 Do not move the table to null rsgroup when creating an existing table
ed6939f is described below

commit ed6939f94a1ec1b9bd933a8e2dd317ee93ecff97
Author: Xiang Li <li...@freewheel.tv>
AuthorDate: Sat Feb 16 08:57:25 2019 +0000

    HBASE-21866 Do not move the table to null rsgroup when creating an existing table
---
 .../hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java   | 35 ++++++++++++++++++++++
 .../master/procedure/CreateTableProcedure.java     | 13 ++++----
 2 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
index ad25097..1d16e66 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
@@ -30,6 +30,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -37,6 +38,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.constraint.ConstraintException;
@@ -424,6 +426,39 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
 
   }
 
+  @Test
+  public void testNotMoveTableToNullRSGroupWhenCreatingExistingTable()
+          throws Exception {
+    // Trigger
+    TableName tn1 = TableName.valueOf("t1");
+    TEST_UTIL.createTable(tn1, "cf1");
+    try {
+      // Create an existing table to trigger HBASE-21866
+      TEST_UTIL.createTable(tn1, "cf1");
+    } catch (TableExistsException teex) {
+      // Ignore
+    }
+
+    // Wait then verify
+    //   Could not verify until the rollback of CreateTableProcedure is done
+    //   (that is, the coprocessor finishes its work),
+    //   or the table is still in the "default" rsgroup even though HBASE-21866
+    //   is not fixed.
+    TEST_UTIL.waitFor(5000, new Waiter.Predicate<Exception>() {
+      @Override
+      public boolean evaluate() throws Exception {
+        return
+            (master.getMasterProcedureExecutor().getActiveExecutorCount() == 0);
+      }
+    });
+    SortedSet<TableName> tables
+        = rsGroupAdmin.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables();
+    assertTrue("Table 't1' must be in 'default' rsgroup", tables.contains(tn1));
+
+    // Cleanup
+    TEST_UTIL.deleteTable(tn1);
+  }
+
   private void toggleQuotaCheckAndRestartMiniCluster(boolean enable) throws Exception {
     TEST_UTIL.shutdownMiniCluster();
     TEST_UTIL.getConfiguration().setBoolean(QuotaUtil.QUOTA_CONF_KEY, enable);
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 f4e5106..f3218ee 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
@@ -167,11 +167,14 @@ public class CreateTableProcedure
           DeleteTableProcedure.deleteFromFs(env, getTableName(), newRegions, false);
           break;
         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());
+          if (hasException() /* avoid NPE */ &&
+              getException().getCause().getClass() != TableExistsException.class) {
+            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;