hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1308547 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/
Date Mon, 02 Apr 2012 20:50:29 GMT
Author: stack
Date: Mon Apr  2 20:50:29 2012
New Revision: 1308547

URL: http://svn.apache.org/viewvc?rev=1308547&view=rev
Log:
HBASE-5665 Repeated split causes HRegionServer failures and breaks table

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1308547&r1=1308546&r2=1308547&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Mon
Apr  2 20:50:29 2012
@@ -823,6 +823,16 @@ public class HRegion implements HeapSize
     return this.closing.get();
   }
 
+  /** @return true if region is available (not closed and not closing) */
+  public boolean isAvailable() {
+    return !isClosed() && !isClosing();
+  }
+
+  /** @return true if region is splittable */
+  public boolean isSplittable() {
+    return isAvailable() && !hasReferences();
+  }
+
   boolean areWritesEnabled() {
     synchronized(this.writestate) {
       return this.writestate.writesEnabled;

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1308547&r1=1308546&r2=1308547&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Mon Apr  2 20:50:29 2012
@@ -1912,8 +1912,7 @@ public class HRegionServer implements HR
     try {
       for (Map.Entry<String, HRegion> e: this.onlineRegions.entrySet()) {
         HRegion r = e.getValue();
-        if (!r.getRegionInfo().isMetaRegion()) {
-          if (r.isClosed() || r.isClosing()) continue;
+        if (!r.getRegionInfo().isMetaRegion() && r.isAvailable()) {
           // Don't update zk with this close transition; pass false.
           closeRegion(r.getRegionInfo(), abort, false);
         }
@@ -3133,7 +3132,7 @@ public class HRegionServer implements HR
   protected HRegionInfo[] getMostLoadedRegions() {
     ArrayList<HRegionInfo> regions = new ArrayList<HRegionInfo>();
     for (HRegion r : onlineRegions.values()) {
-      if (r.isClosed() || r.isClosing()) {
+      if (!r.isAvailable()) {
         continue;
       }
       if (regions.size() < numRegionsToReport) {

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java?rev=1308547&r1=1308546&r2=1308547&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
Mon Apr  2 20:50:29 2012
@@ -161,7 +161,7 @@ public class SplitTransaction {
    * <code>false</code> if it is not (e.g. its already closed, etc.).
    */
   public boolean prepare() {
-    if (this.parent.isClosed() || this.parent.isClosing()) return false;
+    if (!this.parent.isSplittable()) return false;
     // Split key can be null if this region is unsplittable; i.e. has refs.
     if (this.splitrow == null) return false;
     HRegionInfo hri = this.parent.getRegionInfo();

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java?rev=1308547&r1=1308546&r2=1308547&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java
Mon Apr  2 20:50:29 2012
@@ -19,6 +19,8 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
+import com.google.common.collect.ImmutableList;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -138,6 +140,28 @@ public class TestSplitTransaction {
   }
 
   /**
+   * Pass a reference store
+   */
+  @Test public void testPrepareWithRegionsWithReference() throws IOException {
+    // create a mock that will act as a reference StoreFile
+    StoreFile storeFileMock  = Mockito.mock(StoreFile.class);
+    when(storeFileMock.isReference()).thenReturn(true);
+
+    // add the mock to the parent stores
+    Store storeMock = Mockito.mock(Store.class);
+    List<StoreFile> storeFileList = new ArrayList<StoreFile>(1);
+    storeFileList.add(storeFileMock);
+    when(storeMock.getStorefiles()).thenReturn(storeFileList);
+    when(storeMock.close()).thenReturn(ImmutableList.copyOf(storeFileList));
+    this.parent.stores.put(Bytes.toBytes(""), storeMock);
+
+    SplitTransaction st = new SplitTransaction(this.parent, GOOD_SPLIT_ROW);
+
+    assertFalse("a region should not be splittable if it has instances of store file references",
+                st.prepare());
+  }
+
+  /**
    * Pass an unreasonable split row.
    */
   @Test public void testPrepareWithBadSplitRow() throws IOException {



Mime
View raw message