mirror of https://github.com/grpc/grpc-java.git
grpclb: cache requestConnection if no subchannel created
An issue was found during CBT RLS client testing: The RLS lb creates grplb child balancer, calls `grpclb.handleResolvedAddress()` then immediately calls `grpclb.requestConnection()`. The subchannel in `GrpclbState.currentPicker.pickList` contains only `GrpclbState.BUFFER_ENTRY` at the moment `grpclb.requestConnection()` is called, and therefore the `requestConnection()` is no-op, and RPC is hanging.
This commit is contained in:
parent
80f6d874cf
commit
3abdb2859f
|
|
@ -158,6 +158,7 @@ final class GrpclbState {
|
|||
private List<BackendEntry> backendList = Collections.emptyList();
|
||||
private RoundRobinPicker currentPicker =
|
||||
new RoundRobinPicker(Collections.<DropEntry>emptyList(), Arrays.asList(BUFFER_ENTRY));
|
||||
private boolean requestConnectionPending;
|
||||
|
||||
GrpclbState(
|
||||
GrpclbConfig config,
|
||||
|
|
@ -242,9 +243,11 @@ final class GrpclbState {
|
|||
}
|
||||
|
||||
void requestConnection() {
|
||||
requestConnectionPending = true;
|
||||
for (RoundRobinEntry entry : currentPicker.pickList) {
|
||||
if (entry instanceof IdleSubchannelEntry) {
|
||||
((IdleSubchannelEntry) entry).subchannel.requestConnection();
|
||||
requestConnectionPending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -471,6 +474,10 @@ final class GrpclbState {
|
|||
handleSubchannelState(subchannel, newState);
|
||||
}
|
||||
});
|
||||
if (requestConnectionPending) {
|
||||
subchannel.requestConnection();
|
||||
requestConnectionPending = false;
|
||||
}
|
||||
} else {
|
||||
subchannel = subchannels.values().iterator().next();
|
||||
subchannel.updateAddresses(eagList);
|
||||
|
|
|
|||
Loading…
Reference in New Issue