HBASE-22758 Remove the unneccesary info cf deletion in DeleteTableProcedure#deleteFromMeta (#424)

This commit is contained in:
openinx 2019-07-30 14:16:08 +08:00 committed by GitHub
parent 0c80d5b42b
commit c286a31590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 24 deletions

View File

@ -1819,7 +1819,8 @@ public class MetaTableAccessor {
* @param regionInfo region to be deleted from META * @param regionInfo region to be deleted from META
* @throws IOException * @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(); long time = EnvironmentEdgeManager.currentTime();
Delete delete = new Delete(regionInfo.getRegionName()); Delete delete = new Delete(regionInfo.getRegionName());
delete.addFamily(getCatalogFamily(), time); delete.addFamily(getCatalogFamily(), time);
@ -1832,16 +1833,17 @@ public class MetaTableAccessor {
* @param connection connection we're using * @param connection connection we're using
* @param regionsInfo list of regions to be deleted from META * @param regionsInfo list of regions to be deleted from META
*/ */
public static void deleteRegions(Connection connection, List<RegionInfo> regionsInfo) public static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo)
throws IOException { throws IOException {
deleteRegions(connection, regionsInfo, EnvironmentEdgeManager.currentTime()); deleteRegionInfos(connection, regionsInfo, EnvironmentEdgeManager.currentTime());
} }
/** /**
* Deletes the specified regions from META. * Deletes the specified regions from META.
* @param connection connection we're using * @param connection connection we're using
* @param regionsInfo list of regions to be deleted from META * @param regionsInfo list of regions to be deleted from META
*/ */
public static void deleteRegions(Connection connection, List<RegionInfo> regionsInfo, long ts) public static void deleteRegionInfos(Connection connection, List<RegionInfo> regionsInfo, long ts)
throws IOException { throws IOException {
List<Delete> deletes = new ArrayList<>(regionsInfo.size()); List<Delete> deletes = new ArrayList<>(regionsInfo.size());
for (RegionInfo hri : regionsInfo) { for (RegionInfo hri : regionsInfo) {
@ -1860,11 +1862,11 @@ public class MetaTableAccessor {
* @param connection connection we're using * @param connection connection we're using
* @param regionInfos list of regions to be added to META * @param regionInfos list of regions to be added to META
*/ */
public static void overwriteRegions(Connection connection, public static void overwriteRegions(Connection connection, List<RegionInfo> regionInfos,
List<RegionInfo> regionInfos, int regionReplication) throws IOException { int regionReplication) throws IOException {
// use master time for delete marker and the Put // use master time for delete marker and the Put
long now = EnvironmentEdgeManager.currentTime(); 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 // 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. // 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, // See HBASE-9906, and HBASE-9879. Once either HBASE-9879, HBASE-8770 is fixed,

View File

@ -115,7 +115,7 @@ public class GCRegionProcedure extends AbstractStateMachineRegionProcedure<GCReg
am.getRegionStates().deleteRegion(getRegion()); am.getRegionStates().deleteRegion(getRegion());
} }
} }
MetaTableAccessor.deleteRegion(masterServices.getConnection(), getRegion()); MetaTableAccessor.deleteRegionInfo(masterServices.getConnection(), getRegion());
masterServices.getServerManager().removeRegion(getRegion()); masterServices.getServerManager().removeRegion(getRegion());
FavoredNodesManager fnm = masterServices.getFavoredNodesManager(); FavoredNodesManager fnm = masterServices.getFavoredNodesManager();
if (fnm != null) { if (fnm != null) {

View File

@ -260,7 +260,7 @@ public class RegionStateStore {
} }
public void deleteRegions(final List<RegionInfo> regions) throws IOException { public void deleteRegions(final List<RegionInfo> regions) throws IOException {
MetaTableAccessor.deleteRegions(master.getConnection(), regions); MetaTableAccessor.deleteRegionInfos(master.getConnection(), regions);
} }
// ========================================================================== // ==========================================================================

View File

@ -357,12 +357,12 @@ public class DeleteTableProcedure
} }
/** /**
* There may be items for this table still up in hbase:meta in the case where the * There may be items for this table still up in hbase:meta in the case where the info:regioninfo
* info:regioninfo column was empty because of some write error. Remove ALL rows from hbase:meta * column was empty because of some write error. Remove ALL rows from hbase:meta that have to do
* that have to do with this table. See HBASE-12980. * with this table. See HBASE-12980.
*/ */
private static void cleanAnyRemainingRows(final MasterProcedureEnv env, private static void cleanRegionsInMeta(final MasterProcedureEnv env, final TableName tableName)
final TableName tableName) throws IOException { throws IOException {
Connection connection = env.getMasterServices().getConnection(); Connection connection = env.getMasterServices().getConnection();
Scan tableScan = MetaTableAccessor.getScanForTableName(connection, tableName); Scan tableScan = MetaTableAccessor.getScanForTableName(connection, tableName);
try (Table metaTable = connection.getTable(TableName.META_TABLE_NAME)) { try (Table metaTable = connection.getTable(TableName.META_TABLE_NAME)) {
@ -373,19 +373,17 @@ public class DeleteTableProcedure
} }
} }
if (!deletes.isEmpty()) { if (!deletes.isEmpty()) {
LOG.warn("Deleting some vestigial " + deletes.size() + " rows of " + tableName + LOG.warn("Deleting some vestigial " + deletes.size() + " rows of " + tableName + " from "
" from " + TableName.META_TABLE_NAME); + TableName.META_TABLE_NAME);
metaTable.delete(deletes); metaTable.delete(deletes);
} }
} }
} }
protected static void deleteFromMeta(final MasterProcedureEnv env, protected static void deleteFromMeta(final MasterProcedureEnv env, final TableName tableName,
final TableName tableName, List<RegionInfo> regions) throws IOException { List<RegionInfo> regions) throws IOException {
MetaTableAccessor.deleteRegions(env.getMasterServices().getConnection(), regions);
// Clean any remaining rows for this table. // Clean any remaining rows for this table.
cleanAnyRemainingRows(env, tableName); cleanRegionsInMeta(env, tableName);
// clean region references from the server manager // clean region references from the server manager
env.getMasterServices().getServerManager().removeRegions(regions); env.getMasterServices().getServerManager().removeRegions(regions);

View File

@ -437,7 +437,7 @@ public class RestoreSnapshotProcedure
// not overwritten/removed, so you end up with old informations // not overwritten/removed, so you end up with old informations
// that are not correct after the restore. // that are not correct after the restore.
if (regionsToRemove != null) { if (regionsToRemove != null) {
MetaTableAccessor.deleteRegions(conn, regionsToRemove); MetaTableAccessor.deleteRegionInfos(conn, regionsToRemove);
deleteRegionsFromInMemoryStates(regionsToRemove, env, regionReplication); deleteRegionsFromInMemoryStates(regionsToRemove, env, regionReplication);
} }

View File

@ -202,6 +202,6 @@ public class HBaseFsckRepair {
*/ */
public static void removeParentInMeta(Configuration conf, RegionInfo hri) throws IOException { public static void removeParentInMeta(Configuration conf, RegionInfo hri) throws IOException {
Connection conn = ConnectionFactory.createConnection(conf); Connection conn = ConnectionFactory.createConnection(conf);
MetaTableAccessor.deleteRegion(conn, hri); MetaTableAccessor.deleteRegionInfo(conn, hri);
} }
} }

View File

@ -88,7 +88,7 @@ public class TestCatalogJanitorCluster {
assertTrue(report.isEmpty()); assertTrue(report.isEmpty());
// Now remove first region in table t2 to see if catalogjanitor scan notices. // Now remove first region in table t2 to see if catalogjanitor scan notices.
List<RegionInfo> t2Ris = MetaTableAccessor.getTableRegions(TEST_UTIL.getConnection(), T2); List<RegionInfo> 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(); gc = janitor.scan();
report = janitor.getLastReport(); report = janitor.getLastReport();
assertFalse(report.isEmpty()); assertFalse(report.isEmpty());