You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2015/06/16 22:07:12 UTC

hbase git commit: HBASE-12921 Port HBASE-5356 'region_mover.rb can hang if table region it belongs to is deleted' to 0.94. (Liu Shaohui)

Repository: hbase
Updated Branches:
  refs/heads/0.94 b2fb5b784 -> 4a1d46487


HBASE-12921 Port HBASE-5356 'region_mover.rb can hang if table region it belongs to is deleted' to 0.94. (Liu Shaohui)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4a1d4648
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4a1d4648
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4a1d4648

Branch: refs/heads/0.94
Commit: 4a1d46487cd83bb6f62b6367f688fbb44bbc6f82
Parents: b2fb5b7
Author: Lars Hofhansl <la...@apache.org>
Authored: Tue Jun 16 13:06:50 2015 -0700
Committer: Lars Hofhansl <la...@apache.org>
Committed: Tue Jun 16 13:06:50 2015 -0700

----------------------------------------------------------------------
 bin/region_mover.rb | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4a1d4648/bin/region_mover.rb
----------------------------------------------------------------------
diff --git a/bin/region_mover.rb b/bin/region_mover.rb
index 5876163..dc28331 100644
--- a/bin/region_mover.rb
+++ b/bin/region_mover.rb
@@ -90,8 +90,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
 
@@ -105,6 +104,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.isRootRegion()
     # Hack
     tracker = org.apache.hadoop.hbase.zookeeper.RootRegionTracker.new(admin.getConnection().getZooKeeperWatcher(), RubyAbortable.new())
@@ -127,6 +127,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
@@ -140,8 +141,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.
@@ -171,7 +179,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
@@ -342,6 +351,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 +