hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject svn commit: r1565744 - /hbase/branches/0.96/bin/region_mover.rb
Date Fri, 07 Feb 2014 17:58:45 GMT
Author: jxiang
Date: Fri Feb  7 17:58:44 2014
New Revision: 1565744

URL: http://svn.apache.org/r1565744
Log:
HBASE-5356 region_mover.rb can hang if table region it belongs to is deleted

Modified:
    hbase/branches/0.96/bin/region_mover.rb

Modified: hbase/branches/0.96/bin/region_mover.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/bin/region_mover.rb?rev=1565744&r1=1565743&r2=1565744&view=diff
==============================================================================
--- hbase/branches/0.96/bin/region_mover.rb (original)
+++ hbase/branches/0.96/bin/region_mover.rb Fri Feb  7 17:58:44 2014
@@ -82,8 +82,7 @@ end
 # Returns true if passed region is still on 'original' when we look at .META.
 def isSameServer(admin, r, original)
   server = getServerNameForRegion(admin, r)
-  return false unless server
-  return true unless original
+  return false unless server and original
   return server == original
 end
 
@@ -97,6 +96,7 @@ end
 # Get servername that is up in .META.; this is hostname + port + startcode comma-delimited.
 # Can return nil
 def getServerNameForRegion(admin, r)
+  return nil unless admin.isTableEnabled(r.getTableName)
   if r.isMetaRegion()
     # Hack
     zkw = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(admin.getConfiguration(),
"region_mover", nil)
@@ -120,6 +120,7 @@ def getServerNameForRegion(admin, r)
   g.addColumn(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
   g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
   result = table.get(g)
+  return nil unless result
   server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
   startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
   return nil unless server
@@ -133,8 +134,15 @@ def isSuccessfulScan(admin, r)
   scan.setBatch(1)
   scan.setCaching(1)
   scan.setFilter(FirstKeyOnlyFilter.new()) 
-  table = getTable(admin.getConfiguration(), r.getTableName()) 
-  scanner = table.getScanner(scan)
+  begin
+    table = getTable(admin.getConfiguration(), r.getTableName())
+    scanner = table.getScanner(scan)
+  rescue org.apache.hadoop.hbase.TableNotFoundException,
+      org.apache.hadoop.hbase.TableNotEnabledException => e
+    $LOG.warn("Region " + r.getEncodedName() + " belongs to recently " +
+      "deleted/disabled table. Skipping... " + e.message)
+    return
+  end
   begin
     results = scanner.next() 
     # We might scan into next region, this might be an empty table.
@@ -164,7 +172,8 @@ def move(admin, r, newServer, original)
     count = count + 1
     begin
       admin.move(Bytes.toBytes(r.getEncodedName()), Bytes.toBytes(newServer))
-    rescue java.lang.reflect.UndeclaredThrowableException => e
+    rescue java.lang.reflect.UndeclaredThrowableException,
+        org.apache.hadoop.hbase.UnknownRegionException => e
       $LOG.info("Exception moving "  + r.getEncodedName() +
         "; split/moved? Continuing: " + e)
       return
@@ -332,6 +341,8 @@ def unloadRegions(options, hostname)
   movedRegions = java.util.ArrayList.new()
   while true
     rs = getRegions(config, servername)
+    # Remove those already tried to move
+    rs.removeAll(movedRegions)
     break if rs.length == 0
     count = 0
     $LOG.info("Moving " + rs.length.to_s + " region(s) from " + servername +



Mime
View raw message