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 2010/05/13 00:26:31 UTC

svn commit: r943723 - in /hadoop/hbase/branches/0.20: ./ src/java/org/apache/hadoop/hbase/master/ src/test/org/apache/hadoop/hbase/

Author: stack
Date: Wed May 12 22:26:30 2010
New Revision: 943723

URL: http://svn.apache.org/viewvc?rev=943723&view=rev
Log:
HBASE-2525 If one-RS only and its restarted before its shutdown is completely processed, we'll never complete shutdown processing

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/TestZooKeeper.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=943723&r1=943722&r2=943723&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Wed May 12 22:26:30 2010
@@ -125,6 +125,8 @@ Release X.X.X - Unreleased
    HBASE-2413  Master does not respect generation stamps, may result in meta
                getting permanently offlined
    HBASE-2515  ChangeTableState considers split&&offline regions as being served
+   HBASE-2525  If one-RS only and its restarted before its shutdown is completely
+               processed, we'll never complete shutdown processing
 
   IMPROVEMENTS
    HBASE-2180  Bad read performance from synchronizing hfile.fddatainputstream

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java?rev=943723&r1=943722&r2=943723&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java Wed May 12 22:26:30 2010
@@ -45,6 +45,8 @@ import org.apache.hadoop.hbase.master.Re
  * serving, and the regions need to get reassigned.
  */
 class ProcessServerShutdown extends RegionServerOperation {
+  // Server name made of the concatenation of hostname, port and startcode
+  // formatted as <code>&lt;hostname> ',' &lt;port> ',' &lt;startcode></code>
   private final String deadServer;
   private boolean isRootServer;
   private List<MetaRegion> metaRegions;
@@ -86,7 +88,7 @@ class ProcessServerShutdown extends Regi
   private void closeMetaRegions() {
     this.isRootServer =
       this.master.regionManager.isRootServer(this.deadServerAddress) ||
-      this.master.regionManager.isRootServerCandidate (deadServer);
+      this.master.regionManager.isRootInTransitionOnThisServer(deadServer);
     if (this.isRootServer) {
       this.master.regionManager.unsetRootRegion();
     }
@@ -157,7 +159,7 @@ class ProcessServerShutdown extends Regi
         // Check server name.  If null, skip (We used to consider it was on
         // shutdown server but that would mean that we'd reassign regions that
         // were already out being assigned, ones that were product of a split
-        // that happened while the shutdown was being processed.
+        // that happened while the shutdown was being processed).
         String serverAddress = BaseScanner.getServerAddress(values);
         long startCode = BaseScanner.getStartCode(values);
 
@@ -175,7 +177,6 @@ class ProcessServerShutdown extends Regi
             Bytes.toString(row));
         }
 
