Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 153297BA2 for ; Thu, 20 Oct 2011 17:36:34 +0000 (UTC) Received: (qmail 53925 invoked by uid 500); 20 Oct 2011 17:36:34 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 53880 invoked by uid 500); 20 Oct 2011 17:36:33 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 53873 invoked by uid 99); 20 Oct 2011 17:36:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Oct 2011 17:36:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Oct 2011 17:36:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8A39E23889DE for ; Thu, 20 Oct 2011 17:36:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1186953 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java Date: Thu, 20 Oct 2011 17:36:10 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111020173610.8A39E23889DE@eris.apache.org> Author: stack Date: Thu Oct 20 17:36:09 2011 New Revision: 1186953 URL: http://svn.apache.org/viewvc?rev=1186953&view=rev Log: HBASE-4378 [hbck] Does not complain about regions with startkey==endkey. Modified: hbase/trunk/CHANGES.txt hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java Modified: hbase/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1186953&r1=1186952&r2=1186953&view=diff ============================================================================== --- hbase/trunk/CHANGES.txt (original) +++ hbase/trunk/CHANGES.txt Thu Oct 20 17:36:09 2011 @@ -375,6 +375,8 @@ Release 0.92.0 - Unreleased HBASE-4620 I broke the build when I submitted HBASE-3581 (Send length of the rpc response) HBASE-4621 TestAvroServer fails quite often intermittently (Akash Ashok) + HBASE-4378 [hbck] Does not complain about regions with startkey==endkey. + (Jonathan Hsieh) TESTS HBASE-4450 test for number of blocks read: to serve as baseline for expected Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1186953&r1=1186952&r2=1186953&view=diff ============================================================================== --- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original) +++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Thu Oct 20 17:36:09 2011 @@ -653,6 +653,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) { @@ -676,12 +687,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 @@ -1047,7 +1058,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/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java?rev=1186953&r1=1186952&r2=1186953&view=diff ============================================================================== --- hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java (original) +++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java Thu Oct 20 17:36:09 2011 @@ -278,6 +278,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.