You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2010/04/29 03:23:08 UTC

svn commit: r939158 - in /hadoop/hbase/branches/0.20_pre_durability: CHANGES.txt src/java/org/apache/hadoop/hbase/master/ChangeTableState.java

Author: jdcryans
Date: Thu Apr 29 01:23:07 2010
New Revision: 939158

URL: http://svn.apache.org/viewvc?rev=939158&view=rev
Log:
HBASE-2499  Race condition when disabling a table leaves regions in transition

Modified:
    hadoop/hbase/branches/0.20_pre_durability/CHANGES.txt
    hadoop/hbase/branches/0.20_pre_durability/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java

Modified: hadoop/hbase/branches/0.20_pre_durability/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_pre_durability/CHANGES.txt?rev=939158&r1=939157&r2=939158&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20_pre_durability/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20_pre_durability/CHANGES.txt Thu Apr 29 01:23:07 2010
@@ -64,6 +64,7 @@ Release 0.20.4 - Mon Apr 26 08:39:23 PDT
    HBASE-2381  missing copyright headers (Andrew Purtell via Stack)
    HBASE-2497  ProcessServerShutdown throws NullPointerException for offline
                regions
+   HBASE-2499  Race condition when disabling a table leaves regions in transition
 
   IMPROVEMENTS
    HBASE-2180  Bad read performance from synchronizing hfile.fddatainputstream

Modified: hadoop/hbase/branches/0.20_pre_durability/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20_pre_durability/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java?rev=939158&r1=939157&r2=939158&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20_pre_durability/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java (original)
+++ hadoop/hbase/branches/0.20_pre_durability/src/java/org/apache/hadoop/hbase/master/ChangeTableState.java Thu Apr 29 01:23:07 2010
@@ -28,9 +28,12 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.io.BatchUpdate;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Writables;
 
 /**
@@ -85,18 +88,20 @@ class ChangeTableState extends TableOper
           " because it is pending open, will tell it to close later");
         continue;
       }
-
-
-      // Update meta table
-      Put put = updateRegionInfo(i);
-      server.put(m.getRegionName(), put);
-      Delete delete = new Delete(i.getRegionName());
-      delete.deleteColumns(CATALOG_FAMILY, SERVER_QUALIFIER);
-      delete.deleteColumns(CATALOG_FAMILY, STARTCODE_QUALIFIER);
-      server.delete(m.getRegionName(), delete);
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Removed server and startcode from row and set online=" +
-          this.online + ": " + i.getRegionNameAsString());
+      // If it's already offline then don't set it a second/third time, skip
+      // Same for online, don't set again if already online
+      if (!(i.isOffline() && !online) && !(!i.isOffline() && online)) {
+        // Update meta table
+        Put put = updateRegionInfo(i);
+        server.put(m.getRegionName(), put);
+        Delete delete = new Delete(i.getRegionName());
+        delete.deleteColumns(CATALOG_FAMILY, SERVER_QUALIFIER);
+        delete.deleteColumns(CATALOG_FAMILY, STARTCODE_QUALIFIER);
+        server.delete(m.getRegionName(), delete);
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Removed server and startcode from row and set online=" +
+              this.online + ": " + i.getRegionNameAsString());
+        }
       }
       synchronized (master.regionManager) {
         if (this.online) {
@@ -126,6 +131,15 @@ class ChangeTableState extends TableOper
 
         // Cause regions being served to be taken off-line and disabled
         for (HRegionInfo i: e.getValue()) {
+          // The scan we did could be totally staled, get the freshest data
+          Get get = new Get(i.getRegionName());
+          get.addColumn(CATALOG_FAMILY, SERVER_QUALIFIER);
+          Result values = server.get(m.getRegionName(), get);
+          String serverAddress = BaseScanner.getServerAddress(values);
+          // If this region is unassigned, skip!
+          if(serverAddress.length() == 0) {
+            continue;
+          }
           if (LOG.isDebugEnabled()) {
             LOG.debug("Adding region " + i.getRegionNameAsString() +
               " to setClosing list");