Skip to content

Commit f20c96d

Browse files
author
waterWang
committed
fix: make perAttemptRecvTimeout actually apply to retry attempts
The perAttemptRecvTimeout field in RetryPolicy has been configurable since PR #8301 but was never actually applied to individual retry attempts. The DeadlineEntry in RetriableStream.setDeadline() simply passed through the original deadline without considering the per-attempt timeout. Fix: When perAttemptRecvTimeoutNanos is set in the retry policy, apply the minimum of the original deadline and the per-attempt deadline to each substream. This ensures that each retry attempt is bounded by the per-attempt timeout, relative to when the attempt starts. Fixes #12919 [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]
1 parent 3b3002c commit f20c96d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

core/src/main/java/io/grpc/internal/RetriableStream.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,13 @@ public final void setDeadline(final Deadline deadline) {
754754
class DeadlineEntry implements BufferEntry {
755755
@Override
756756
public void runWith(Substream substream) {
757-
substream.stream.setDeadline(deadline);
757+
if (retryPolicy != null && retryPolicy.perAttemptRecvTimeoutNanos != null) {
758+
Deadline perAttemptDeadline =
759+
Deadline.after(retryPolicy.perAttemptRecvTimeoutNanos, TimeUnit.NANOSECONDS);
760+
substream.stream.setDeadline(deadline.minimum(perAttemptDeadline));
761+
} else {
762+
substream.stream.setDeadline(deadline);
763+
}
758764
}
759765
}
760766

0 commit comments

Comments
 (0)