Skip to content

xds: Fix XDS control plane client retry timer backoff duration when connection closes after results are received #11766

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

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fix retry timer backoff duration.
  • Loading branch information
larry-safran committed Dec 19, 2024
commit 6a17ea5c2c860ae6d22a37615a31b7c9beaf7390
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
Loading