Index: src/java/org/apache/hadoop/hbase/master/BaseScanner.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/BaseScanner.java (revision 929007) +++ src/java/org/apache/hadoop/hbase/master/BaseScanner.java (working copy) @@ -444,9 +444,15 @@ private HRegionInfo getDaughterRegionInfo(final Result rowContent, final byte [] which) throws IOException { - return Writables.getHRegionInfoOrNull(rowContent.getValue(CATALOG_FAMILY, which)); + return getRegionInfo(rowContent, CATALOG_FAMILY, which); } + private HRegionInfo getRegionInfo(final Result r, final byte [] f, + final byte [] q) + throws IOException { + return Writables.getHRegionInfoOrNull(r.getValue(f, q)); + } + /* * Remove mention of daughter from parent row. * parent row. @@ -530,9 +536,9 @@ final MetaRegion meta, final HRegionInfo info, final String serverAddress, final long startCode) throws IOException { - String serverName = null; String sa = serverAddress; long sc = startCode; + HRegionInfo ri = info; // Scans are sloppy. They don't respect row locks and they get and // cache a row internally so may have data that is stale. Make sure that for // sure we have the right server and servercode. We are trying to avoid @@ -542,10 +548,13 @@ g.addFamily(HConstants.CATALOG_FAMILY); Result r = regionServer.get(meta.getRegionName(), g); if (r != null && !r.isEmpty()) { + // Result may not have serveraddress or startcode so below may be null. sa = getServerAddress(r); - // Reget startcode in case its changed in the meantime too. sc = getStartCode(r); + ri = getRegionInfo(r, HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); } + // If serverName remains null after below machinations, region is not assigned. + String serverName = null; if (sa != null && sa.length() > 0) { serverName = HServerInfo.getServerName(sa, sc); } @@ -555,8 +564,8 @@ * a dead server. Regions that were on a dead server will get reassigned * by ProcessServerShutdown */ - if (info.isOffline() || - this.master.regionManager.regionIsInTransition(info.getRegionNameAsString()) || + if (ri.isOffline() || + this.master.regionManager.regionIsInTransition(ri.getRegionNameAsString()) || (serverName != null && this.master.serverManager.isDead(serverName))) { return; } @@ -569,12 +578,12 @@ if (storedInfo == null) { // The current assignment is invalid if (LOG.isDebugEnabled()) { - LOG.debug("Current assignment of " + info.getRegionNameAsString() + + LOG.debug("Current assignment of " + ri.getRegionNameAsString() + " is not valid; " + " serverAddress=" + sa + ", startCode=" + sc + " unknown."); } // Now get the region assigned - this.master.regionManager.setUnassigned(info, true); + this.master.regionManager.setUnassigned(ri, true); } } }