From commits-return-83658-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Mon Mar 4 06:25:22 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id BF2C7180627 for ; Mon, 4 Mar 2019 07:25:21 +0100 (CET) Received: (qmail 75827 invoked by uid 500); 4 Mar 2019 06:25:20 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 75818 invoked by uid 99); 4 Mar 2019 06:25:20 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Mar 2019 06:25:20 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 2A5B687762; Mon, 4 Mar 2019 06:25:20 +0000 (UTC) Date: Mon, 04 Mar 2019 06:25:20 +0000 To: "commits@hbase.apache.org" Subject: [hbase] branch branch-2.2 updated: HBASE-21866 Do not move the table to null rsgroup when creating an existing table MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155168072003.3247.4892280385077508469@gitbox.apache.org> From: zghao@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hbase X-Git-Refname: refs/heads/branch-2.2 X-Git-Reftype: branch X-Git-Oldrev: 9c5b0609a832b9f506f63ee3d51208290cee371a X-Git-Newrev: e64136577485e6c5a1fc006e62bc2c205dfc9b2b X-Git-Rev: e64136577485e6c5a1fc006e62bc2c205dfc9b2b X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. zghao pushed a commit to branch branch-2.2 in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/branch-2.2 by this push: new e641365 HBASE-21866 Do not move the table to null rsgroup when creating an existing table e641365 is described below commit e64136577485e6c5a1fc006e62bc2c205dfc9b2b Author: Xiang Li AuthorDate: Tue Feb 19 07:31:10 2019 +0000 HBASE-21866 Do not move the table to null rsgroup when creating an existing table Signed-off-by: Guanghao Zhang --- .../hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java | 36 ++++++++++++++++++++++ .../master/procedure/CreateTableProcedure.java | 13 +++++--- 2 files changed, 44 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 4d41d36..ca53985 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 @@ -28,9 +28,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; + import org.apache.hadoop.hbase.HBaseClassTestRule; 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.TableNotFoundException; import org.apache.hadoop.hbase.Waiter; @@ -452,6 +455,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() { + @Override + public boolean evaluate() throws Exception { + return + (master.getMasterProcedureExecutor().getActiveExecutorCount() == 0); + } + }); + SortedSet 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 3e144d0..34fde27 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 @@ -139,11 +139,14 @@ public class CreateTableProcedure // nothing to rollback, pre-create is just table-state checks. // We can fail if the table does exist or the descriptor is malformed. // TODO: coprocessor rollback semantic is still undefined. - DeleteTableProcedure.deleteTableStates(env, getTableName()); - - final MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost(); - if (cpHost != null) { - cpHost.postDeleteTable(getTableName()); + if (hasException() /* avoid NPE */ && + getException().getCause().getClass() != TableExistsException.class) { + DeleteTableProcedure.deleteTableStates(env, getTableName()); + + final MasterCoprocessorHost cpHost = env.getMasterCoprocessorHost(); + if (cpHost != null) { + cpHost.postDeleteTable(getTableName()); + } } releaseSyncLatch();