Skip to content

Commit

Permalink
ENG-4468: Always perform only one server rpc call for readiness check.
Browse files Browse the repository at this point in the history
Summary:
Java client automatically retries (up to 100 times) on error return and overall timeout of 120sec.

Making the tserver readiness call only once with 5sec timeout, since it will return error when local bootstrap is happening. So the YW retry will check again as needed.

Test Plan: Jenkins: java-only

Reviewers: bogdan, neha

Reviewed By: neha

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D6344
  • Loading branch information
bbaddepudi committed Mar 18, 2019
1 parent 0f8fdd9 commit e48b7da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions java/yb-client/src/main/java/org/yb/client/AsyncYBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ public Deferred<IsTabletServerReadyResponse> isTServerReady(final HostAndPort hp
throw new IllegalStateException("Could not create a client to " + hp.toString());
}
IsTabletServerReadyRequest rpc = new IsTabletServerReadyRequest();
rpc.setTimeoutMillis(defaultAdminOperationTimeoutMs);
// TODO: Allow these two to be paramters in all such user API's.
rpc.maxAttempts = 1;
rpc.setTimeoutMillis(5000);

Deferred<IsTabletServerReadyResponse> d = rpc.getDeferred();
rpc.attempt++;
client.sendRpc(rpc);
Expand Down Expand Up @@ -1159,13 +1162,13 @@ TabletClient clientFor(RemoteTablet tablet) {
/**
* Checks whether or not an RPC can be retried once more.
* @param rpc The RPC we're going to attempt to execute.
* @return {@code true} if this RPC already had too many attempts,
* @return {@code true} if this RPC already had too many attempts or ran out of time,
* {@code false} otherwise (in which case it's OK to retry once more).
* @throws NonRecoverableException if the request has had too many attempts
* already.
*/
static boolean cannotRetryRequest(final YRpc<?> rpc) {
return rpc.deadlineTracker.timedOut() || rpc.attempt > 100; // TODO Don't hardcode.
return rpc.deadlineTracker.timedOut() || rpc.attempt >= rpc.maxAttempts;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions java/yb-client/src/main/java/org/yb/client/YRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public interface HasKey {
*/
byte attempt; // package-private for TabletClient and AsyncYBClient only.

// Maximum number of attempts to try the RPC. Default 100 times.
byte maxAttempts = 100;

// Whether or not retries for this RPC should always go to the same server. This is required in
// some cases where we do not want the RPC retries to hit a different server serving the same
// tablet.
Expand Down Expand Up @@ -242,6 +245,7 @@ public String toString() {
buf.append(tablet.getTabletIdAsString());
}
buf.append(", attempt=").append(attempt);
buf.append(", maxAttempts=").append(maxAttempts);
buf.append(", ").append(deadlineTracker);
buf.append(", ").append(deferred);
buf.append(')');
Expand Down

0 comments on commit e48b7da

Please sign in to comment.