Review Board 1.7.22


HBASE-5801 [hbck] Hbck should handle case where some regions have different HTD settings in .regioninfo files (0.90 specific)

Review Request #4833 - Created April 20, 2012 and submitted

Jimmy Xiang
0.90
HBASE-5801
Reviewers
hbase
jmhsieh
hbase-git
Added option to fix inconsistent table descriptors:
1. sideline the current .regioninfo file
2. create a new one with HTD from HBaseAdmin (meta, first entry)
3. offline the region and wait till it assigned again
TestHBaseFsck* are green. On live cluster, it does the fix as expected. 

Changes between revision 2 and 3

1 2 3
1 2 3

  1. src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java: Loading...
  2. src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java: Loading...
src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
Diff Revision 2 Diff Revision 3
[20] 1233 lines
[+20] [+] private void fixTableDescConsistency(final String key, final HbckInfo hbi)
1234
        Path sidelineTableDir= new Path(getSidelineDir(), tableName);
1234
        Path sidelineTableDir= new Path(getSidelineDir(), tableName);
1235
        Path sidelineRegionDir = new Path(sidelineTableDir, regionDir.getName());
1235
        Path sidelineRegionDir = new Path(sidelineTableDir, regionDir.getName());
1236
        Path regioninfoSidelinPath = new Path(sidelineRegionDir, HRegion.REGIONINFO_FILE);
1236
        Path regioninfoSidelinPath = new Path(sidelineRegionDir, HRegion.REGIONINFO_FILE);
1237
        FileSystem fs = FileSystem.get(admin.getConfiguration());
1237
        FileSystem fs = FileSystem.get(admin.getConfiguration());
1238
        fs.mkdirs(sidelineRegionDir);
1238
        fs.mkdirs(sidelineRegionDir);
1239
        fs.rename(regioninfoPath, regioninfoSidelinPath);
1239
        boolean success = fs.rename(regioninfoPath, regioninfoSidelinPath);

    
   
1240
        if (!success) {

    
   
1241
          String msg = "Unable to rename file " + regioninfoPath +  " to " + regioninfoSidelinPath;

    
   
1242
          LOG.error(msg);

    
   
1243
          throw new IOException(msg);

    
   
1244
        }
1240

    
   
1245

   
1241
        // then fix the table desc: create a new .regioninfo,
1246
        // then fix the table desc: create a new .regioninfo,
1242
        //   offline the region and wait till it's assigned again.
1247
        //   offline the region and wait till it's assigned again.
1243
        hri.setTableDesc(htd);
1248
        hri.setTableDesc(htd);
1244
        Path tmpDir = new Path(sidelineRegionDir, ".tmp");
1249
        Path tmpDir = new Path(sidelineRegionDir, ".tmp");
[+20] [20] 341 lines
[+20] [+] private void trackHTD(HbckInfo hir) {
1586
      if (htds.size() != 1) {
1591
      if (htds.size() != 1) {
1587
        if (htdFromAdmin == null) {
1592
        if (htdFromAdmin == null) {
1588
          LOG.warn("None/Multiple table descriptors found for table '"
1593
          LOG.warn("None/Multiple table descriptors found for table '"
1589
            + tableName + "' regions: " + htds);
1594
            + tableName + "' regions: " + htds);
1590
          htdFromAdmin = admin.getTableDescriptor(Bytes.toBytes(tableName));
1595
          htdFromAdmin = admin.getTableDescriptor(Bytes.toBytes(tableName));
1591
          LOG.info("Use this one from meta instead" + htdFromAdmin);
1596
          LOG.warn("Use this one from meta instead" + htdFromAdmin);
1592
        }
1597
        }
1593
        return htdFromAdmin;
1598
        return htdFromAdmin;
1594
      }
1599
      }
1595
      return (HTableDescriptor)htds.toArray()[0];
1600
      return (HTableDescriptor)htds.toArray()[0];
1596
    }
1601
    }
[+20] [20] 873 lines
[+20] [+] public int compare(HbckInfo l, HbckInfo r) {
2470
   * Prints summary of all tables found on the system.
2475
   * Prints summary of all tables found on the system.
2471
   */
2476
   */
2472
  private void printTableSummary(TreeMap<String, TableInfo> tablesInfo) {
2477
  private void printTableSummary(TreeMap<String, TableInfo> tablesInfo) {
2473
    System.out.println("Summary:");
2478
    System.out.println("Summary:");
2474
    if (isMultiTableDescFound()) {
2479
    if (isMultiTableDescFound()) {
2475
      System.out.println("  Mutliple table descriptors were found.\n"
2480
      System.out.println("  Multiple table descriptors were found.\n"
2476
        + "    You can ignore it if your cluster is working fine.\n"
2481
        + "    You can ignore it if your cluster is working fine.\n"
2477
        + "    To fix it, please re-run hbck with option -fixTableDesc\n");
2482
        + "    To fix it, please re-run hbck with option -fixTableDesc\n");
2478
    }
2483
    }
2479

    
   
2484

   
2480
    for (TableInfo tInfo : tablesInfo.values()) {
2485
    for (TableInfo tInfo : tablesInfo.values()) {
[+20] [20] 668 lines
src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
Diff Revision 2 Diff Revision 3
 
  1. src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java: Loading...
  2. src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java: Loading...