HBASE-1009 Master stuck in loop wanting to assign but regions are closing

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@719155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-11-20 02:02:01 +00:00
parent 0d735d26a9
commit 23564f2cf6
3 changed files with 17 additions and 1 deletions

View File

@ -79,6 +79,7 @@ Release 0.19.0 - Unreleased
HBASE-1005 Regex and string comparison operators for ColumnValueFilter
HBASE-910 Scanner misses columns / rows when the scanner is obtained
durring a memcache flush
HBASE-1009 Master stuck in loop wanting to assign but regions are closing
IMPROVEMENTS
HBASE-901 Add a limit to key length, check key and value length on client side

View File

@ -110,6 +110,11 @@ public class HRegion implements HConstants {
static final Random rand = new Random();
static final Log LOG = LogFactory.getLog(HRegion.class);
final AtomicBoolean closed = new AtomicBoolean(false);
/* Closing can take some time; use the closing flag if there is stuff we don't want
* to do while in closing state; e.g. like offer this region up to the master as a region
* to close if the carrying regionserver is overloaded. Once set, it is never cleared.
*/
private final AtomicBoolean closing = new AtomicBoolean(false);
private final RegionHistorian historian;
//////////////////////////////////////////////////////////////////////////////
@ -329,6 +334,13 @@ public class HRegion implements HConstants {
return this.closed.get();
}
/**
* @return True if closing process has started.
*/
public boolean isClosing() {
return this.closing.get();
}
/**
* Close down this HRegion. Flush the cache, shut down each HStore, don't
* service any more calls.
@ -365,6 +377,7 @@ public class HRegion implements HConstants {
LOG.warn("region " + this + " already closed");
return null;
}
this.closing.set(true);
synchronized (splitLock) {
synchronized (writestate) {
// Disable compacting and flushing by background threads for this
@ -419,7 +432,6 @@ public class HRegion implements HConstants {
result.addAll(store.close());
}
this.closed.set(true);
LOG.info("Closed " + this);
return result;
} finally {

View File

@ -1762,6 +1762,9 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
ArrayList<HRegionInfo> regions = new ArrayList<HRegionInfo>();
synchronized (onlineRegions) {
for (HRegion r : onlineRegions.values()) {
if (r.isClosed() || r.isClosing()) {
continue;
}
if (regions.size() < numRegionsToReport) {
regions.add(r.getRegionInfo());
} else {