You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/10/20 19:38:42 UTC
svn commit: r1186958 - in /hbase/branches/0.90: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
Author: stack
Date: Thu Oct 20 17:38:41 2011
New Revision: 1186958
URL: http://svn.apache.org/viewvc?rev=1186958&view=rev
Log:
HBASE-4378 [hbck] Does not complain about regions with startkey==endkey.
Modified:
hbase/branches/0.90/CHANGES.txt
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1186958&r1=1186957&r2=1186958&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Thu Oct 20 17:38:41 2011
@@ -83,6 +83,8 @@ Release 0.90.5 - Unreleased
via todd)
HBASE-4562 When split doing offlineParentInMeta encounters error, it'll cause data loss
(bluedavy via Lars H)
+ HBASE-4378 [hbck] Does not complain about regions with startkey==endkey.
+ (Jonathan Hsieh)
IMPROVEMENT
HBASE-4205 Enhance HTable javadoc (Eric Charles)
Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1186958&r1=1186957&r2=1186958&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Thu Oct 20 17:38:41 2011
@@ -609,6 +609,17 @@ public class HBaseFsck {
}
}
+ // check for degenerate ranges
+ for (HbckInfo rng : ranges) {
+ // special endkey case converts '' to null
+ byte[] endKey = rng.getEndKey();
+ endKey = (endKey.length == 0) ? null : endKey;
+ if (Bytes.equals(rng.getStartKey(),endKey)) {
+ errors.reportError(ERROR_CODE.DEGENERATE_REGION,
+ "Region has the same start and end key.", this, rng);
+ }
+ }
+
if (ranges.size() == 1) {
// this split key is ok -- no overlap, not a hole.
if (problemKey != null) {
@@ -632,12 +643,12 @@ public class HBaseFsck {
subRange.remove(r1);
for (HbckInfo r2 : subRange) {
if (Bytes.compareTo(r1.getStartKey(), r2.getStartKey())==0) {
- // dup start key
- errors.reportError(ERROR_CODE.DUPE_STARTKEYS,
- "Multiple regions have the same startkey: "
- + Bytes.toStringBinary(key), this, r1);
- errors.reportError(ERROR_CODE.DUPE_STARTKEYS,
- "Multiple regions have the same startkey: "
+ // dup start key
+ errors.reportError(ERROR_CODE.DUPE_STARTKEYS,
+ "Multiple regions have the same startkey: "
+ + Bytes.toStringBinary(key), this, r1);
+ errors.reportError(ERROR_CODE.DUPE_STARTKEYS,
+ "Multiple regions have the same startkey: "
+ Bytes.toStringBinary(key), this, r2);
} else {
// overlap
@@ -1009,7 +1020,7 @@ public class HBaseFsck {
NOT_IN_META_OR_DEPLOYED, NOT_IN_HDFS_OR_DEPLOYED, NOT_IN_HDFS, SERVER_DOES_NOT_MATCH_META, NOT_DEPLOYED,
MULTI_DEPLOYED, SHOULD_NOT_BE_DEPLOYED, MULTI_META_REGION, RS_CONNECT_FAILURE,
FIRST_REGION_STARTKEY_NOT_EMPTY, DUPE_STARTKEYS,
- HOLE_IN_REGION_CHAIN, OVERLAP_IN_REGION_CHAIN, REGION_CYCLE
+ HOLE_IN_REGION_CHAIN, OVERLAP_IN_REGION_CHAIN, REGION_CYCLE, DEGENERATE_REGION
}
public void clear();
public void report(String message);
Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java?rev=1186958&r1=1186957&r2=1186958&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java Thu Oct 20 17:38:41 2011
@@ -225,6 +225,32 @@ public class TestHBaseFsck {
deleteTable(table);
}
}
+
+ /**
+ * This creates a bad table with regions that has startkey == endkey
+ */
+ @Test
+ public void testDegenerateRegions() throws Exception {
+ String table = "tableDegenerateRegions";
+ try {
+ setupTable(table);
+ assertNoErrors(doFsck(false));
+
+ // Now let's mess it up, by adding a region with a duplicate startkey
+ HRegionInfo hriDupe = createRegion(conf, tbl.getTableDescriptor(),
+ Bytes.toBytes("B"), Bytes.toBytes("B"));
+ TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriDupe);
+ TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
+ .waitForAssignment(hriDupe);
+
+ HBaseFsck hbck = doFsck(false);
+ assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.DEGENERATE_REGION,
+ ERROR_CODE.DUPE_STARTKEYS, ERROR_CODE.DUPE_STARTKEYS});
+ assertEquals(2, hbck.getOverlapGroups(table).size());
+ } finally {
+ deleteTable(table);
+ }
+ }
/**
* This creates a bad table where a start key contained in another region.