@Test
  public void testDeleteForSureClearsAllTableRowsFromMeta()
    throws IOException, InterruptedException {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    final Admin admin = TEST_UTIL.getAdmin();
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILYNAME)).build();
    try {
      createTable(TEST_UTIL, tableDescriptor, HBaseTestingUtil.KEYS_FOR_HBA_CREATE_TABLE);
    } catch (Exception e) {
      LOG.error("", e);
      fail("Got an exception while creating " + tableName);
    }
    // Now I have a nice table, mangle it by removing the HConstants.REGIONINFO_QUALIFIER_STR
    // content from a few of the rows.
    try (Table metaTable = TEST_UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
      try (ResultScanner scanner = metaTable.getScanner(
        MetaTableAccessor.getScanForTableName(TEST_UTIL.getConfiguration(), tableName))) {
        for (Result result : scanner) {
          // Just delete one row.
          Delete d = new Delete(result.getRow());
          d.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
          LOG.info("Mangled: " + d);
          metaTable.delete(d);
          break;
        }
      }
      admin.disableTable(tableName);
      TEST_UTIL.waitTableDisabled(tableName.getName());
      // Rely on the coprocessor based latch to make the operation synchronous.
      try {
        deleteTable(TEST_UTIL, tableName);
      } catch (Exception e) {
        LOG.error("", e);
        fail("Got an exception while deleting " + tableName);
      }
      int rowCount = 0;
      try (ResultScanner scanner = metaTable.getScanner(
        MetaTableAccessor.getScanForTableName(TEST_UTIL.getConfiguration(), tableName))) {
        for (Result result : scanner) {
          LOG.info("Found when none expected: " + result);
          rowCount++;
        }
      }
      assertEquals(0, rowCount);
    }
  }
We were only clearing rows that had a hregioninfo column in hbase:meta. Mangled rows that were
missing the hregioninfo because of error were being left behind messing up any subsequent table
made with the same name. HBASE-12980
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestEnableTable.java