HBASE-5356 region_mover.rb can hang if table region it belongs to is deleted
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1565742 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d30249534b
commit
147a2304d1
@ -82,8 +82,7 @@ end
|
|||||||
# Returns true if passed region is still on 'original' when we look at .META.
|
# Returns true if passed region is still on 'original' when we look at .META.
|
||||||
def isSameServer(admin, r, original)
|
def isSameServer(admin, r, original)
|
||||||
server = getServerNameForRegion(admin, r)
|
server = getServerNameForRegion(admin, r)
|
||||||
return false unless server
|
return false unless server and original
|
||||||
return true unless original
|
|
||||||
return server == original
|
return server == original
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -97,6 +96,7 @@ end
|
|||||||
# Get servername that is up in .META.; this is hostname + port + startcode comma-delimited.
|
# Get servername that is up in .META.; this is hostname + port + startcode comma-delimited.
|
||||||
# Can return nil
|
# Can return nil
|
||||||
def getServerNameForRegion(admin, r)
|
def getServerNameForRegion(admin, r)
|
||||||
|
return nil unless admin.isTableEnabled(r.getTableName)
|
||||||
if r.isMetaRegion()
|
if r.isMetaRegion()
|
||||||
# Hack
|
# Hack
|
||||||
zkw = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(admin.getConfiguration(), "region_mover", nil)
|
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::SERVER_QUALIFIER)
|
||||||
g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
|
g.addColumn(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
|
||||||
result = table.get(g)
|
result = table.get(g)
|
||||||
|
return nil unless result
|
||||||
server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
|
server = result.getValue(HConstants::CATALOG_FAMILY, HConstants::SERVER_QUALIFIER)
|
||||||
startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
|
startcode = result.getValue(HConstants::CATALOG_FAMILY, HConstants::STARTCODE_QUALIFIER)
|
||||||
return nil unless server
|
return nil unless server
|
||||||
@ -133,8 +134,15 @@ def isSuccessfulScan(admin, r)
|
|||||||
scan.setBatch(1)
|
scan.setBatch(1)
|
||||||
scan.setCaching(1)
|
scan.setCaching(1)
|
||||||
scan.setFilter(FirstKeyOnlyFilter.new())
|
scan.setFilter(FirstKeyOnlyFilter.new())
|
||||||
table = getTable(admin.getConfiguration(), r.getTableName())
|
begin
|
||||||
scanner = table.getScanner(scan)
|
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
|
begin
|
||||||
results = scanner.next()
|
results = scanner.next()
|
||||||
# We might scan into next region, this might be an empty table.
|
# 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
|
count = count + 1
|
||||||
begin
|
begin
|
||||||
admin.move(Bytes.toBytes(r.getEncodedName()), Bytes.toBytes(newServer))
|
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() +
|
$LOG.info("Exception moving " + r.getEncodedName() +
|
||||||
"; split/moved? Continuing: " + e)
|
"; split/moved? Continuing: " + e)
|
||||||
return
|
return
|
||||||
@ -332,6 +341,8 @@ def unloadRegions(options, hostname)
|
|||||||
movedRegions = java.util.ArrayList.new()
|
movedRegions = java.util.ArrayList.new()
|
||||||
while true
|
while true
|
||||||
rs = getRegions(config, servername)
|
rs = getRegions(config, servername)
|
||||||
|
# Remove those already tried to move
|
||||||
|
rs.removeAll(movedRegions)
|
||||||
break if rs.length == 0
|
break if rs.length == 0
|
||||||
count = 0
|
count = 0
|
||||||
$LOG.info("Moving " + rs.length.to_s + " region(s) from " + servername +
|
$LOG.info("Moving " + rs.length.to_s + " region(s) from " + servername +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user