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 23ad3b42aef0..17998fec7bd7 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 @@ -35,15 +35,12 @@ import org.apache.hadoop.hbase.master.MasterCoprocessorHost; import org.apache.hadoop.hbase.master.MasterFileSystem; import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer; -import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException; -import org.apache.hadoop.hbase.procedure2.ProcedureUtil; import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory; import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerValidationUtils; import org.apache.hadoop.hbase.rsgroup.RSGroupInfo; import org.apache.hadoop.hbase.util.CommonFSUtils; import org.apache.hadoop.hbase.util.FSTableDescriptors; import org.apache.hadoop.hbase.util.ModifyRegionUtils; -import org.apache.hadoop.hbase.util.RetryCounter; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +51,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.CreateTableState; -import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos; @InterfaceAudience.Private public class CreateTableProcedure extends AbstractStateMachineTableProcedure { @@ -64,7 +60,6 @@ public class CreateTableProcedure extends AbstractStateMachineTableProcedure newRegions; - private RetryCounter retryCounter; public CreateTableProcedure() { // Required by the Procedure framework to create the procedure on replay @@ -85,7 +80,7 @@ public CreateTableProcedure(final MasterProcedureEnv env, final TableDescriptor @Override protected Flow executeFromState(final MasterProcedureEnv env, final CreateTableState state) - throws InterruptedException, ProcedureSuspendedException { + throws InterruptedException { LOG.info("{} execute state={}", this, state); try { switch (state) { @@ -136,7 +131,6 @@ protected Flow executeFromState(final MasterProcedureEnv env, final CreateTableS break; case CREATE_TABLE_POST_OPERATION: postCreate(env); - retryCounter = null; return Flow.NO_MORE_STATE; default: throw new UnsupportedOperationException("unhandled state=" + state); @@ -145,26 +139,12 @@ protected Flow executeFromState(final MasterProcedureEnv env, final CreateTableS if (isRollbackSupported(state)) { setFailure("master-create-table", e); } else { - if (retryCounter == null) { - retryCounter = ProcedureUtil.createRetryCounter(env.getMasterConfiguration()); - } - long backoff = retryCounter.getBackoffTimeAndIncrementAttempts(); - LOG.warn("Retriable error trying to create table={},state={},suspend {}secs.", - getTableName(), state, backoff / 1000, e); - throw suspend(Math.toIntExact(backoff), true); + LOG.warn("Retriable error trying to create table=" + getTableName() + " state=" + state, e); } } - retryCounter = null; return Flow.HAS_MORE_STATE; } - @Override - protected synchronized boolean setTimeoutFailure(MasterProcedureEnv env) { - setState(ProcedureProtos.ProcedureState.RUNNABLE); - env.getProcedureScheduler().addFront(this); - return false; - } - @Override protected void rollbackState(final MasterProcedureEnv env, final CreateTableState state) throws IOException { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java index 8c2f1067c952..80fb5d0534d4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java @@ -41,12 +41,9 @@ import org.apache.hadoop.hbase.mob.MobConstants; import org.apache.hadoop.hbase.mob.MobUtils; import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer; -import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException; -import org.apache.hadoop.hbase.procedure2.ProcedureUtil; import org.apache.hadoop.hbase.util.CommonFSUtils; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.FSUtils; -import org.apache.hadoop.hbase.util.RetryCounter; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +54,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos; import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.DeleteTableState; -import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos; @InterfaceAudience.Private public class DeleteTableProcedure extends AbstractStateMachineTableProcedure { @@ -65,7 +61,6 @@ public class DeleteTableProcedure extends AbstractStateMachineTableProcedure regions; private TableName tableName; - private RetryCounter retryCounter; public DeleteTableProcedure() { // Required by the Procedure framework to create the procedure on replay @@ -84,7 +79,7 @@ public DeleteTableProcedure(final MasterProcedureEnv env, final TableName tableN @Override protected Flow executeFromState(final MasterProcedureEnv env, DeleteTableState state) - throws InterruptedException, ProcedureSuspendedException { + throws InterruptedException { if (LOG.isTraceEnabled()) { LOG.trace(this + " execute state=" + state); } @@ -129,7 +124,6 @@ protected Flow executeFromState(final MasterProcedureEnv env, DeleteTableState s break; case DELETE_TABLE_POST_OPERATION: postDelete(env); - retryCounter = null; LOG.debug("Finished {}", this); return Flow.NO_MORE_STATE; default: @@ -139,26 +133,12 @@ protected Flow executeFromState(final MasterProcedureEnv env, DeleteTableState s if (isRollbackSupported(state)) { setFailure("master-delete-table", e); } else { - if (retryCounter == null) { - retryCounter = ProcedureUtil.createRetryCounter(env.getMasterConfiguration()); - } - long backoff = retryCounter.getBackoffTimeAndIncrementAttempts(); - LOG.warn("Retriable error trying to delete table={},state={},suspend {}secs.", - getTableName(), state, backoff / 1000, e); - throw suspend(Math.toIntExact(backoff), true); + LOG.warn("Retriable error trying to delete table=" + getTableName() + " state=" + state, e); } } - retryCounter = null; return Flow.HAS_MORE_STATE; } - @Override - protected synchronized boolean setTimeoutFailure(MasterProcedureEnv env) { - setState(ProcedureProtos.ProcedureState.RUNNABLE); - env.getProcedureScheduler().addFront(this); - return false; - } - @Override protected boolean abort(MasterProcedureEnv env) { // TODO: Current behavior is: with no rollback and no abort support, procedure may get stuck diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/BadMasterObserverForCreateDeleteTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/BadMasterObserverForCreateDeleteTable.java deleted file mode 100644 index 454a24e198aa..000000000000 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/BadMasterObserverForCreateDeleteTable.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hbase.coprocessor; - -import java.io.IOException; -import java.util.Optional; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.RegionInfo; -import org.apache.hadoop.hbase.client.TableDescriptor; - -/** - * A bad Master Observer to prevent user to create/delete table once. - */ -public class BadMasterObserverForCreateDeleteTable implements MasterObserver, MasterCoprocessor { - private boolean createFailedOnce = false; - private boolean deleteFailedOnce = false; - - @Override - public void postCompletedCreateTableAction(ObserverContext ctx, - TableDescriptor desc, RegionInfo[] regions) throws IOException { - if (!createFailedOnce && !desc.getTableName().isSystemTable()) { - createFailedOnce = true; - throw new IOException("execute postCompletedCreateTableAction failed once."); - } - } - - @Override - public void postCompletedDeleteTableAction(ObserverContext ctx, - TableName tableName) throws IOException { - if (!deleteFailedOnce && !tableName.isSystemTable()) { - deleteFailedOnce = true; - throw new IOException("execute postCompletedDeleteTableAction failed once."); - } - } - - @Override - public Optional getMasterObserver() { - return Optional.of(this); - } -} diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateDeleteTableProcedureWithRetry.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateDeleteTableProcedureWithRetry.java deleted file mode 100644 index 3491aa639844..000000000000 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateDeleteTableProcedureWithRetry.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hbase.master.procedure; - -import java.io.IOException; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HBaseClassTestRule; -import org.apache.hadoop.hbase.HBaseTestingUtil; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.RegionInfo; -import org.apache.hadoop.hbase.client.TableDescriptor; -import org.apache.hadoop.hbase.coprocessor.BadMasterObserverForCreateDeleteTable; -import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; -import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; -import org.apache.hadoop.hbase.testclassification.MasterTests; -import org.apache.hadoop.hbase.testclassification.MediumTests; -import org.apache.hadoop.hbase.util.ModifyRegionUtils; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -@Category({ MasterTests.class, MediumTests.class }) -public class TestCreateDeleteTableProcedureWithRetry { - @ClassRule - public static final HBaseClassTestRule CLASS_RULE = - HBaseClassTestRule.forClass(TestCreateDeleteTableProcedureWithRetry.class); - - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); - - private static final TableName TABLE_NAME = - TableName.valueOf(TestCreateDeleteTableProcedureWithRetry.class.getSimpleName()); - - private static final String CF = "cf"; - - @BeforeClass - public static void setUp() throws Exception { - Configuration conf = UTIL.getConfiguration(); - conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, - BadMasterObserverForCreateDeleteTable.class.getName()); - UTIL.startMiniCluster(1); - } - - @AfterClass - public static void tearDown() throws Exception { - UTIL.shutdownMiniCluster(); - } - - @Test - public void testCreateDeleteTableRetry() throws IOException { - ProcedureExecutor procExec = - UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor(); - TableDescriptor htd = MasterProcedureTestingUtility.createHTD(TABLE_NAME, CF); - RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, null); - CreateTableProcedure createProc = - new CreateTableProcedure(procExec.getEnvironment(), htd, regions); - ProcedureTestingUtility.submitAndWait(procExec, createProc); - Assert.assertTrue(UTIL.getAdmin().tableExists(TABLE_NAME)); - MasterProcedureTestingUtility.validateTableCreation(UTIL.getMiniHBaseCluster().getMaster(), - TABLE_NAME, regions, CF); - - UTIL.getAdmin().disableTable(TABLE_NAME); - DeleteTableProcedure deleteProc = - new DeleteTableProcedure(procExec.getEnvironment(), TABLE_NAME); - ProcedureTestingUtility.submitAndWait(procExec, deleteProc); - Assert.assertFalse(UTIL.getAdmin().tableExists(TABLE_NAME)); - MasterProcedureTestingUtility.validateTableDeletion(UTIL.getMiniHBaseCluster().getMaster(), - TABLE_NAME); - } -} diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java index 0bb54cc190e3..bed41f4da86c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java @@ -39,7 +39,6 @@ import org.apache.hadoop.hbase.master.MasterFileSystem; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerFactory; import org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileTrackerForTest; @@ -245,8 +244,7 @@ public CreateTableProcedureOnHDFSFailure(final MasterProcedureEnv env, @Override protected Flow executeFromState(MasterProcedureEnv env, - MasterProcedureProtos.CreateTableState state) - throws InterruptedException, ProcedureSuspendedException { + MasterProcedureProtos.CreateTableState state) throws InterruptedException { if ( !failOnce && state == MasterProcedureProtos.CreateTableState.CREATE_TABLE_WRITE_FS_LAYOUT