Sfoglia il codice sorgente

HADOOP-2109 Fixed race condition in processing server lease timeout.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@591162 13f79535-47bb-0310-9956-ffa450edef68
Jim Kellerman 18 anni fa
parent
commit
60f9592f6f

+ 1 - 0
src/contrib/hbase/CHANGES.txt

@@ -18,6 +18,7 @@ Trunk (unreleased changes)
    HADOOP-2079 HADOOP-2056 Fix generated HLog, HRegion names
    HADOOP-2124 Use of `hostname` does not work on Cygwin in some cases
    HADOOP-2083 TestTableIndex failed in #970 and #956
+   HADOOP-2109 Fixed race condition in processing server lease timeout.
 
   IMPROVEMENTS
     HADOOP-2401 Add convenience put method that takes writable

+ 23 - 11
src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java

@@ -409,8 +409,7 @@ HMasterRegionInterface {
     }
 
     protected void checkAssigned(final HRegionInfo info,
-      final String serverName, final long startCode)
-    throws IOException {
+      final String serverName, final long startCode) throws IOException {
       // Skip region - if ...
       if(info.isOffline()                                 // offline
           || killedRegions.contains(info.getRegionName()) // queued for offline
@@ -435,7 +434,7 @@ HMasterRegionInterface {
         }
         synchronized (serversToServerInfo) {
           storedInfo = serversToServerInfo.get(serverName);
-          if (storedInfo != null && deadServers.contains(serverName)) {
+          if (deadServers.contains(serverName)) {
             deadServer = true;
           }
         }
@@ -443,10 +442,23 @@ HMasterRegionInterface {
       if (LOG.isDebugEnabled()) {
         LOG.debug("Checking " + info.getRegionName() + " is assigned");
       }
-      if (!(unassignedRegions.containsKey(info.getRegionName()) ||
-            pendingRegions.contains(info.getRegionName()))
-          && (storedInfo == null || 
-              (storedInfo.getStartCode() != startCode && !deadServer))) {
+
+      /*
+       * If the server is not dead and either:
+       *   the stored info is not null and the start code does not match
+       * or:
+       *   the stored info is null and the region is neither unassigned nor pending
+       * then:
+       */ 
+      if (!deadServer &&
+          ((storedInfo != null && storedInfo.getStartCode() != startCode) ||
+              (storedInfo == null &&
+                  !unassignedRegions.containsKey(info.getRegionName()) &&
+                  !pendingRegions.contains(info.getRegionName())
+              )
+          )
+      ) {
+
         // The current assignment is no good
         if (LOG.isDebugEnabled()) {
           LOG.debug("Current assignment of " + info.getRegionName() +
@@ -2390,6 +2402,7 @@ HMasterRegionInterface {
     return !closed.get();
   }
 
+  /** {@inheritDoc} */
   public void shutdown() {
     TimerTask tt = new TimerTask() {
       @Override
@@ -3021,8 +3034,8 @@ HMasterRegionInterface {
   }
 
   protected static void doMain(String [] args,
-      Class<? extends HMaster> masterClass)
-  throws IOException {
+      Class<? extends HMaster> masterClass) {
+
     if (args.length < 1) {
       printUsageAndExit();
     }
@@ -3079,9 +3092,8 @@ HMasterRegionInterface {
   /**
    * Main program
    * @param args
-   * @throws IOException 
    */
-  public static void main(String [] args) throws IOException {
+  public static void main(String [] args) {
     doMain(args, HMaster.class);
   }
 }

+ 1 - 2
src/contrib/hbase/src/test/org/apache/hadoop/hbase/OOMEHMaster.java

@@ -54,9 +54,8 @@ public class OOMEHMaster extends HMaster {
 
   /**
    * @param args
-   * @throws IOException 
    */
-  public static void main(String[] args) throws IOException {
+  public static void main(String[] args) {
     doMain(args, OOMEHMaster.class);
   }
 }