Skip to content

Commit

Permalink
HBASE-6713 Stopping META/ROOT RS may take 50mins when some region is …
Browse files Browse the repository at this point in the history
…splitting (Chunhui)

git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/0.94@1382163 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Zhihong Yu committed Sep 7, 2012
1 parent 8ae631e commit 30a2ce3
Showing 1 changed file with 29 additions and 5 deletions.
Expand Up @@ -766,17 +766,29 @@ public void run() {
// Just skip out w/o closing regions. Used when testing.
} else if (abortRequested) {
if (this.fsOk) {
closeAllRegions(abortRequested); // Don't leave any open file handles
closeUserRegions(abortRequested); // Don't leave any open file handles
}
LOG.info("aborting server " + this.serverNameFromMasterPOV);
} else {
closeAllRegions(abortRequested);
closeUserRegions(abortRequested);
closeAllScanners();
LOG.info("stopping server " + this.serverNameFromMasterPOV);
}
// Interrupt catalog tracker here in case any regions being opened out in
// handlers are stuck waiting on meta or root.
if (this.catalogTracker != null) this.catalogTracker.stop();

// Closing the compactSplit thread before closing meta regions
if (!this.killed && containsMetaTableRegions()) {
if (!abortRequested || this.fsOk) {
if (this.compactSplitThread != null) {
this.compactSplitThread.join();
this.compactSplitThread = null;
}
closeMetaTableRegions(abortRequested);
}
}

if (!this.killed && this.fsOk) {
waitOnAllRegionsToClose(abortRequested);
LOG.info("stopping server " + this.serverNameFromMasterPOV +
Expand Down Expand Up @@ -811,11 +823,16 @@ public void run() {
LOG.info(Thread.currentThread().getName() + " exiting");
}

private boolean containsMetaTableRegions() {
return onlineRegions.containsKey(HRegionInfo.ROOT_REGIONINFO.getEncodedName())
|| onlineRegions.containsKey(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName());
}

private boolean areAllUserRegionsOffline() {
if (getNumberOfOnlineRegions() > 2) return false;
boolean allUserRegionsOffline = true;
for (Map.Entry<String, HRegion> e: this.onlineRegions.entrySet()) {
if (!e.getValue().getRegionInfo().isMetaRegion()) {
if (!e.getValue().getRegionInfo().isMetaTable()) {
allUserRegionsOffline = false;
break;
}
Expand Down Expand Up @@ -1890,7 +1907,14 @@ private MapWritable reportForDuty() throws IOException {
*/
protected void closeAllRegions(final boolean abort) {
closeUserRegions(abort);
// Only root and meta should remain. Are we carrying root or meta?
closeMetaTableRegions(abort);
}

/**
* Close root and meta regions if we carry them
* @param abort Whether we're running an abort.
*/
void closeMetaTableRegions(final boolean abort) {
HRegion meta = null;
HRegion root = null;
this.lock.writeLock().lock();
Expand Down Expand Up @@ -1922,7 +1946,7 @@ void closeUserRegions(final boolean abort) {
try {
for (Map.Entry<String, HRegion> e: this.onlineRegions.entrySet()) {
HRegion r = e.getValue();
if (!r.getRegionInfo().isMetaRegion() && r.isAvailable()) {
if (!r.getRegionInfo().isMetaTable() && r.isAvailable()) {
// Don't update zk with this close transition; pass false.
closeRegion(r.getRegionInfo(), abort, false);
}
Expand Down

0 comments on commit 30a2ce3

Please sign in to comment.