HBASE-20182 Addendum throw IOException instead of NoServerForRegionException because it is a DoNotRetryRegionException

This commit is contained in:
zhangduo 2018-04-11 14:37:56 +08:00
parent 4bcb560e22
commit 28d09cedcf
4 changed files with 24 additions and 19 deletions

View File

@ -159,9 +159,11 @@ public class HRegionInfo implements RegionInfo, Comparable<HRegionInfo> {
} }
private byte [] endKey = HConstants.EMPTY_BYTE_ARRAY; private byte [] endKey = HConstants.EMPTY_BYTE_ARRAY;
// This flag is in the parent of a split while the parent is still referenced // This flag is in the parent of a split while the parent is still referenced by daughter regions.
// by daughter regions. We USED to set this flag when we disabled a table // We USED to set this flag when we disabled a table but now table state is kept up in zookeeper
// but now table state is kept up in zookeeper as of 0.90.0 HBase. // as of 0.90.0 HBase. And now in DisableTableProcedure, finally we will create bunch of
// UnassignProcedures and at the last of the procedure we will set the region state to CLOSED, and
// will not change the offLine flag.
private boolean offLine = false; private boolean offLine = false;
private long regionId = -1; private long regionId = -1;
private transient byte [] regionName = HConstants.EMPTY_BYTE_ARRAY; private transient byte [] regionName = HConstants.EMPTY_BYTE_ARRAY;

View File

@ -269,12 +269,7 @@ class AsyncNonMetaRegionLocator {
} }
// return whether we should stop the scan // return whether we should stop the scan
private boolean onScanNext(TableName tableName, LocateRequest req, Result result, private boolean onScanNext(TableName tableName, LocateRequest req, Result result) {
Throwable error) {
if (error != null) {
complete(tableName, req, null, error);
return true;
}
RegionLocations locs = MetaTableAccessor.getRegionLocations(result); RegionLocations locs = MetaTableAccessor.getRegionLocations(result);
LOG.debug("The fetched location of '{}', row='{}', locateType={} is {}", tableName, LOG.debug("The fetched location of '{}', row='{}', locateType={} is {}", tableName,
Bytes.toStringBinary(req.row), req.locateType, locs); Bytes.toStringBinary(req.row), req.locateType, locs);
@ -298,7 +293,7 @@ class AsyncNonMetaRegionLocator {
} }
if (loc.getServerName() == null) { if (loc.getServerName() == null) {
complete(tableName, req, null, complete(tableName, req, null,
new NoServerForRegionException( new IOException(
String.format("No server address listed for region '%s', row='%s', locateType=%s", String.format("No server address listed for region '%s', row='%s', locateType=%s",
info.getRegionNameAsString(), Bytes.toStringBinary(req.row), req.locateType))); info.getRegionNameAsString(), Bytes.toStringBinary(req.row), req.locateType)));
return true; return true;
@ -370,22 +365,28 @@ class AsyncNonMetaRegionLocator {
private boolean completeNormally = false; private boolean completeNormally = false;
private boolean tableNotFound = true;
@Override @Override
public void onError(Throwable error) { public void onError(Throwable error) {
onScanNext(tableName, req, null, error); complete(tableName, req, null, error);
} }
@Override @Override
public void onComplete() { public void onComplete() {
if (!completeNormally) { if (tableNotFound) {
onScanNext(tableName, req, null, new TableNotFoundException(tableName)); complete(tableName, req, null, new TableNotFoundException(tableName));
} else if (!completeNormally) {
complete(tableName, req, null, new IOException(
"Unable to find region for " + Bytes.toStringBinary(req.row) + " in " + tableName));
} }
} }
@Override @Override
public void onNext(Result[] results, ScanController controller) { public void onNext(Result[] results, ScanController controller) {
for (Result result : results) { for (Result result : results) {
if (onScanNext(tableName, req, result, null)) { tableNotFound = false;
if (onScanNext(tableName, req, result)) {
completeNormally = true; completeNormally = true;
controller.terminate(); controller.terminate();
return; return;

View File

@ -836,7 +836,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
if (tableNotFound) { if (tableNotFound) {
throw new TableNotFoundException(tableName); throw new TableNotFoundException(tableName);
} else { } else {
throw new NoServerForRegionException( throw new IOException(
"Unable to find region for " + Bytes.toStringBinary(row) + " in " + tableName); "Unable to find region for " + Bytes.toStringBinary(row) + " in " + tableName);
} }
} }
@ -864,7 +864,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
// the parent in the above condition, so we may have already reached a region which does // the parent in the above condition, so we may have already reached a region which does
// not contains us. // not contains us.
if (!regionInfo.containsRow(row)) { if (!regionInfo.containsRow(row)) {
throw new NoServerForRegionException( throw new IOException(
"Unable to find region for " + Bytes.toStringBinary(row) + " in " + tableName); "Unable to find region for " + Bytes.toStringBinary(row) + " in " + tableName);
} }
ServerName serverName = locations.getRegionLocation(replicaId).getServerName(); ServerName serverName = locations.getRegionLocation(replicaId).getServerName();

View File

@ -149,9 +149,11 @@ public class RegionInfoBuilder {
* old region name format. * old region name format.
*/ */
// This flag is in the parent of a split while the parent is still referenced // This flag is in the parent of a split while the parent is still referenced by daughter
// by daughter regions. We USED to set this flag when we disabled a table // regions. We USED to set this flag when we disabled a table but now table state is kept up in
// but now table state is kept up in zookeeper as of 0.90.0 HBase. // zookeeper as of 0.90.0 HBase. And now in DisableTableProcedure, finally we will create bunch
// of UnassignProcedures and at the last of the procedure we will set the region state to
// CLOSED, and will not change the offLine flag.
private boolean offLine = false; private boolean offLine = false;
private boolean split = false; private boolean split = false;
private final long regionId; private final long regionId;