Skip to content

Commit 6698268

Browse files
committed
Revert "HBASE-22700 refactor isMetaClearingException (#578)"
This reverts commit b1d4878.
1 parent 44f01ad commit 6698268

File tree

5 files changed

+17
-37
lines changed

5 files changed

+17
-37
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocatorHelper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import static org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil.findException;
2121
import static org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil.isMetaClearingException;
22-
import static org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil.isRegionServerOverloadedException;
2322

2423
import java.util.Arrays;
2524
import java.util.Optional;
@@ -68,8 +67,7 @@ static void updateCachedLocationOnError(HRegionLocation loc, Throwable exception
6867
LOG.debug("The actual exception when updating {} is {}", loc,
6968
cause != null ? cause.toString() : "none");
7069
}
71-
if (cause == null || !isMetaClearingException(cause)
72-
|| isRegionServerOverloadedException(cause)) {
70+
if (cause == null || !isMetaClearingException(cause)) {
7371
LOG.debug("Will not update {} because the exception is null or not the one we care about",
7472
loc);
7573
return;

hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRequestFutureImpl.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,7 @@ private void receiveGlobalFailure(
711711
// Do not use the exception for updating cache because it might be coming from
712712
// any of the regions in the MultiAction.
713713
updateCachedLocations(server, regionName, row,
714-
ClientExceptionsUtil.isMetaClearingException(t) &&
715-
!ClientExceptionsUtil.isRegionServerOverloadedException(t) ? null : t);
714+
ClientExceptionsUtil.isMetaClearingException(t) ? null : t);
716715
for (Action action : e.getValue()) {
717716
Retry retry = manageError(
718717
action.getOriginalIndex(), action.getAction(), canRetry, t, server);
@@ -914,8 +913,7 @@ private void invokeCallBack(byte[] regionName, byte[] row, CResult result) {
914913
}
915914

916915
private void cleanServerCache(ServerName server, Throwable regionException) {
917-
if (ClientExceptionsUtil.isMetaClearingException(regionException)
918-
&& !ClientExceptionsUtil.isRegionServerOverloadedException(regionException)) {
916+
if (ClientExceptionsUtil.isMetaClearingException(regionException)) {
919917
// We want to make sure to clear the cache in case there were location-related exceptions.
920918
// We don't to clear the cache for every possible exception that comes through, however.
921919
asyncProcess.connection.clearCaches(server);

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,7 @@ public void updateCachedLocations(final TableName tableName, byte[] regionName,
19111911
RegionInfo regionInfo = oldLocation.getRegion();
19121912
Throwable cause = ClientExceptionsUtil.findException(exception);
19131913
if (cause != null) {
1914-
if (!ClientExceptionsUtil.isMetaClearingException(cause)
1915-
|| ClientExceptionsUtil.isRegionServerOverloadedException(cause)) {
1914+
if (!ClientExceptionsUtil.isMetaClearingException(cause)) {
19161915
// We know that the region is still on this region server
19171916
return;
19181917
}

hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ClientExceptionsUtil.java

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.hadoop.hbase.CallDroppedException;
3333
import org.apache.hadoop.hbase.CallQueueTooBigException;
3434
import org.apache.hadoop.hbase.DoNotRetryIOException;
35+
import org.apache.hadoop.hbase.MultiActionResultTooLarge;
3536
import org.apache.hadoop.hbase.NotServingRegionException;
3637
import org.apache.hadoop.hbase.RegionTooBusyException;
3738
import org.apache.hadoop.hbase.RetryImmediatelyException;
@@ -58,28 +59,18 @@ public static boolean isMetaClearingException(Throwable cur) {
5859
if (cur == null) {
5960
return true;
6061
}
61-
return !isMetaCachePreservingException(cur);
62+
return !isSpecialException(cur) || (cur instanceof RegionMovedException)
63+
|| cur instanceof NotServingRegionException;
6264
}
6365

64-
public static boolean isRegionServerOverloadedException(Throwable t) {
65-
t = findException(t);
66-
return isInstanceOfRegionServerOverloadedException(t);
67-
}
68-
69-
private static boolean isInstanceOfRegionServerOverloadedException(Throwable t) {
70-
return t instanceof CallQueueTooBigException || t instanceof CallDroppedException;
66+
public static boolean isSpecialException(Throwable cur) {
67+
return (cur instanceof RegionMovedException || cur instanceof RegionOpeningException
68+
|| cur instanceof RegionTooBusyException || cur instanceof RpcThrottlingException
69+
|| cur instanceof MultiActionResultTooLarge || cur instanceof RetryImmediatelyException
70+
|| cur instanceof CallQueueTooBigException || cur instanceof CallDroppedException
71+
|| cur instanceof NotServingRegionException || cur instanceof RequestTooBigException);
7172
}
7273

73-
private static boolean isMetaCachePreservingException(Throwable t) {
74-
return t instanceof RegionOpeningException || t instanceof RegionTooBusyException
75-
|| t instanceof RpcThrottlingException || t instanceof RetryImmediatelyException
76-
|| t instanceof RequestTooBigException;
77-
}
78-
79-
private static boolean isExceptionWeCare(Throwable t) {
80-
return isMetaCachePreservingException(t) || isInstanceOfRegionServerOverloadedException(t)
81-
|| t instanceof NotServingRegionException;
82-
}
8374

8475
/**
8576
* Look for an exception we know in the remote exception:
@@ -96,15 +87,15 @@ public static Throwable findException(Object exception) {
9687
}
9788
Throwable cur = (Throwable) exception;
9889
while (cur != null) {
99-
if (isExceptionWeCare(cur)) {
90+
if (isSpecialException(cur)) {
10091
return cur;
10192
}
10293
if (cur instanceof RemoteException) {
10394
RemoteException re = (RemoteException) cur;
10495
cur = re.unwrapRemoteException();
10596

10697
// unwrapRemoteException can return the exception given as a parameter when it cannot
107-
// unwrap it. In this case, there is no need to look further
98+
// unwrap it. In this case, there is no need to look further
10899
// noinspection ObjectEquality
109100
if (cur == re) {
110101
return cur;

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.ArrayList;
2828
import java.util.List;
2929
import org.apache.hadoop.conf.Configuration;
30-
import org.apache.hadoop.hbase.CallDroppedException;
3130
import org.apache.hadoop.hbase.CallQueueTooBigException;
3231
import org.apache.hadoop.hbase.HBaseClassTestRule;
3332
import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -41,7 +40,6 @@
4140
import org.apache.hadoop.hbase.TableName;
4241
import org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil;
4342
import org.apache.hadoop.hbase.exceptions.RegionOpeningException;
44-
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
4543
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
4644
import org.apache.hadoop.hbase.regionserver.HRegionServer;
4745
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
@@ -145,14 +143,12 @@ public void testPreserveMetaCacheOnException() throws Exception {
145143
table.mutateRow(mutations);
146144
} catch (IOException ex) {
147145
// Only keep track of the last exception that updated the meta cache
148-
if ((ClientExceptionsUtil.isMetaClearingException(ex)
149-
&& !ClientExceptionsUtil.isRegionServerOverloadedException(ex)) || success) {
146+
if (ClientExceptionsUtil.isMetaClearingException(ex) || success) {
150147
exp = ex;
151148
}
152149
}
153150
// Do not test if we did not touch the meta cache in this iteration.
154-
if (exp != null && ClientExceptionsUtil.isMetaClearingException(exp)
155-
&& !ClientExceptionsUtil.isRegionServerOverloadedException(exp)) {
151+
if (exp != null && ClientExceptionsUtil.isMetaClearingException(exp)) {
156152
assertNull(conn.getCachedLocation(TABLE_NAME, row));
157153
} else if (success) {
158154
assertNotNull(conn.getCachedLocation(TABLE_NAME, row));
@@ -211,9 +207,7 @@ public static List<Throwable> metaCachePreservingExceptions() {
211207
add(new RpcThrottlingException(" "));
212208
add(new MultiActionResultTooLarge(" "));
213209
add(new RetryImmediatelyException(" "));
214-
add(new RequestTooBigException());
215210
add(new CallQueueTooBigException());
216-
add(new CallDroppedException());
217211
}};
218212
}
219213

0 commit comments

Comments
 (0)