Skip to content

Commit 10dc41a

Browse files
authored
core: round robin should ignore name resolution error for channel state change when there are READY subchannels (#7595)
Round robin is keeping use of READY subchannels even if there is name resolution error. However, it moves Channel state to TRANSIENT_ERROR. In hierarchical load balancers, the upstream LB policy may need to aggregate pickers from multiple downstream round_robin LB policy while filtering out non-ready subchannels. It cannot infer if the subchannel can be used just from the SubchannelPicker interface. It relies on the state that the round_robin intends to set channel to. So the change is to match the readiness of the picker/subchannel with the state that round_robin tries to update. It will completely ignore name resolution error if there are READY subchannels.
1 parent 8020a73 commit 10dc41a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

core/src/main/java/io/grpc/util/RoundRobinLoadBalancer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ public void onSubchannelState(ConnectivityStateInfo state) {
130130

131131
@Override
132132
public void handleNameResolutionError(Status error) {
133-
// ready pickers aren't affected by status changes
134-
updateBalancingState(TRANSIENT_FAILURE,
135-
currentPicker instanceof ReadyPicker ? currentPicker : new EmptyPicker(error));
133+
if (currentState != READY) {
134+
updateBalancingState(TRANSIENT_FAILURE, new EmptyPicker(error));
135+
}
136136
}
137137

138138
private void processSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) {

core/src/test/java/io/grpc/util/RoundRobinLoadBalancerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,12 @@ public void nameResolutionErrorWithActiveChannels() throws Exception {
381381
loadBalancer.handleNameResolutionError(Status.NOT_FOUND.withDescription("nameResolutionError"));
382382

383383
verify(mockHelper, times(3)).createSubchannel(any(CreateSubchannelArgs.class));
384-
verify(mockHelper, times(3))
384+
verify(mockHelper, times(2))
385385
.updateBalancingState(stateCaptor.capture(), pickerCaptor.capture());
386386

387387
Iterator<ConnectivityState> stateIterator = stateCaptor.getAllValues().iterator();
388388
assertEquals(CONNECTING, stateIterator.next());
389389
assertEquals(READY, stateIterator.next());
390-
assertEquals(TRANSIENT_FAILURE, stateIterator.next());
391390

392391
LoadBalancer.PickResult pickResult = pickerCaptor.getValue().pickSubchannel(mockArgs);
393392
assertEquals(readySubchannel, pickResult.getSubchannel());

0 commit comments

Comments
 (0)