Review Board 1.7.22


HBASE-5986 - Clients can see holes in the META table when regions are being split

Review Request #5133 - Created May 16, 2012 and updated

enis
HBASE-5986
Reviewers
hbase
hbase-git
We found this issue when running large scale ingestion tests for HBASE-5754. The problem is that the .META. table updates are not atomic while splitting a region. In SplitTransaction, there is a time lap between the marking the parent offline, and adding of daughters to the META table. This can result in clients using MetaScanner, of HTable.getStartEndKeys (used by the TableInputFormat) missing regions which are made just offline, but the daughters are not added yet.

This patch is the approach 2 mentioned in the issue comments, mainly during META scan, if we detect that the region is split, we block until the information for the child regions are available in META and manually feed those rows to the MetaScanner. Although approach 3 (using local region transactions) seems cleaner, they are not available under branch 0.92, which I think should also incorporate this fix. I'll provide ports once we are clear for trunk. 

Also this patch does not fix MetaReader (see https://issues.apache.org/jira/browse/HBASE-3475). 
added extensive tests under TestEndToEndSplitTranscation, and ran existing unit tests. 
src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
Revision 8873512 New Change
[20] 31 lines
[+20]
32
import org.apache.hadoop.hbase.client.Delete;
32
import org.apache.hadoop.hbase.client.Delete;
33
import org.apache.hadoop.hbase.client.HTable;
33
import org.apache.hadoop.hbase.client.HTable;
34
import org.apache.hadoop.hbase.client.Put;
34
import org.apache.hadoop.hbase.client.Put;
35
import org.apache.hadoop.hbase.client.Result;
35
import org.apache.hadoop.hbase.client.Result;
36
import org.apache.hadoop.hbase.util.Bytes;
36
import org.apache.hadoop.hbase.util.Bytes;

    
   
37
import org.apache.hadoop.hbase.util.PairOfSameType;
37
import org.apache.hadoop.hbase.util.Writables;
38
import org.apache.hadoop.hbase.util.Writables;
38

    
   
39

   
39
/**
40
/**
40
 * Writes region and assignment information to <code>.META.</code>.
41
 * Writes region and assignment information to <code>.META.</code>.
41
 * TODO: Put MetaReader and MetaEditor together; doesn't make sense having
42
 * TODO: Put MetaReader and MetaEditor together; doesn't make sense having
[+20] [20] 262 lines
[+20] [+] public static HRegionInfo getHRegionInfo(
304
    HRegionInfo info = Writables.getHRegionInfo(bytes);
305
    HRegionInfo info = Writables.getHRegionInfo(bytes);
305
    LOG.info("Current INFO from scan results = " + info);
306
    LOG.info("Current INFO from scan results = " + info);
306
    return info;
307
    return info;
307
  }
308
  }
308

    
   
309

   

    
   
310
  public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) throws IOException {

    
   
311
    HRegionInfo splitA = Writables.getHRegionInfoOrNull(

    
   
312
        data.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER));

    
   
313
    HRegionInfo splitB = Writables.getHRegionInfoOrNull(

    
   
314
        data.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER));

    
   
315
    

    
   
316
    return new PairOfSameType<HRegionInfo>(splitA, splitB);

    
   
317
  }

    
   
318
  

    
   
319
  
309
  private static Put addRegionInfo(final Put p, final HRegionInfo hri)
320
  private static Put addRegionInfo(final Put p, final HRegionInfo hri)
310
  throws IOException {
321
  throws IOException {
311
    p.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
322
    p.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
312
        Writables.getBytes(hri));
323
        Writables.getBytes(hri));
313
    return p;
324
    return p;
[+20] [20] 10 lines
src/main/java/org/apache/hadoop/hbase/client/HTable.java
Revision b8290e4 New Change
 
src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
Revision f404999 New Change
 
src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
Revision a8091e6 New Change
 
  1. src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java: Loading...
  2. src/main/java/org/apache/hadoop/hbase/client/HTable.java: Loading...
  3. src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java: Loading...
  4. src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java: Loading...