From 892aa832adc1a134493cb7984d6e36514ead9cd9 Mon Sep 17 00:00:00 2001 From: openinx Date: Tue, 30 Jul 2019 14:16:08 +0800 Subject: [PATCH] HBASE-22758 Remove the unneccesary info cf deletion in DeleteTableProcedure#deleteFromMeta (#424) --- .../apache/hadoop/hbase/MetaTableAccessor.java | 16 +++++++++------- .../master/assignment/GCRegionProcedure.java | 2 +- .../master/assignment/RegionStateStore.java | 2 +- .../master/procedure/DeleteTableProcedure.java | 16 +++++++--------- .../procedure/RestoreSnapshotProcedure.java | 2 +- .../hadoop/hbase/util/HBaseFsckRepair.java | 2 +- .../TestLoadIncrementalHFilesSplitRecovery.java | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java index 60afaca3895..d0c09c4341f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java @@ -1807,7 +1807,8 @@ public class MetaTableAccessor { * @param regionInfo region to be deleted from META * @throws IOException */ - public static void deleteRegion(Connection connection, RegionInfo regionInfo) throws IOException { + public static void deleteRegionInfo(Connection connection, RegionInfo regionInfo) + throws IOException { long time = EnvironmentEdgeManager.currentTime(); Delete delete = new Delete(regionInfo.getRegionName()); delete.addFamily(getCatalogFamily(), time); @@ -1820,16 +1821,17 @@ public class MetaTableAccessor { * @param connection connection we're using * @param regionsInfo list of regions to be deleted from META */ - public static void deleteRegions(Connection connection, List regionsInfo) + public static void deleteRegionInfos(Connection connection, List regionsInfo) throws IOException { - deleteRegions(connection, regionsInfo, EnvironmentEdgeManager.currentTime()); + deleteRegionInfos(connection, regionsInfo, EnvironmentEdgeManager.currentTime()); } + /** * Deletes the specified regions from META. * @param connection connection we're using * @param regionsInfo list of regions to be deleted from META */ - public static void deleteRegions(Connection connection, List regionsInfo, long ts) + public static void deleteRegionInfos(Connection connection, List regionsInfo, long ts) throws IOException { List deletes = new ArrayList<>(regionsInfo.size()); for (RegionInfo hri : regionsInfo) { @@ -1848,11 +1850,11 @@ public class MetaTableAccessor { * @param connection connection we're using * @param regionInfos list of regions to be added to META */ - public static void overwriteRegions(Connection connection, - List regionInfos, int regionReplication) throws IOException { + public static void overwriteRegions(Connection connection, List regionInfos, + int regionReplication) throws IOException { // use master time for delete marker and the Put long now = EnvironmentEdgeManager.currentTime(); - deleteRegions(connection, regionInfos, now); + deleteRegionInfos(connection, regionInfos, now); // Why sleep? This is the easiest way to ensure that the previous deletes does not // eclipse the following puts, that might happen in the same ts from the server. // See HBASE-9906, and HBASE-9879. Once either HBASE-9879, HBASE-8770 is fixed, diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/GCRegionProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/GCRegionProcedure.java index efd9beaeb6a..8529a49e0c6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/GCRegionProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/GCRegionProcedure.java @@ -115,7 +115,7 @@ public class GCRegionProcedure extends AbstractStateMachineRegionProcedure regions) throws IOException { - MetaTableAccessor.deleteRegions(master.getConnection(), regions); + MetaTableAccessor.deleteRegionInfos(master.getConnection(), regions); } // ========================================================================== 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 4ebc3c2ab5c..e3f6132cdc9 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 @@ -357,8 +357,8 @@ public class DeleteTableProcedure * that have to do with this table. See HBASE-12980. * @throws IOException */ - private static void cleanAnyRemainingRows(final MasterProcedureEnv env, - final TableName tableName) throws IOException { + private static void cleanRegionsInMeta(final MasterProcedureEnv env, final TableName tableName) + throws IOException { Connection connection = env.getMasterServices().getConnection(); Scan tableScan = MetaTableAccessor.getScanForTableName(connection, tableName); try (Table metaTable = connection.getTable(TableName.META_TABLE_NAME)) { @@ -369,19 +369,17 @@ public class DeleteTableProcedure } } if (!deletes.isEmpty()) { - LOG.warn("Deleting some vestigial " + deletes.size() + " rows of " + tableName + - " from " + TableName.META_TABLE_NAME); + LOG.warn("Deleting some vestigial " + deletes.size() + " rows of " + tableName + " from " + + TableName.META_TABLE_NAME); metaTable.delete(deletes); } } } - protected static void deleteFromMeta(final MasterProcedureEnv env, - final TableName tableName, List regions) throws IOException { - MetaTableAccessor.deleteRegions(env.getMasterServices().getConnection(), regions); - + protected static void deleteFromMeta(final MasterProcedureEnv env, final TableName tableName, + List regions) throws IOException { // Clean any remaining rows for this table. - cleanAnyRemainingRows(env, tableName); + cleanRegionsInMeta(env, tableName); // clean region references from the server manager env.getMasterServices().getServerManager().removeRegions(regions); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java index f542449b691..80fc544736e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RestoreSnapshotProcedure.java @@ -437,7 +437,7 @@ public class RestoreSnapshotProcedure // not overwritten/removed, so you end up with old informations // that are not correct after the restore. if (regionsToRemove != null) { - MetaTableAccessor.deleteRegions(conn, regionsToRemove); + MetaTableAccessor.deleteRegionInfos(conn, regionsToRemove); deleteRegionsFromInMemoryStates(regionsToRemove, env, regionReplication); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java index ec7f717cf61..dd40954f40f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java @@ -199,6 +199,6 @@ public class HBaseFsckRepair { */ public static void removeParentInMeta(Configuration conf, RegionInfo hri) throws IOException { Connection conn = ConnectionFactory.createConnection(conf); - MetaTableAccessor.deleteRegion(conn, hri); + MetaTableAccessor.deleteRegionInfo(conn, hri); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestLoadIncrementalHFilesSplitRecovery.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestLoadIncrementalHFilesSplitRecovery.java index a4b99a11b75..17ee0f6664c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestLoadIncrementalHFilesSplitRecovery.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestLoadIncrementalHFilesSplitRecovery.java @@ -592,7 +592,7 @@ public class TestLoadIncrementalHFilesSplitRecovery { List regionInfos = MetaTableAccessor.getTableRegions(connection, tableName); for (RegionInfo regionInfo : regionInfos) { if (Bytes.equals(regionInfo.getStartKey(), HConstants.EMPTY_BYTE_ARRAY)) { - MetaTableAccessor.deleteRegion(connection, regionInfo); + MetaTableAccessor.deleteRegionInfo(connection, regionInfo); break; } }