hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1167566 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/regionserver/handler/CloseRegionHandler.java src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
Date Sat, 10 Sep 2011 17:47:46 GMT
Author: stack
Date: Sat Sep 10 17:47:46 2011
New Revision: 1167566

URL: http://svn.apache.org/viewvc?rev=1167566&view=rev
Log:
HBASE-4270 IOE ignored during flush-on-close causes dataloss

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/handler/CloseRegionHandler.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1167566&r1=1167565&r2=1167566&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Sep 10 17:47:46 2011
@@ -563,6 +563,7 @@ Release 0.90.5 - Unreleased
                re-assigns it but the RS warns 'already online on this server'
                (Gaojinchao)
    HBASE-4294  HLogSplitter sleeps with 1-second granularity (todd)
+   HBASE-4270  IOE ignored during flush-on-close causes dataloss
 
   IMPROVEMENT
    HBASE-4205  Enhance HTable javadoc (Eric Charles)

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/handler/CloseRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/handler/CloseRegionHandler.java?rev=1167566&r1=1167565&r2=1167566&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/handler/CloseRegionHandler.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/handler/CloseRegionHandler.java
Sat Sep 10 17:47:46 2011
@@ -125,9 +125,13 @@ public class CloseRegionHandler extends 
             regionInfo.getRegionNameAsString());
           return;
         }
-      } catch (IOException e) {
-        LOG.error("Unrecoverable exception while closing region " +
-          regionInfo.getRegionNameAsString() + ", still finishing close", e);
+      } catch (Throwable t) {
+        // A throwable here indicates that we couldn't successfully flush the
+        // memstore before closing. So, we need to abort the server and allow
+        // the master to split our logs in order to recover the data.
+        server.abort("Unrecoverable exception while closing region " +
+          regionInfo.getRegionNameAsString() + ", still finishing close", t);
+        throw new RuntimeException(t);
       }
 
       this.rsServices.removeFromOnlineRegions(regionInfo.getEncodedName());

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java?rev=1167566&r1=1167565&r2=1167566&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
Sat Sep 10 17:47:46 2011
@@ -19,30 +19,19 @@
  */
 package org.apache.hadoop.hbase.regionserver.handler;
 
+import static org.junit.Assert.*;
+
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.Server;
-import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.ZooKeeperConnectionException;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.ipc.HBaseRpcMetrics;
-import org.apache.hadoop.hbase.regionserver.CompactionRequestor;
-import org.apache.hadoop.hbase.regionserver.FlushRequester;
 import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.RegionServerAccounting;
 import org.apache.hadoop.hbase.regionserver.RegionServerServices;
