-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-28050 RSProcedureDispatcher to fail-fast for krb auth failures #5391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
3a5bc01
a61c49f
4a79223
8549505
a8ba2ee
420fcb6
8b59b13
6fbfe4d
fbea61e
a8626fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,10 @@ | |
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.concurrent.TimeUnit; | ||
| import javax.security.sasl.SaslException; | ||
| import org.apache.hadoop.hbase.CallQueueTooBigException; | ||
| import org.apache.hadoop.hbase.DoNotRetryIOException; | ||
| import org.apache.hadoop.hbase.HConstants; | ||
| import org.apache.hadoop.hbase.ServerName; | ||
| import org.apache.hadoop.hbase.client.AsyncRegionServerAdmin; | ||
| import org.apache.hadoop.hbase.client.RegionInfo; | ||
|
|
@@ -287,17 +289,7 @@ private boolean scheduleForRetry(IOException e) { | |
| numberOfAttemptsSoFar); | ||
| return false; | ||
| } | ||
| // This exception is thrown in the rpc framework, where we can make sure that the call has not | ||
| // been executed yet, so it is safe to mark it as fail. Especially for open a region, we'd | ||
| // better choose another region server. | ||
| // Notice that, it is safe to quit only if this is the first time we send request to region | ||
| // server. Maybe the region server has accepted our request the first time, and then there is | ||
| // a network error which prevents we receive the response, and the second time we hit a | ||
| // CallQueueTooBigException, obviously it is not safe to quit here, otherwise it may lead to a | ||
| // double assign... | ||
| if (e instanceof CallQueueTooBigException && numberOfAttemptsSoFar == 0) { | ||
| LOG.warn("request to {} failed due to {}, try={}, this usually because" | ||
| + " server is overloaded, give up", serverName, e.toString(), numberOfAttemptsSoFar); | ||
| if (unableToConnectToServerInFirstAttempt(e)) { | ||
| return false; | ||
| } | ||
| // Always retry for other exception types if the region server is not dead yet. | ||
|
|
@@ -330,6 +322,73 @@ private boolean scheduleForRetry(IOException e) { | |
| return true; | ||
| } | ||
|
|
||
| private boolean unableToConnectToServerInFirstAttempt(IOException e) { | ||
|
||
| // This exception is thrown in the rpc framework, where we can make sure that the call has not | ||
| // been executed yet, so it is safe to mark it as fail. Especially for open a region, we'd | ||
| // better choose another region server. | ||
| // Notice that, it is safe to quit only if this is the first time we send request to region | ||
|
||
| // server. Maybe the region server has accepted our request the first time, and then there is | ||
| // a network error which prevents we receive the response, and the second time we hit a | ||
| // CallQueueTooBigException, obviously it is not safe to quit here, otherwise it may lead to a | ||
| // double assign... | ||
| if (e instanceof CallQueueTooBigException && numberOfAttemptsSoFar == 0) { | ||
| LOG.warn("request to {} failed due to {}, try={}, this usually because" | ||
| + " server is overloaded, give up", serverName, e, numberOfAttemptsSoFar); | ||
| return true; | ||
| } | ||
| if (isSaslError(e) && numberOfAttemptsSoFar == 0) { | ||
| LOG.warn("{} is not reachable; give up after first attempt", serverName, e); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private boolean isSaslError(IOException e) { | ||
| if ( | ||
| e instanceof SaslException | ||
| || (e.getMessage() != null && e.getMessage().contains(HConstants.RELOGIN_IS_IN_PROGRESS)) | ||
| ) { | ||
| return true; | ||
| } | ||
| // check 4 level of cause | ||
|
||
| Throwable cause = e.getCause(); | ||
| if (cause == null) { | ||
| return false; | ||
| } | ||
| if (isSaslError(cause)) { | ||
| return true; | ||
| } | ||
| cause = cause.getCause(); | ||
| if (cause == null) { | ||
| return false; | ||
| } | ||
| if (isSaslError(cause)) { | ||
| return true; | ||
| } | ||
| cause = cause.getCause(); | ||
| if (cause == null) { | ||
| return false; | ||
| } | ||
| if (isSaslError(cause)) { | ||
| return true; | ||
| } | ||
| cause = cause.getCause(); | ||
| if (cause == null) { | ||
| return false; | ||
| } | ||
| return isSaslError(cause); | ||
| } | ||
|
|
||
| private boolean isSaslError(Throwable cause) { | ||
|
||
| if (cause instanceof IOException) { | ||
| IOException unwrappedException = unwrapException((IOException) cause); | ||
| return unwrappedException instanceof SaslException | ||
| || (unwrappedException.getMessage() != null | ||
| && unwrappedException.getMessage().contains(HConstants.RELOGIN_IS_IN_PROGRESS)); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private long getMaxWaitTime() { | ||
| if (this.maxWaitTime < 0) { | ||
| // This is the max attempts, not retries, so it should be at least 1. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird, please don't put these kinds of constants in HConstants. There are too many unrelated concerns there already.
Public static string constant in some other file, even this one, is preferred.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NettyRpcConnection is package private, hence can't be accessed from hbase-server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what is the best place to keep this, anywhere else in hbase-common would also work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not put it in HConstants, it is IA.Public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i understand but i am not sure what is the best place to keep this in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, this is now taken care of