Skip to content

Commit 02aa9b8

Browse files
committed
core: Wait for backoff timer on address update in pick_first
The backoff timer is only used when serializeRetries=true, and that exists to match the old/current pick_first's behavior as closely as possible. InternalSubchannel.updateAddresses() would take no action when in TRANSIENT_FAILURE; it would update the addresses and just wait for the backoff timer to expire. Note that this only impacts serializeRetries=true; in the other cases we do want to start trying to the new addresses immediately, because the backoff timers are in the subchannels.
1 parent fa7b52b commit 02aa9b8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ private void shutdownRemaining(SubchannelData activeSubchannelData) {
496496
*/
497497
@Override
498498
public void requestConnection() {
499-
if (!addressIndex.isValid() || rawConnectivityState == SHUTDOWN) {
499+
if (!addressIndex.isValid() || rawConnectivityState == SHUTDOWN || reconnectTask != null) {
500500
return;
501501
}
502502

core/src/test/java/io/grpc/internal/PickFirstLeafLoadBalancerTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,11 @@ public void updateAddresses_disjoint_transient_failure() {
14461446
loadBalancer.acceptResolvedAddresses(
14471447
ResolvedAddresses.newBuilder().setAddresses(newServers).setAttributes(affinity).build());
14481448

1449+
if (serializeRetries) {
1450+
inOrder.verify(mockSubchannel3, never()).start(stateListenerCaptor.capture());
1451+
fakeClock.forwardTime(1, TimeUnit.SECONDS);
1452+
}
1453+
14491454
// subchannel 3 still attempts a connection even though we stay in transient failure
14501455
assertEquals(TRANSIENT_FAILURE, loadBalancer.getConcludedConnectivityState());
14511456
inOrder.verify(mockSubchannel3).start(stateListenerCaptor.capture());

0 commit comments

Comments
 (0)