Skip to content
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

Wrap StatusRuntimeExceptions from GrpcRemoteCache #7860

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ public static boolean isRemoteCacheOptions(RemoteOptions options) {
private ListenableFuture<FindMissingBlobsResponse> getMissingDigests(
FindMissingBlobsRequest request) throws IOException, InterruptedException {
Context ctx = Context.current();
return retrier.executeAsync(() -> ctx.call(() -> casFutureStub().findMissingBlobs(request)));
try {
return retrier.executeAsync(() -> ctx.call(() -> casFutureStub().findMissingBlobs(request)));
} catch (StatusRuntimeException e) {
throw new IOException(e);
}
}

private ImmutableSet<Digest> getMissingDigests(Iterable<Digest> digests)
Expand Down Expand Up @@ -274,6 +278,9 @@ public void onSuccess(Void result) {

@Override
public void onFailure(Throwable t) {
if (t instanceof StatusRuntimeException) {
t = new IOException(t);
}
outerF.setException(t);
}
},
Expand All @@ -289,12 +296,14 @@ private ListenableFuture<Void> downloadBlob(
Context ctx = Context.current();
AtomicLong offset = new AtomicLong(0);
ProgressiveBackoff progressiveBackoff = new ProgressiveBackoff(retrier::newBackoff);
return retrier.executeAsync(
() ->
ctx.call(
() ->
requestRead(
resourceName, offset, progressiveBackoff, digest, out, hashSupplier)));
return Futures.catchingAsync(
retrier.executeAsync(
() -> ctx.call(
() -> requestRead(resourceName, offset, progressiveBackoff, digest, out, hashSupplier)),
progressiveBackoff),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous implementation of the progressive read did not use the progressive backoff to determine the retry delay of successive requests. Put simply, we got progressive reads due to the offset, but there was no meaning to the progress from the perspective of the backoff used to proceed. A single download got max_retry_attempts to complete the download, and that's it - without this there was no effect to the progressiveBackoff being introduced.

StatusRuntimeException.class,
(e) -> Futures.immediateFailedFuture(new IOException(e)),
MoreExecutors.directExecutor());
}

static class ProgressiveBackoff implements Backoff {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public <T> ListenableFuture<T> executeAsync(AsyncCallable<T> call) {
* Executes an {@link AsyncCallable}, retrying execution in case of failure with the given
* backoff.
*/
private <T> ListenableFuture<T> executeAsync(AsyncCallable<T> call, Backoff backoff) {
public <T> ListenableFuture<T> executeAsync(AsyncCallable<T> call, Backoff backoff) {
try {
return Futures.catchingAsync(
call.call(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,13 +1011,10 @@ public void read(ReadRequest request, StreamObserver<ReadResponse> responseObser
boolean passedThroughDeadlineExceeded = false;
try {
getFromFuture(client.downloadBlob(digest));
} catch (RuntimeException e) {
fail("Should have thrown an exception.");
} catch (IOException e) {
Status st = Status.fromThrowable(e);
if (st.getCode() != Status.Code.DEADLINE_EXCEEDED) {
throw e;
}
passedThroughDeadlineExceeded = true;
assertThat(st.getCode()).isEqualTo(Status.Code.DEADLINE_EXCEEDED);
}
assertThat(passedThroughDeadlineExceeded).isTrue();
}
}