Skip to content

Commit

Permalink
[java] Fix handling of SERVICE_UNAVAILABLE errors
Browse files Browse the repository at this point in the history
When the Java client sends a write, and it is rejected due to, e.g., a
soft memory limit error, it causes the client to invalidate the leader's
location for the tablet. The client then has to do a GetTableLocations
lookup on the master to refresh the cache. This is silly because the
location is valid and the leader is where the write must go. This patch
corrects the handling of certain RPC-level errors including the handling
of SERVICE_UNAVAILABLE. It will reduce greatly the number of unnecessary
calls to the master. These usually aren't a problem because master
lookups are fast, but it's a waste of time and resources nonetheless.

Change-Id: Id3437c779322e756a6e1fbc19f464f765741d58b
Reviewed-on: http://gerrit.cloudera.org:8080/13308
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
Reviewed-by: Andrew Wong <[email protected]>
  • Loading branch information
wdberkeley committed May 22, 2019
1 parent 6a8d1d2 commit 2b5b737
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,8 @@ public void run(final Timeout timeout) {
* Remove the tablet server from the RemoteTablet's locations. Right now nothing is removing
* the tablet itself from the caches.
*/
private void invalidateTabletCache(RemoteTablet tablet, ServerInfo info,
private void invalidateTabletCache(RemoteTablet tablet,
ServerInfo info,
String errorMessage) {
final String uuid = info.getUuid();
LOG.info("Invalidating location {} for tablet {}: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,21 @@ private static void failOrRetryRpc(AsyncKuduClient client,
.build());

RemoteTablet tablet = rpc.getTablet();
// Note As of the time of writing (03/11/16), a null tablet doesn't make sense, if we see a null
// tablet it's because we didn't set it properly before calling sendRpc().
// Note: As of the time of writing (03/11/16), a null tablet doesn't make sense, if we see a
// null tablet it's because we didn't set it properly before calling sendRpc().
if (tablet == null) { // Can't retry, dunno where this RPC should go.
rpc.errback(exception);
return;
}
if (exception instanceof InvalidAuthnTokenException) {
client.handleInvalidAuthnToken(rpc);
} else if (exception instanceof InvalidAuthzTokenException) {
client.handleInvalidAuthzToken(rpc, exception);
} else if (exception.getStatus().isServiceUnavailable()) {
client.handleRetryableError(rpc, exception);
} else {
// If we don't really know anything about the exception, invalidate the location for the
// tablet, opening the possibility of retrying on a different server.
client.handleTabletNotFound(rpc, exception, connection.getServerInfo());
}
}
Expand Down

0 comments on commit 2b5b737

Please sign in to comment.