-import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
@@ -56,7 +45,7 @@ import org.junit.Test;
  * Test of the {@link OpenRegionHandler}.
  */
 public class TestOpenRegionHandler {
-  private static final Log LOG = LogFactory.getLog(TestOpenRegionHandler.class);
+  static final Log LOG = LogFactory.getLog(TestOpenRegionHandler.class);
   private final static HBaseTestingUtility HTU = new HBaseTestingUtility();
 
   @BeforeClass public static void before() throws Exception {
@@ -68,156 +57,6 @@ public class TestOpenRegionHandler {
   }
 
   /**
-   * Basic mock Server
-   */
-  static class MockServer implements Server {
-    boolean stopped = false;
-    final static ServerName NAME = new ServerName("MockServer", 123, -1);
-    final ZooKeeperWatcher zk;
-
-    MockServer() throws ZooKeeperConnectionException, IOException {
-      this.zk =  new ZooKeeperWatcher(HTU.getConfiguration(), NAME.toString(), this, true);
-    }
-
-    @Override
-    public void abort(String why, Throwable e) {
-      LOG.fatal("Abort why=" + why, e);
-      this.stopped = true;
-    }
-
-    @Override
-    public void stop(String why) {
-      LOG.debug("Stop why=" + why);
-      this.stopped = true;
-    }
-
-    @Override
-    public boolean isStopped() {
-      return this.stopped;
-    }
-
-    @Override
-    public Configuration getConfiguration() {
-      return HTU.getConfiguration();
-    }
-
-    @Override
-    public ZooKeeperWatcher getZooKeeper() {
-      return this.zk;
-    }
-
-    @Override
-    public CatalogTracker getCatalogTracker() {
-      // TODO Auto-generated method stub
-      return null;
-    }
-
-    @Override
-    public ServerName getServerName() {
-      return NAME;
-    }
-  }
-
-  /**
-   * Basic mock region server services.
-   */
-  static class MockRegionServerServices implements RegionServerServices {
-    final Map<String, HRegion> regions = new HashMap<String, HRegion>();
-    boolean stopping = false;
-    Set<byte[]> rit = new HashSet<byte[]>();
-
-    @Override
-    public boolean removeFromOnlineRegions(String encodedRegionName) {
-      return this.regions.remove(encodedRegionName) != null;
-    }
-    
-    @Override
-    public HRegion getFromOnlineRegions(String encodedRegionName) {
-      return this.regions.get(encodedRegionName);
-    }
-    
-    @Override
-    public void addToOnlineRegions(HRegion r) {
-      this.regions.put(r.getRegionInfo().getEncodedName(), r);
-    }
-    
-    @Override
-    public void postOpenDeployTasks(HRegion r, CatalogTracker ct, boolean daughter)
-        throws KeeperException, IOException {
-    }
-    
-    @Override
-    public boolean isStopping() {
-      return this.stopping;
-    }
-    
-    @Override
-    public HLog getWAL() {
-      return null;
-    }
-
-    @Override
-    public HBaseRpcMetrics getRpcMetrics() {
-      return null;
-    }
-
-    @Override
-    public Set<byte[]> getRegionsInTransitionInRS() {
-      return rit;
-    }
-
-    @Override
-    public FlushRequester getFlushRequester() {
-      return null;
-    }
-    
-    @Override
-    public CompactionRequestor getCompactionRequester() {
-      return null;
-    }
-
-    @Override
-    public CatalogTracker getCatalogTracker() {
-      return null;
-    }
-
-    @Override
-    public ZooKeeperWatcher getZooKeeper() {
-      return null;
-    }
-    
-    public RegionServerAccounting getRegionServerAccounting() {
-      return null;
-    }
-
-    @Override
-    public ServerName getServerName() {
-      return null;
-    }
-
-    @Override
-    public Configuration getConfiguration() {
-      return null;
-    }
-
-    @Override
-    public void abort(String why, Throwable e) {
-       //no-op
-    }
-
-    @Override
-    public void stop(String why) {
-      //no-op
-    }
-
-    @Override
-    public boolean isStopped() {
-      return false;
-    }
-
-  };
-
-  /**
    * Test the openregionhandler can deal with its znode being yanked out from
    * under it.
    * @see <a href="https://issues.apache.org/jira/browse/HBASE-3627">HBASE-3627</a>
@@ -225,19 +64,19 @@ public class TestOpenRegionHandler {
    * @throws NodeExistsException
    * @throws KeeperException
    */
-  @Test public void testOpenRegionHandlerYankingRegionFromUnderIt()
+  @Test public void testYankingRegionFromUnderIt()
   throws IOException, NodeExistsException, KeeperException {
-    final Server server = new MockServer();
+    final Server server = new MockServer(HTU);
     final RegionServerServices rss = new MockRegionServerServices();
 
-    HTableDescriptor htd =
-      new HTableDescriptor("testOpenRegionHandlerYankingRegionFromUnderIt");
+    HTableDescriptor htd = new HTableDescriptor("TestOpenRegionHandler.java");
     final HRegionInfo hri =
       new HRegionInfo(htd.getName(), HConstants.EMPTY_END_ROW,
           HConstants.EMPTY_END_ROW);
     HRegion region =
          HRegion.createHRegion(hri, HBaseTestingUtility.getTestDir(), HTU
             .getConfiguration(), htd);
+    assertNotNull(region);
     OpenRegionHandler handler = new OpenRegionHandler(server, rss, hri, htd) {
       HRegion openRegion() {
         // Open region first, then remove znode as though it'd been hijacked.
@@ -264,4 +103,4 @@ public class TestOpenRegionHandler {
     // post OPENING; again will expect it to come back w/o NPE or exception.
     handler.process();
   }
-}
+}
\ No newline at end of file



Mime
View raw message