HBASE-3203 We can get an order to open a region while shutting down and it'll hold up regionserver shutdown
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1031872 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d4b41f0940
commit
5f2c693b59
|
@ -653,6 +653,8 @@ Release 0.21.0 - Unreleased
|
|||
HBASE-3202 Closing a region, if we get a ConnectException, handle
|
||||
it rather than abort
|
||||
HBASE-3198 Log rolling archives files prematurely
|
||||
HBASE-3203 We can get an order to open a region while shutting down
|
||||
and it'll hold up regionserver shutdown
|
||||
|
||||
|
||||
IMPROVEMENTS
|
||||
|
|
|
@ -418,8 +418,14 @@ public class ServerManager {
|
|||
void letRegionServersShutdown() {
|
||||
synchronized (onlineServers) {
|
||||
while (onlineServers.size() > 0) {
|
||||
LOG.info("Waiting on following regionserver(s) to go down " +
|
||||
this.onlineServers.values());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String key: this.onlineServers.keySet()) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(key);
|
||||
}
|
||||
LOG.info("Waiting on regionserver(s) to go down " + sb.toString());
|
||||
try {
|
||||
this.onlineServers.wait(1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
|
|
@ -35,12 +35,10 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -56,6 +54,7 @@ import org.apache.hadoop.fs.Path;
|
|||
import org.apache.hadoop.hbase.Chore;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
|
||||
import org.apache.hadoop.hbase.HMsg;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HServerAddress;
|
||||
|
@ -70,7 +69,6 @@ import org.apache.hadoop.hbase.Stoppable;
|
|||
import org.apache.hadoop.hbase.UnknownRowLockException;
|
||||
import org.apache.hadoop.hbase.UnknownScannerException;
|
||||
import org.apache.hadoop.hbase.YouAreDeadException;
|
||||
import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
|
||||
import org.apache.hadoop.hbase.catalog.CatalogTracker;
|
||||
import org.apache.hadoop.hbase.catalog.MetaEditor;
|
||||
import org.apache.hadoop.hbase.catalog.RootLocationEditor;
|
||||
|
@ -138,6 +136,10 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
// of HRegionServer in isolation.
|
||||
protected volatile boolean stopped = false;
|
||||
|
||||
// A state before we go into stopped state. At this stage we're closing user
|
||||
// space regions.
|
||||
private boolean stopping = false;
|
||||
|
||||
// Go down hard. Used if file system becomes unavailable and also in
|
||||
// debugging and unit tests.
|
||||
protected volatile boolean abortRequested;
|
||||
|
@ -467,7 +469,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
}
|
||||
|
||||
/**
|
||||
* @return True if cluster shutdown in progress
|
||||
* @return False if cluster shutdown in progress
|
||||
*/
|
||||
private boolean isClusterUp() {
|
||||
return this.clusterStatusTracker.isClusterUp();
|
||||
|
@ -509,7 +511,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
}
|
||||
|
||||
this.regionServerThread = Thread.currentThread();
|
||||
boolean calledCloseUserRegions = false;
|
||||
try {
|
||||
while (!this.stopped) {
|
||||
if (tryReportForDuty()) break;
|
||||
|
@ -521,9 +522,9 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
if (!isClusterUp()) {
|
||||
if (this.onlineRegions.isEmpty()) {
|
||||
stop("Exiting; cluster shutdown set and not carrying any regions");
|
||||
} else if (!calledCloseUserRegions) {
|
||||
} else if (!this.stopping) {
|
||||
closeUserRegions(this.abortRequested);
|
||||
calledCloseUserRegions = true;
|
||||
this.stopping = true;
|
||||
}
|
||||
}
|
||||
// Try to get the root region location from zookeeper.
|
||||
|
@ -1235,7 +1236,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
return true;
|
||||
}
|
||||
|
||||
/** @return the HLog */
|
||||
@Override
|
||||
public HLog getWAL() {
|
||||
return this.hlog;
|
||||
}
|
||||
|
@ -2059,6 +2060,11 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
return this.stopped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStopping() {
|
||||
return this.stopping;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the configuration
|
||||
|
|
|
@ -30,6 +30,12 @@ import org.apache.zookeeper.KeeperException;
|
|||
* Services provided by {@link HRegionServer}
|
||||
*/
|
||||
public interface RegionServerServices extends OnlineRegions {
|
||||
/**
|
||||
* @return True if this regionserver is stopping.
|
||||
*/
|
||||
public boolean isStopping();
|
||||
|
||||
/** @return the HLog */
|
||||
public HLog getWAL();
|
||||
|
||||
/**
|
||||
|
|
|
@ -181,6 +181,9 @@ class SplitTransaction {
|
|||
final RegionServerServices services)
|
||||
throws IOException {
|
||||
LOG.info("Starting split of region " + this.parent);
|
||||
if (server.isStopped() || services.isStopping()) {
|
||||
throw new IOException("Server is stopped or stopping");
|
||||
}
|
||||
assert !this.parent.lock.writeLock().isHeldByCurrentThread() : "Unsafe to hold write lock while performing RPCs";
|
||||
|
||||
// If true, no cluster to write meta edits into.
|
||||
|
|
|
@ -67,8 +67,8 @@ public class OpenRegionHandler extends EventHandler {
|
|||
public void process() throws IOException {
|
||||
final String name = regionInfo.getRegionNameAsString();
|
||||
LOG.debug("Processing open of " + name);
|
||||
if (this.server.isStopped()) {
|
||||
LOG.info("Server stopping, skipping open of " + name);
|
||||
if (this.server.isStopped() || this.rsServices.isStopping()) {
|
||||
LOG.info("Server stopping or stopped, skipping open of " + name);
|
||||
return;
|
||||
}
|
||||
final String encodedName = regionInfo.getEncodedName();
|
||||
|
|
Loading…
Reference in New Issue