hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1212254 - in /hbase/branches/0.92/src: main/java/org/apache/hadoop/hbase/regionserver/ main/java/org/apache/hadoop/hbase/regionserver/handler/ test/java/org/apache/hadoop/hbase/regionserver/
Date Fri, 09 Dec 2011 06:11:49 GMT
Author: stack
Date: Fri Dec  9 06:11:49 2011
New Revision: 1212254

URL: http://svn.apache.org/viewvc?rev=1212254&view=rev
Log:
HBASE-4880 Region is on service before openRegionHandler completes, may cause data loss

Modified:
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
    hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1212254&r1=1212253&r2=1212254&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Fri Dec  9 06:11:49 2011
@@ -38,6 +38,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Random;
 import java.util.Set;
 import java.util.SortedMap;
@@ -58,6 +59,7 @@ import org.apache.hadoop.hbase.ClockOutO
 import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
 import org.apache.hadoop.hbase.HDFSBlocksDistribution;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerAddress;
@@ -74,7 +76,6 @@ import org.apache.hadoop.hbase.TableDesc
 import org.apache.hadoop.hbase.UnknownRowLockException;
 import org.apache.hadoop.hbase.UnknownScannerException;
 import org.apache.hadoop.hbase.YouAreDeadException;
-import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.catalog.MetaEditor;
 import org.apache.hadoop.hbase.catalog.RootLocationEditor;
@@ -95,8 +96,8 @@ import org.apache.hadoop.hbase.coprocess
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.executor.ExecutorService.ExecutorType;
 import org.apache.hadoop.hbase.filter.BinaryComparator;
-import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
 import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
 import org.apache.hadoop.hbase.io.hfile.BlockCache;
 import org.apache.hadoop.hbase.io.hfile.BlockCacheColumnFamilySummary;
 import org.apache.hadoop.hbase.io.hfile.CacheConfig;
@@ -146,6 +147,8 @@ import org.apache.hadoop.net.DNS;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.zookeeper.KeeperException;
 import org.codehaus.jackson.map.ObjectMapper;
+import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
+import org.apache.hadoop.util.ReflectionUtils;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
@@ -1475,9 +1478,6 @@ public class HRegionServer implements HR
         getCompactionRequester().requestCompaction(r, s, "Opening Region");
       }
     }
-
-    // Add to online regions if all above was successful.
-    addToOnlineRegions(r);
     // Update ZK, ROOT or META
     if (r.getRegionInfo().isRootRegion()) {
       RootLocationEditor.setRootLocation(getZooKeeper(),

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java?rev=1212254&r1=1212253&r2=1212254&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
Fri Dec  9 06:11:49 2011
@@ -57,6 +57,7 @@ public interface RegionServerServices ex
   /**
    * Tasks to perform after region open to complete deploy of region on
    * regionserver
+   * 
    * @param r Region to open.
    * @param ct Instance of {@link CatalogTracker}
    * @param daughter True if this is daughter of a split

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java?rev=1212254&r1=1212253&r2=1212254&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
Fri Dec  9 06:11:49 2011
@@ -41,8 +41,8 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.catalog.MetaEditor;
-import org.apache.hadoop.hbase.executor.RegionTransitionData;
 import org.apache.hadoop.hbase.executor.EventHandler.EventType;
+import org.apache.hadoop.hbase.executor.RegionTransitionData;
 import org.apache.hadoop.hbase.io.Reference.Range;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.CancelableProgressable;
@@ -361,7 +361,10 @@ public class SplitTransaction {
         try {
           // add 2nd daughter first (see HBASE-4335)
           services.postOpenDeployTasks(b, server.getCatalogTracker(), true);
+          // Should add it to OnlineRegions
+          services.addToOnlineRegions(b);
           services.postOpenDeployTasks(a, server.getCatalogTracker(), true);
+          services.addToOnlineRegions(a);
         } catch (KeeperException ke) {
           throw new IOException(ke);
         }

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java?rev=1212254&r1=1212253&r2=1212254&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
Fri Dec  9 06:11:49 2011
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.Server;
@@ -110,10 +109,11 @@ public class OpenRegionHandler extends E
         tryTransitionToFailedOpen(regionInfo);
         return;
       }
-
       boolean failed = true;
       if (tickleOpening("post_region_open")) {
-        if (updateMeta(region)) failed = false;
+        if (updateMeta(region)) {
+          failed = false;
+        }
       }
       if (failed || this.server.isStopped() ||
           this.rsServices.isStopping()) {
@@ -132,6 +132,8 @@ public class OpenRegionHandler extends E
         cleanupFailedOpen(region);
         return;
       }
+      // Successful region open, and add it to OnlineRegions
+      this.rsServices.addToOnlineRegions(region);
 
       // Done!  Successful region open
       LOG.debug("Opened " + name + " on server:" +
@@ -212,9 +214,10 @@ public class OpenRegionHandler extends E
   }
 
   /**
-   * Thread to run region post open tasks.  Call {@link #getException()} after
+   * Thread to run region post open tasks. Call {@link #getException()} after
    * the thread finishes to check for exceptions running
-   * {@link RegionServerServices#postOpenDeployTasks(HRegion, org.apache.hadoop.hbase.catalog.CatalogTracker,
boolean)}.
+   * {@link RegionServerServices#postOpenDeployTasks(HRegion, org.apache.hadoop.hbase.catalog.CatalogTracker,
boolean)}
+   * .
    */
   static class PostOpenDeployTasksThread extends Thread {
     private Exception exception = null;
@@ -348,7 +351,6 @@ public class OpenRegionHandler extends E
 
   private void cleanupFailedOpen(final HRegion region) throws IOException {
     if (region != null) region.close();
-    this.rsServices.removeFromOnlineRegions(regionInfo.getEncodedName());
   }
 
   /**

Modified: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java?rev=1212254&r1=1212253&r2=1212254&view=diff
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
(original)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
Fri Dec  9 06:11:49 2011
@@ -31,6 +31,8 @@ import org.apache.hadoop.hbase.util.Pair
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
@@ -84,6 +86,8 @@ public class TestEndToEndSplitTransactio
     // note that this replicates some code from SplitTransaction
     // 2nd daughter first
     server.postOpenDeployTasks(regions.getSecond(), server.getCatalogTracker(), true);
+    // Add to online regions
+    server.addToOnlineRegions(regions.getSecond());
     // THIS is the crucial point:
     // the 2nd daughter was added, so querying before the split key should fail.
     assertFalse(test(con, tableName, firstRow, server));
@@ -92,6 +96,8 @@ public class TestEndToEndSplitTransactio
 
     // first daughter second
     server.postOpenDeployTasks(regions.getFirst(), server.getCatalogTracker(), true);
+    // Add to online regions
+    server.addToOnlineRegions(regions.getFirst());
     assertTrue(test(con, tableName, firstRow, server));
     assertTrue(test(con, tableName, lastRow, server));
 



Mime
View raw message