Skip to content

Commit

Permalink
Fix retry timer backoff duration.
Browse files Browse the repository at this point in the history
  • Loading branch information
larry-safran committed Dec 19, 2024
1 parent 7601afc commit 6a17ea5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 2 additions & 5 deletions xds/src/main/java/io/grpc/xds/client/ControlPlaneClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,9 @@ private void handleRpcStreamClosed(Status status) {
// FakeClock in tests isn't thread-safe. Schedule the retry timer before notifying callbacks
// to avoid TSAN races, since tests may wait until callbacks are called but then would run
// concurrently with the stopwatch and schedule.

long elapsed = stopwatch.elapsed(TimeUnit.NANOSECONDS);
long delayNanos = Math.max(0, retryBackoffPolicy.nextBackoffNanos() - elapsed);

rpcRetryTimer =
syncContext.schedule(new RpcRetryTask(), delayNanos, TimeUnit.NANOSECONDS, timeService);
syncContext.schedule(new RpcRetryTask(), retryBackoffPolicy.nextBackoffNanos(),
TimeUnit.NANOSECONDS, timeService);

Status newStatus = status;
if (responseReceived) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3524,6 +3524,7 @@ public void streamClosedAndRetryWithBackoff() {
call.verifyRequest(EDS, EDS_RESOURCE, "", "", NODE);

// Management server closes the RPC stream with an error.
fakeClock.forwardNanos(1000L); // Make sure retry isn't based on stopwatch 0
call.sendError(Status.UNKNOWN.asException());
verify(ldsResourceWatcher, Mockito.timeout(1000).times(1))
.onError(errorCaptor.capture());
Expand Down

0 comments on commit 6a17ea5

Please sign in to comment.