Skip to content

Commit a584688

Browse files
authored
[Dataflow Streaming] Change GrpcGetDataStream to backoff requests that have been cancelled. (#36475)
1 parent bf4bf81 commit a584688

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

  • runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc

runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc/GrpcGetDataStream.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ final class GrpcGetDataStream
8080

8181
static final FluentBackoff BACK_OFF_FACTORY =
8282
FluentBackoff.DEFAULT
83-
.withInitialBackoff(Duration.millis(10))
83+
.withInitialBackoff(Duration.millis(1))
8484
.withMaxBackoff(Duration.standardSeconds(10));
8585

8686
/**
@@ -439,23 +439,24 @@ private <ResponseT> ResponseT issueRequest(QueuedRequest request, ParseFn<Respon
439439
try {
440440
queueRequestAndWait(request);
441441
return parseFn.parse(request.getResponseStream());
442-
} catch (AppendableInputStream.InvalidInputStreamStateException | CancellationException e) {
442+
} catch (CancellationException e) {
443443
throwIfShutdown(request, e);
444-
if (!(e instanceof CancellationException)) {
445-
throw e;
446-
}
444+
} catch (AppendableInputStream.InvalidInputStreamStateException e) {
445+
throwIfShutdown(request, e);
446+
throw e;
447447
} catch (IOException e) {
448448
LOG.error("Parsing GetData response failed: ", e);
449-
try {
450-
BackOffUtils.next(Sleeper.DEFAULT, backoff);
451-
} catch (InterruptedException ie) {
452-
Thread.currentThread().interrupt();
453-
}
454449
} catch (InterruptedException e) {
455450
Thread.currentThread().interrupt();
456451
throwIfShutdown(request, e);
457452
throw new RuntimeException(e);
458453
}
454+
// In all cases we are going to retry, perform some backoff
455+
try {
456+
BackOffUtils.next(Sleeper.DEFAULT, backoff);
457+
} catch (InterruptedException ie) {
458+
Thread.currentThread().interrupt();
459+
}
459460
}
460461
}
461462

0 commit comments

Comments
 (0)