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 List<BackendEntry> backendList = Collections.emptyList();
|
||||||
private RoundRobinPicker currentPicker =
|
private RoundRobinPicker currentPicker =
|
||||||
new RoundRobinPicker(Collections.<DropEntry>emptyList(), Arrays.asList(BUFFER_ENTRY));
|
new RoundRobinPicker(Collections.<DropEntry>emptyList(), Arrays.asList(BUFFER_ENTRY));
|
||||||
|
private boolean requestConnectionPending;
|
||||||
|
|
||||||
GrpclbState(
|
GrpclbState(
|
||||||
GrpclbConfig config,
|
GrpclbConfig config,
|
||||||
|
|
@ -242,9 +243,11 @@ final class GrpclbState {
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestConnection() {
|
void requestConnection() {
|
||||||
|
requestConnectionPending = true;
|
||||||
for (RoundRobinEntry entry : currentPicker.pickList) {
|
for (RoundRobinEntry entry : currentPicker.pickList) {
|
||||||
if (entry instanceof IdleSubchannelEntry) {
|
if (entry instanceof IdleSubchannelEntry) {
|
||||||
((IdleSubchannelEntry) entry).subchannel.requestConnection();
|
((IdleSubchannelEntry) entry).subchannel.requestConnection();
|
||||||
|
requestConnectionPending = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -471,6 +474,10 @@ final class GrpclbState {
|
||||||
handleSubchannelState(subchannel, newState);
|
handleSubchannelState(subchannel, newState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (requestConnectionPending) {
|
||||||
|
subchannel.requestConnection();
|
||||||
|
requestConnectionPending = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
subchannel = subchannels.values().iterator().next();
|
subchannel = subchannels.values().iterator().next();
|
||||||
subchannel.updateAddresses(eagList);
|
subchannel.updateAddresses(eagList);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue