Author: stack
Date: Thu Sep  8 15:38:04 2011
New Revision: 1166754

URL: http://svn.apache.org/viewvc?rev=1166754&view=rev
Log:
HBASE-4341 HRS#closeAllRegions should take care of HRS#onlineRegions's weak 
consistency

Modified:
    hbase/trunk/CHANGES.txt
    
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1166754&r1=1166753&r2=1166754&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Thu Sep  8 15:38:04 2011
@@ -245,6 +245,8 @@ Release 0.91.0 - Unreleased
                (Alejandro Abdelnur via todd)
    HBASE-4271  Clean up coprocessor handling of table operations
                (Ming Ma via garyh)
+   HBASE-4341  HRS#closeAllRegions should take care of HRS#onlineRegions's
+               weak consistency (Jieshan Bean)
 
   IMPROVEMENTS
    HBASE-3290  Max Compaction Size (Nicolas Spiegelberg via Stack)  

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1166754&r1=1166753&r2=1166754&view=diff
==============================================================================
--- 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
 (original)
+++ 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
 Thu Sep  8 15:38:04 2011
@@ -704,7 +704,7 @@ public class HRegionServer implements HR
     // Interrupt catalog tracker here in case any regions being opened out in
     // handlers are stuck waiting on meta or root.
     if (this.catalogTracker != null) this.catalogTracker.stop();
-    if (this.fsOk) waitOnAllRegionsToClose();
+    if (this.fsOk) waitOnAllRegionsToClose(abortRequested);
 
     // Make sure the proxy is down.
     if (this.hbaseMaster != null) {
@@ -783,7 +783,7 @@ public class HRegionServer implements HR
   /**
    * Wait on regions close.
    */
-  private void waitOnAllRegionsToClose() {
+  private void waitOnAllRegionsToClose(final boolean abort) {
     // Wait till all regions are closed before going out.
     int lastCount = -1;
     while (!isOnlineRegionsEmpty()) {
@@ -798,6 +798,16 @@ public class HRegionServer implements HR
           LOG.debug(this.onlineRegions);
         }
       }
+      // Ensure all user regions have been sent a close. Use this to
+      // protect against the case where an open comes in after we start the
+      // iterator of onlineRegions to close all user regions.
+      for (Map.Entry<String, HRegion> e : this.onlineRegions.entrySet()) {
+        HRegionInfo hri = e.getValue().getRegionInfo();
+        if 
(!this.regionsInTransitionInRS.contains(hri.getEncodedNameAsBytes())) {
+          // Don't update zk with this close transition; pass false.
+          closeRegion(hri, abort, false);
+        }
+      }
       Threads.sleep(1000);
     }
   }


Reply via email to