Skip to content

Commit 310ce7b

Browse files
authored
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. Note that this change was also important because requestConnection() can be directly triggered by the user with channel.getState(true), and that shouldn't defeat the backoff timer.
1 parent fc08423 commit 310ce7b

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

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+
forwardTimeByBackoffDelay();
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)