From 300f9062007000717e3d98fc0ba0dc9f18be2dd4 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) --- .../hadoop/hbase/MetaTableAccessor.java | 16 ++++++++------ .../master/assignment/GCRegionProcedure.java | 2 +- .../master/assignment/RegionStateStore.java | 2 +- .../procedure/DeleteTableProcedure.java | 22 +++++++++---------- .../procedure/RestoreSnapshotProcedure.java | 2 +- .../hadoop/hbase/util/HBaseFsckRepair.java | 2 +- .../master/TestCatalogJanitorCluster.java | 2 +- ...estLoadIncrementalHFilesSplitRecovery.java | 2 +- 8 files changed, 25 insertions(+), 25 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 ed18d3da501..f3910936b04 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 @@ -1819,7 +1819,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); @@ -1832,16 +1833,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) { @@ -1860,11 +1862,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 a8e3a334b36..b50f4baec6b 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,12 +357,12 @@ public class DeleteTableProcedure } /** - * There may be items for this table still up in hbase:meta in the case where the - * info:regioninfo column was empty because of some write error. Remove ALL rows from hbase:meta - * that have to do with this table. See HBASE-12980. + * There may be items for this table still up in hbase:meta in the case where the info:regioninfo + * column was empty because of some write error. Remove ALL rows from hbase:meta that have to do + * with this table. See HBASE-12980. */ - 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)) { @@ -373,19 +373,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/master/TestCatalogJanitorCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorCluster.java index 3004a4efd0c..d9fb07369e0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitorCluster.java @@ -88,7 +88,7 @@ public class TestCatalogJanitorCluster { assertTrue(report.isEmpty()); // Now remove first region in table t2 to see if catalogjanitor scan notices. List t2Ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), T2); - MetaTableAccessor.deleteRegion(TEST_UTIL.getConnection(), t2Ris.get(0)); + MetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), t2Ris.get(0)); gc = janitor.scan(); report = janitor.getLastReport(); assertFalse(report.isEmpty()); 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; } }