-//        HRegionInfo info = master.getHRegionInfo(row, values.rowResult());
         HRegionInfo info = master.getHRegionInfo(row, values);
         if (info == null) {
           emptyRows.add(row);

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=943723&r1=943722&r2=943723&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java Wed May 12 22:26:30 2010
@@ -874,7 +874,7 @@ class RegionManager implements HConstant
    * @param server Server
    * @return true if server is transitioning the ROOT table
    */
-  public boolean isRootServerCandidate(final String server) {
+  public boolean isRootInTransitionOnThisServer(final String server) {
     synchronized (this.regionsInTransition) {
       for (RegionState s : regionsInTransition.values()) {
         if (s.getRegionInfo().isRootRegion()

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=943723&r1=943722&r2=943723&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java Wed May 12 22:26:30 2010
@@ -163,6 +163,10 @@ class ServerManager implements HConstant
     // Test for case where we get a region startup message from a regionserver
     // that has been quickly restarted but whose znode expiration handler has
     // not yet run, or from a server whose fail we are currently processing.
+    // Test its host+port combo is present in serverAddresstoServerInfo.  If it
+    // is, reject the server and trigger its expiration. The next time it comes
+    // in, it should have been removed from serverAddressToServerInfo and queued
+    // for processing by ProcessServerShutdown.
     HServerInfo info = new HServerInfo(serverInfo);
     String hostAndPort = info.getServerAddress().toString();
     HServerInfo existingServer =
@@ -176,15 +180,24 @@ class ServerManager implements HConstant
       }
       throw new Leases.LeaseStillHeldException(hostAndPort);
     }
-    if (isDead(hostAndPort, true)) {
-      LOG.debug("Server start rejected; currently processing " + hostAndPort +
-        " failure");
-      throw new Leases.LeaseStillHeldException(hostAndPort);
-    }
+    checkIsDead(info.getServerName(), "STARTUP");
     LOG.info("Received start message from: " + info.getServerName());
     recordNewServer(info);
   }
 
+  /*
+   * If this server is on the dead list, reject it with a LeaseStillHeldException
+   * @param serverName Server name formatted as host_port_startcode.
+   * @param what START or REPORT
+   * @throws LeaseStillHeldException
+   */
+  private void checkIsDead(final String serverName, final String what)
+  throws Leases.LeaseStillHeldException {
+    if (!isDead(serverName)) return;
+    LOG.debug("Server " + what + " rejected; currently processing " +
+      serverName + " as dead server");
+    throw new Leases.LeaseStillHeldException(serverName);
+  }
 
   /**
    * Adds the HSI to the RS list and creates an empty load
@@ -238,11 +251,7 @@ class ServerManager implements HConstant
     final HMsg msgs[], final HRegionInfo[] mostLoadedRegions)
   throws IOException {
     HServerInfo info = new HServerInfo(serverInfo);
-    if (isDead(info.getServerName())) {
-      LOG.info("Received report from region server " + info.getServerName() +
-        " previously marked dead. Rejecting report.");
-      throw new Leases.LeaseStillHeldException(info.getServerName());
-    }
+    checkIsDead(info.getServerName(), "REPORT");
     if (msgs.length > 0) {
       if (msgs[0].isType(HMsg.Type.MSG_REPORT_EXITING)) {
         processRegionServerExit(info, msgs);
@@ -672,7 +681,7 @@ class ServerManager implements HConstant
       master.regionManager.offlineMetaServer(info.getServerAddress());
 
       //HBASE-1928: Check whether this server has been transitioning the ROOT table
-      if (this.master.regionManager.isRootServerCandidate (serverName)) {
+      if (this.master.regionManager.isRootInTransitionOnThisServer(serverName)) {
          this.master.regionManager.unsetRootRegion();
          this.master.regionManager.reassignRootRegion();
       }

Modified: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=943723&r1=943722&r2=943723&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java Wed May 12 22:26:30 2010
@@ -614,8 +614,10 @@ public class HBaseTestingUtility {
     ZooKeeper zk = new ZooKeeper(quorumServers,
         sessionTimeout, EmptyWatcher.instance, sessionID, password);
     zk.close();
+    final long sleep = sessionTimeout * 5L;
+    LOG.info("ZK Closed; sleeping=" + sleep);
 
-    Thread.sleep(sessionTimeout * 5L);
+    Thread.sleep(sleep);
 
     new HTable(conf, HConstants.META_TABLE_NAME);
   }

Modified: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/TestZooKeeper.java?rev=943723&r1=943722&r2=943723&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/TestZooKeeper.java (original)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/TestZooKeeper.java Wed May 12 22:26:30 2010
@@ -21,6 +21,8 @@ package org.apache.hadoop.hbase;
 
 import java.io.IOException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HConnection;
@@ -39,6 +41,8 @@ import org.apache.zookeeper.ZooKeeper;
  *
  */
 public class TestZooKeeper extends HBaseClusterTestCase {
+  private static final Log LOG = LogFactory.getLog(TestZooKeeper.class);
+  
   private static class EmptyWatcher implements Watcher {
     public static EmptyWatcher instance = new EmptyWatcher();
     private EmptyWatcher() {}
@@ -116,13 +120,15 @@ public class TestZooKeeper extends HBase
   }
 
   public void testRegionServerSessionExpired() throws Exception{
-    this.conf.setBoolean("hbase.regionserver.restart.on.zk.expire", true);
+    LOG.info("Starting " + getName());
     new HTable(conf, HConstants.META_TABLE_NAME);
     HRegionServer rs = cluster.getRegionServer(0);
+    rs.getConfiguration().setBoolean("hbase.regionserver.restart.on.zk.expire", true);
     sessionExpirationHelper(rs.getZooKeeperWrapper());
   }
 
   public void testMasterSessionExpired() throws Exception {
+    LOG.info("Starting " + getName());
     new HTable(conf, HConstants.META_TABLE_NAME);
     HMaster master = cluster.getMaster();
     sessionExpirationHelper(master.getZooKeeperWrapper());