kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [kudu] 01/02: [java] Fix handling of SERVICE_UNAVAILABLE errors
Date Thu, 23 May 2019 18:16:15 GMT
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 2b5b7372f27a1009209bd30f86b2a725e9ba58eb
Author: Will Berkeley <wdberkeley@gmail.com>
AuthorDate: Fri May 10 10:07:48 2019 -0700

    [java] Fix handling of SERVICE_UNAVAILABLE errors
    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 <adar@cloudera.com>
    Reviewed-by: Andrew Wong <awong@cloudera.com>
 .../main/java/org/apache/kudu/client/AsyncKuduClient.java  |  3 ++-
 .../src/main/java/org/apache/kudu/client/RpcProxy.java     | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
index 6440702..1c909bf 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
@@ -2063,7 +2063,8 @@ public class AsyncKuduClient implements AutoCloseable {
    * 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 {}: {}",
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java
index 606cfd8..7b2f254 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java
@@ -409,11 +409,21 @@ class RpcProxy {
     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.
+      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
+      // tablet, opening the possibility of retrying on a different server.
       client.handleTabletNotFound(rpc, exception, connection.getServerInfo());

View raw message